diff --git a/parser/parser_lex.l b/parser/parser_lex.l index 22fd2b5a4..62303fa39 100644 --- a/parser/parser_lex.l +++ b/parser/parser_lex.l @@ -255,9 +255,11 @@ MODES {MODE_CHARS}+ WS [[:blank:]] NUMBER [[:digit:]]+ +ID_FIRST_CHARS [^ \t\r\n"!,#] +ID_FIRST {ID_CHARS}|(,{ID_CHARS}|\\[ ]|\\\t|\\\"|\\!|\\,|\\#) ID_CHARS [^ \t\r\n"!,] ID {ID_CHARS}|(,{ID_CHARS}|\\[ ]|\\\t|\\\"|\\!|\\,) -IDS {ID}+ +IDS {ID_FIRST}{ID}* INC_ID [^ \t\r\n"!,<>]|(,[^ \t\r\n"!,<>]|\\[ ]|\\\t|\\\"|\\!|\\,) INC_IDS {INC_ID}+ POST_VAR_ID_CHARS [^ \t\n"!,]{-}[=\+] @@ -507,6 +509,12 @@ GT > yyerror(_("Variable declarations do not accept trailing commas")); } + #.*\r?\n { /* normal comment */ + DUMP_AND_DEBUG("comment(%d): %s\n", current_lineno, yytext); + current_lineno++; + POP(); + } + \\\n { DUMP_PREPROCESS; current_lineno++ ; } \r?\n { diff --git a/parser/tst/equality.sh b/parser/tst/equality.sh index a0badfa55..082b68f7c 100755 --- a/parser/tst/equality.sh +++ b/parser/tst/equality.sh @@ -643,6 +643,18 @@ verify_binary_equality "attachment slash filtering" \ @{FOO}=/foo /t @{BAR}/@{FOO} { }" +# verify comment at end of variable assignment is not treated as a value +verify_binary_equality "comment at end of set var" \ + "/t { /bin/ r, }" \ + "@{BAR}=/bin/ #a tail comment + /t { @{BAR} r, }" + +verify_binary_equality "value like comment at end of set var" \ + "/t { /{bin/,#value} r, }" \ + "@{BAR}=bin/ \#value + /t { /@{BAR} r, }" + + # This can potentially fail as ideally it requires a better dfa comparison # routine as it can generates hormomorphic dfas. The enumeration of the # dfas dumped will be different, even if the binary is the same