From 50e67fb3e640a9e6e1260ca984582c9a9b8d5375 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Sat, 14 Jan 2017 14:44:18 -0600 Subject: nqasm: Handle register and register indirect arguments --- lexer.l | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lexer.l') 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#] addpc/{EOI} { BEGIN(args); return T_ADDPC; } nop/{EOI} { BEGIN(args); return T_NOP; } +r{REGNUM} { SETVALUE(yytext[1]-'0'); return T_REG; } +@r{REGNUM} { SETVALUE(yytext[2]-'0'); return T_REGPTR; } +{SP}*,{SP}* { return T_COMMA; } + {SP}*{COMMENT}?\n { BEGIN(INITIAL); return T_EOL; } {SP}*{COMMENT} { BEGIN(INITIAL); return T_EOL; } {SP}+ { return T_SPACE; } -- cgit v1.2.3