From ea58b3887a7deba05e3fc85eb536038a547f8871 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 17 Jul 2016 18:56:29 +0200 Subject: lexer/parser: o Renaming the ASSERT_K token to ASSERT. o Fixing a bug in the NAME regex where underscored where not allowed in certain names. o All ASSERT statements use string instead of NAME. o Improving STRING_ANY, allow many non-quote tokens instead of just one. Can probably replace the entire string rule with STRING_ANY now. o Fixing naming of '!', "~" and "?" operators. Ld: o Implement support for multiplication and division operators. o Better error messages. --- GnuLdParser.g4 | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'GnuLdParser.g4') diff --git a/GnuLdParser.g4 b/GnuLdParser.g4 index 0d2bf4b..974eba2 100644 --- a/GnuLdParser.g4 +++ b/GnuLdParser.g4 @@ -122,13 +122,13 @@ casesymlist: /* Parsed as expressions so that commas separate entries */ extern_name_list: - extern_name_list_body + extern_name_list_body ; extern_name_list_body: - NAME - | extern_name_list_body NAME - | extern_name_list_body COMMA NAME + NAME + | extern_name_list_body NAME + | extern_name_list_body COMMA NAME ; script_file: @@ -151,7 +151,7 @@ ifile_p1: | floating_point_support | statement_anywhere | version - | SEMICOLON + | SEMICOLON | TARGET_K LPAREN NAME RPAREN | SEARCH_DIR LPAREN filename RPAREN | OUTPUT LPAREN filename RPAREN @@ -202,7 +202,7 @@ sec_or_group_p1: statement_anywhere: ENTRY LPAREN NAME RPAREN | assignment end - | ASSERT_K LPAREN exp COMMA string RPAREN + | ASSERT LPAREN exp COMMA string RPAREN ; /* The '*' and '?' cases are there because the lexer returns them as @@ -275,7 +275,7 @@ statement: | input_section_spec | length LPAREN mustbe_exp RPAREN | FILL LPAREN fill_exp RPAREN - | ASSERT_K LPAREN exp COMMA NAME RPAREN end + | ASSERT LPAREN exp COMMA string RPAREN end | INCLUDE filename statement_list_opt END ; @@ -435,9 +435,9 @@ exp: DASH exp # expNegate // TODO: %prec UNARY | LPAREN exp RPAREN # expParen | NEXT LPAREN exp RPAREN # expNextParen // TODO: %prec UNARY - | EXLAMATION exp # expInvert // TODO: %prec UNARY + | EXLAMATION exp # expNot // TODO: %prec UNARY | PLUS exp # expPlus // TODO: %prec UNARY - | TILDE exp # expMinus // TODO: %prec UNARY + | TILDE exp # expInvert // TODO: %prec UNARY | exp STAR exp # expMul | exp SLASH exp # expDiv | exp MOD exp # expMod @@ -454,7 +454,7 @@ exp: | exp AMPERSAND exp # expAnd | exp HAT exp # expXor | exp BAR exp # expOr - | exp QUESTION exp COLON exp # expTrinary + | exp QUESTION exp COLON exp # expTernary | exp ANDAND exp # expAndand | exp OROR exp # expOror | DEFINED LPAREN NAME RPAREN # expDefined @@ -476,7 +476,7 @@ exp: | NAME # expName | MAX_K LPAREN exp COMMA exp RPAREN # expMax | MIN_K LPAREN exp COMMA exp RPAREN # expMin - | ASSERT_K LPAREN exp COMMA NAME RPAREN # expAssert + | ASSERT LPAREN exp COMMA string RPAREN # expAssert | ORIGIN LPAREN NAME RPAREN # expOrigin | LENGTH LPAREN NAME RPAREN # expLengthExp | LOG2CEIL LPAREN exp RPAREN # expLog2ceil @@ -678,10 +678,8 @@ vers_defns: | NAME | vers_defns SEMICOLON VERS_IDENTIFIER | vers_defns SEMICOLON NAME - | vers_defns SEMICOLON EXTERN NAME LBRACE - vers_defns opt_semicolon RBRACE - | EXTERN NAME LBRACE - vers_defns opt_semicolon RBRACE + | vers_defns SEMICOLON EXTERN NAME LBRACE vers_defns opt_semicolon RBRACE + | EXTERN NAME LBRACE vers_defns opt_semicolon RBRACE | GLOBAL | vers_defns SEMICOLON GLOBAL | LOCAL -- cgit v1.2.3