unsigned int lineno = 1;
int old;
+static comment();
+
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) yy_input(buf, &result, max_size)
#undef YY_FATAL_ERROR
%a 4000
%o 5000
-CMDFILENAMECHAR [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\-]
-CMDFILENAMECHAR1 [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>]
-FILENAMECHAR1 [_a-zA-Z\/\.\\]
+CMDFILENAMECHAR [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\-\~]
+CMDFILENAMECHAR1 [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\~]
+FILENAMECHAR1 [_a-zA-Z\/\.\\\$\_\~]
SYMBOLCHARN [_a-zA-Z\/\.\\0-9]
-FILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\]
+FILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~]
FILENAME {FILENAMECHAR}+
WHITE [ \t\n]+
-%x COMMAND
-%x SCRIPT
-%x EXPRESSION
-%x COMMENT
-%x BOTH
-%x DEFSYMEXP
-%x MRI
+NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
+
+
+%s COMMAND
+%s SCRIPT
+%s EXPRESSION
+%s COMMENT
+%s BOTH
+%s DEFSYMEXP
+%s MRI
%%
-
+
+
+<BOTH,SCRIPT,EXPRESSION,COMMAND>"/*" { comment(); }
+
+
<DEFSYMEXP>"-" { RTOKEN('-');}
<DEFSYMEXP>"+" { RTOKEN('+');}
<DEFSYMEXP>{FILENAMECHAR1}{SYMBOLCHARN}* { yylval.name = buystring(yytext); return NAME; }
return OPTION_F;
}
+<COMMAND>"-y"{FILENAME} {
+ yylval.name = buystring(yytext+2);
+ return OPTION_y;
+ }
+
<COMMAND>"-A"{FILENAME} {
yylval.name = buystring(yytext+2);
return OPTION_Aarch;
}
+<COMMAND>"-retain-symbols-file" { return OPTION_RETAIN_SYMBOLS_FILE; }
+
<MRI,EXPRESSION>"$"([0-9A-Fa-f])+ {
- yylval.integer = strtoul(yytext+1, 0,16);
+ yylval.integer = strtoul(yytext+1, 0,16);
return INT;
}
-<MRI,EXPRESSION>([0-9A-Fa-f])+(H|X|B|O|D)
- {
+<MRI,EXPRESSION>([0-9A-Fa-f])+(H|X|B|O|D) {
int base ;
switch (yytext[yyleng-1]) {
case 'X':
<BOTH,SCRIPT>"l" { RTOKEN( LENGTH);}
<BOTH,SCRIPT>"len" { RTOKEN( LENGTH);}
<MRI>"\n" { ++ lineno; RTOKEN(NEWLINE); }
-<MRI>^"*".* { /* Mri comment line */ }
+<MRI>"*".* { /* Mri comment line */ }
<MRI>"END" { RTOKEN(ENDWORD); }
+<MRI>"ALIGNMOD" { RTOKEN(ALIGNMOD);}
+<MRI>"ALIGN" { RTOKEN(ALIGN_K);}
+
<MRI>"CHIP" { RTOKEN(CHIP); }
+<MRI>"BASE" { RTOKEN(BASE); }
+<MRI>"ALIAS" { RTOKEN(ALIAS); }
+<MRI>"TRUNCATE" { RTOKEN(TRUNCATE); }
<MRI>"LOAD" { RTOKEN(LOAD); }
+<MRI>"PUBLIC" { RTOKEN(PUBLIC); }
<MRI>"ORDER" { RTOKEN(ORDER); }
<MRI>"NAME" { RTOKEN(NAMEWORD); }
<MRI>"FORMAT" { RTOKEN(FORMAT); }
<MRI>"LIST".* { RTOKEN(LIST); /* LIST and ignore to end of line */ }
<MRI>"SECT" { RTOKEN(SECT); }
-<MRI>"ABSOLUTE" { RTOKEN(ABSOLUTE); }
+<EXPRESSION,BOTH,SCRIPT,MRI>"ABSOLUTE" { RTOKEN(ABSOLUTE); }
<MRI>"end" { RTOKEN(ENDWORD); }
<MRI>"chip" { RTOKEN(CHIP); }
<MRI>"load" { RTOKEN(LOAD); }
<MRI>"format" { RTOKEN(FORMAT); }
<MRI>"list".* { RTOKEN(LIST); /* LIST and ignore to end of line */ }
<MRI>"sect" { RTOKEN(SECT); }
-<MRI>"absolute" { RTOKEN(ABSOLUTE); }
+<EXPRESSION,BOTH,SCRIPT,MRI>"absolute" { RTOKEN(ABSOLUTE); }
<COMMAND>{CMDFILENAMECHAR1}{CMDFILENAMECHAR}* {
yylval.name = buystring(yytext);
}
-<MRI,BOTH,EXPRESSION>{FILENAMECHAR1}{FILENAMECHAR}* {
+<MRI>{FILENAMECHAR1}{NOCFILENAMECHAR}* {
+/* Filename without commas, needed to parse mri stuff */
+ yylval.name = buystring(yytext);
+ return NAME;
+ }
+
+
+<BOTH,EXPRESSION>{FILENAMECHAR1}{FILENAMECHAR}* {
yylval.name = buystring(yytext);
return NAME;
}
<BOTH,SCRIPT,EXPRESSION>"\n" { lineno++;}
<MRI,COMMAND,BOTH,SCRIPT,EXPRESSION>[ \t]
-"/*" { old = INITIAL; BEGIN(COMMENT); }
-<COMMAND>"/*" { old = COMMAND; BEGIN(COMMENT); }
-<BOTH>"/*" { old =BOTH; BEGIN(COMMENT); }
-<SCRIPT>"/*" { old = EXPRESSION; BEGIN(COMMENT); }
-<EXPRESSION>"/*" { old = SCRIPT; BEGIN(COMMENT); }
-"/*" { old = INITIAL; BEGIN(COMMENT); }
-<COMMENT>[^*\\n]*
-<COMMENT>"*"+[^*/\\n]*
-<COMMENT>\\n { ++lineno;}
-<COMMENT>"*"+"/" { BEGIN(old); }
-
-
<<EOF>> {
include_stack_ptr--;
return END;
}
-
-
-
-
-
-
-
%%
void
}
}
+static
+comment()
+{
+ int c;
+ while (1)
+ {
+ c = input();
+ while (c !='*' && c != EOF)
+ {
+ if (c == '\n') lineno++;
+ c = input();
+ }
+
+
+ if (c == '*')
+ {
+ c = input();
+ while ( c == '*')
+ c = input();
+ if ( c == '/' )
+ break; /* found the end */
+ }
+
+ if ( c == EOF )
+ {
+ einfo( "%F%P :EOF in comment");
+ break;
+ }
+ }
+}