diff options
Diffstat (limited to 'lexer.l')
-rw-r--r-- | lexer.l | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -2,6 +2,8 @@ #include "parser.h" +#define SETVALUE(v) yylval.arg = (struct argument) { .value = (v) } + %} %option outfile="lexer.c" header-file="lexer.h" @@ -13,6 +15,7 @@ COMMENT #[^\n]* SP [ \t] EOI [ \t\n#] +REGNUM [0-7] %% @@ -54,6 +57,10 @@ EOI [ \t\n#] <inst>addpc/{EOI} { BEGIN(args); return T_ADDPC; } <inst>nop/{EOI} { BEGIN(args); return T_NOP; } +<args>r{REGNUM} { SETVALUE(yytext[1]-'0'); return T_REG; } +<args>@r{REGNUM} { SETVALUE(yytext[2]-'0'); return T_REGPTR; } +<args>{SP}*,{SP}* { return T_COMMA; } + {SP}*{COMMENT}?\n { BEGIN(INITIAL); return T_EOL; } {SP}*{COMMENT} { BEGIN(INITIAL); return T_EOL; } {SP}+ { return T_SPACE; } |