+2021-02-01 Alan Modra <amodra@gmail.com>
+
+ * ldgram.y (section): Call ldlex_backup. Remove empty action.
+ * ldlex.h (ldlex_backup): Declare.
+ * ldlex.l (<EXPRESSION>NAME): Don't use NOCFILENAMECHAR set of
+ chars, use SYMBOLNAMECHAR.
+ (ldlex_backup): New function.
+
2021-02-01 Alan Modra <amodra@gmail.com>
* ldgram.y: Whitespace fixes.
'}' { ldlex_popstate (); ldlex_expression (); }
memspec_opt memspec_at_opt phdr_opt fill_opt
{
+ if (yychar == NAME)
+ {
+ yyclearin;
+ ldlex_backup ();
+ }
ldlex_popstate ();
lang_leave_output_section_statement ($18, $15, $17, $16);
}
opt_comma
- {}
| OVERLAY
{ ldlex_expression (); }
opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
{ ldlex_popstate (); ldlex_expression (); }
memspec_opt memspec_at_opt phdr_opt fill_opt
{
+ if (yychar == NAME)
+ {
+ yyclearin;
+ ldlex_backup ();
+ }
ldlex_popstate ();
lang_leave_overlay ($5, (int) $4,
$16, $13, $15, $14);
extern void ldlex_expression (void);
extern void ldlex_both (void);
extern void ldlex_popstate (void);
+extern void ldlex_backup (void);
extern const char* ldlex_filename (void);
/* In lexsup.c. */
yylval.name = xstrdup (yytext + 2);
return LNAME;
}
-<EXPRESSION>{SYMBOLNAMECHAR1}{NOCFILENAMECHAR}* {
+<EXPRESSION>{SYMBOLNAMECHAR1}{SYMBOLNAMECHAR}* {
yylval.name = xstrdup (yytext);
return NAME;
}
yy_start = *(--state_stack_p);
}
+/* In cases where the parser needs to look ahead and the context
+ changes from expression to script or vice-versa, throw away a
+ NAME. What constitutes a NAME depends on context. */
+
+void
+ldlex_backup (void)
+{
+ yyless (0);
+}
+
/* Return the current file name, or the previous file if no file is
current. */