summaryrefslogtreecommitdiff
path: root/lexer.l
diff options
context:
space:
mode:
Diffstat (limited to 'lexer.l')
-rw-r--r--lexer.l7
1 files changed, 7 insertions, 0 deletions
diff --git a/lexer.l b/lexer.l
index 6b6b121..f3a540c 100644
--- a/lexer.l
+++ b/lexer.l
@@ -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; }