2014-10-15 Hans-Peter Nilsson <hp@axis.com>
+ * ldlex.l (INPUTLIST): New start condition.
+ (comment pattern, ",", "(", ")", "AS_NEEDED")
+ ({FILENAMECHAR1}{FILENAMECHAR}*, "-l"{FILENAMECHAR}+)
+ (quoted string pattern, whitespace pattern): Add INPUTLIST to
+ valid start conditions.
+ (<INPUTLIST>"="{FILENAMECHAR1}{FILENAMECHAR}*): New NAME rule.
+ (ldlex_inputlist): New start-condition-setter function.
+ * ldgram.y (input_list1): Rename from input_list. All recursive
+ use changed.
+ (input_list): New wrapper rule for input_list1, setting
+ INPUTLIST lexer state for the duration of parsing input_list1.
* ldlang.c (lang_add_input_file): If the first character in the
filename is '=', prepend the sysroot and force the context of that
input file to non-sysroot.
;
input_list:
+ { ldlex_inputlist(); }
+ input_list1
+ { ldlex_popstate(); }
+
+input_list1:
NAME
{ lang_add_input_file($1,lang_input_file_is_search_file_enum,
(char *)NULL); }
- | input_list ',' NAME
+ | input_list1 ',' NAME
{ lang_add_input_file($3,lang_input_file_is_search_file_enum,
(char *)NULL); }
- | input_list NAME
+ | input_list1 NAME
{ lang_add_input_file($2,lang_input_file_is_search_file_enum,
(char *)NULL); }
| LNAME
{ lang_add_input_file($1,lang_input_file_is_l_enum,
(char *)NULL); }
- | input_list ',' LNAME
+ | input_list1 ',' LNAME
{ lang_add_input_file($3,lang_input_file_is_l_enum,
(char *)NULL); }
- | input_list LNAME
+ | input_list1 LNAME
{ lang_add_input_file($2,lang_input_file_is_l_enum,
(char *)NULL); }
| AS_NEEDED '('
{ $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
input_flags.add_DT_NEEDED_for_regular = TRUE; }
- input_list ')'
+ input_list1 ')'
{ input_flags.add_DT_NEEDED_for_regular = $<integer>3; }
- | input_list ',' AS_NEEDED '('
+ | input_list1 ',' AS_NEEDED '('
{ $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
input_flags.add_DT_NEEDED_for_regular = TRUE; }
- input_list ')'
+ input_list1 ')'
{ input_flags.add_DT_NEEDED_for_regular = $<integer>5; }
- | input_list AS_NEEDED '('
+ | input_list1 AS_NEEDED '('
{ $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
input_flags.add_DT_NEEDED_for_regular = TRUE; }
- input_list ')'
+ input_list1 ')'
{ input_flags.add_DT_NEEDED_for_regular = $<integer>4; }
;
/* STATES
EXPRESSION definitely in an expression
SCRIPT definitely in a script
+ INPUTLIST definitely in a script, a filename-list
BOTH either EXPRESSION or SCRIPT
DEFSYMEXP in an argument to -defsym
MRI in an MRI script
V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
%s SCRIPT
+%s INPUTLIST
%s EXPRESSION
%s BOTH
%s DEFSYMEXP
}
}
-<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT>"/*" { comment (); }
+<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>"/*" { comment (); }
<DEFSYMEXP>"-" { RTOKEN('-');}
<BOTH,SCRIPT,EXPRESSION,MRI>"|=" { RTOKEN(OREQ);}
<BOTH,SCRIPT,EXPRESSION,MRI>"&&" { RTOKEN(ANDAND);}
<BOTH,SCRIPT,EXPRESSION,MRI>">" { RTOKEN('>');}
-<BOTH,SCRIPT,EXPRESSION,MRI>"," { RTOKEN(',');}
+<BOTH,SCRIPT,EXPRESSION,MRI,INPUTLIST>"," { RTOKEN(',');}
<BOTH,SCRIPT,EXPRESSION,MRI>"&" { RTOKEN('&');}
<BOTH,SCRIPT,EXPRESSION,MRI>"|" { RTOKEN('|');}
<BOTH,SCRIPT,EXPRESSION,MRI>"~" { RTOKEN('~');}
<BOTH,SCRIPT,EXPRESSION,MRI>"=" { RTOKEN('=');}
<BOTH,SCRIPT,EXPRESSION,MRI>"}" { RTOKEN('}') ; }
<BOTH,SCRIPT,EXPRESSION,MRI>"{" { RTOKEN('{'); }
-<BOTH,SCRIPT,EXPRESSION,MRI>")" { RTOKEN(')');}
-<BOTH,SCRIPT,EXPRESSION,MRI>"(" { RTOKEN('(');}
+<BOTH,SCRIPT,EXPRESSION,MRI,INPUTLIST>")" { RTOKEN(')');}
+<BOTH,SCRIPT,EXPRESSION,MRI,INPUTLIST>"(" { RTOKEN('(');}
<BOTH,SCRIPT,EXPRESSION,MRI>":" { RTOKEN(':'); }
<BOTH,SCRIPT,EXPRESSION,MRI>";" { RTOKEN(';');}
<BOTH,SCRIPT>"MEMORY" { RTOKEN(MEMORY);}
<BOTH,SCRIPT>"OUTPUT" { RTOKEN(OUTPUT);}
<BOTH,SCRIPT>"INPUT" { RTOKEN(INPUT);}
<EXPRESSION,BOTH,SCRIPT>"GROUP" { RTOKEN(GROUP);}
-<EXPRESSION,BOTH,SCRIPT>"AS_NEEDED" { RTOKEN(AS_NEEDED);}
+<EXPRESSION,BOTH,SCRIPT,INPUTLIST>"AS_NEEDED" { RTOKEN(AS_NEEDED);}
<EXPRESSION,BOTH,SCRIPT>"DEFINED" { RTOKEN(DEFINED);}
<BOTH,SCRIPT>"CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);}
<BOTH,SCRIPT>"CONSTRUCTORS" { RTOKEN( CONSTRUCTORS);}
}
-<BOTH>{FILENAMECHAR1}{FILENAMECHAR}* {
+<BOTH,INPUTLIST>{FILENAMECHAR1}{FILENAMECHAR}* {
yylval.name = xstrdup (yytext);
return NAME;
}
-<BOTH>"-l"{FILENAMECHAR}+ {
+<INPUTLIST>"="{FILENAMECHAR1}{FILENAMECHAR}* {
+/* Filename to be prefixed by --sysroot or when non-sysrooted, nothing. */
+ yylval.name = xstrdup (yytext);
+ return NAME;
+ }
+<BOTH,INPUTLIST>"-l"{FILENAMECHAR}+ {
yylval.name = xstrdup (yytext + 2);
return LNAME;
}
}
}
-<EXPRESSION,BOTH,SCRIPT,VERS_NODE>"\""[^\"]*"\"" {
+<EXPRESSION,BOTH,SCRIPT,VERS_NODE,INPUTLIST>"\""[^\"]*"\"" {
/* No matter the state, quotes
give what's inside */
yylval.name = xstrdup (yytext + 1);
<VERS_START,VERS_NODE,VERS_SCRIPT>#.* { /* Eat up comments */ }
-<VERS_START,VERS_NODE,VERS_SCRIPT>[ \t\r]+ { /* Eat up whitespace */ }
+<VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>[ \t\r]+ { /* Eat up whitespace */ }
<<EOF>> {
include_stack_ptr--;
BEGIN (SCRIPT);
}
+void
+ldlex_inputlist (void)
+{
+ *(state_stack_p)++ = yy_start;
+ BEGIN (INPUTLIST);
+}
+
void
ldlex_mri_script (void)
{