summaryrefslogtreecommitdiff
path: root/lexer.l
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2017-01-14 14:44:18 -0600
committerBobby Bingham <koorogi@koorogi.info>2017-01-15 23:19:04 -0600
commit50e67fb3e640a9e6e1260ca984582c9a9b8d5375 (patch)
treed4d12ed5a5787e30e1062ced1edc6c7979afe77e /lexer.l
parenta743db94541bebafff23c8a490dbce3f55d69712 (diff)
nqasm: Handle register and register indirect arguments
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; }