PR28198, Support # as linker script comment marker
authorAlan Modra <amodra@gmail.com>
Wed, 11 Aug 2021 08:46:35 +0000 (18:16 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 11 Aug 2021 10:16:43 +0000 (19:46 +0930)
PR 28198
* ldlex.l: Combine rules for handling newline, whitespace and
comments.  Extend # comment handling to all states.

ld/ldlex.l

index 25b4bcaae01daf319a8399324a497263bb90c30e..f588bd3adc59be4ca6afffd6fe1b72e01acccb5a 100644 (file)
@@ -420,8 +420,13 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
                                        yylval.name[len] = 0;
                                        return NAME;
                                }
-<BOTH,SCRIPT,EXPRESSION>"\n"           { lineno++;}
-<MRI,BOTH,SCRIPT,EXPRESSION>[ \t\r]+   { }
+
+<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>"\n" {
+                               lineno++; }
+<MRI,BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>[ \t\r]+ {
+                               /* Eat up whitespace */ }
+<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT>#.* {
+                               /* Eat up comments */ }
 
 <VERS_NODE,VERS_SCRIPT>[:,;]   { return *yytext; }
 
@@ -450,12 +455,6 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
                                  return *yytext;
                                }
 
-<VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>[\n]       { lineno++; }
-
-<VERS_START,VERS_NODE,VERS_SCRIPT>#.*          { /* Eat up comments */ }
-
-<VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>[ \t\r]+   { /* Eat up whitespace */ }
-
 <<EOF>> {
   include_stack_ptr--;
   if (include_stack_ptr == 0)