From 6ee196e6800099d52776bb16f84f26525586958f Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Wed, 18 Jan 2017 19:10:20 -0600 Subject: nqasm: lex registers as if they were labels This makes parsing registers trickier, but allows a label to have a name 'r0'-'r7', which would otherwise conflict with the registers. --- lexer.l | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lexer.l') diff --git a/lexer.l b/lexer.l index 7d44adf..5c8ebfb 100644 --- a/lexer.l +++ b/lexer.l @@ -35,7 +35,7 @@ HEX [0-9a-f] %% {SP}+ { BEGIN(inst); return T_SPACE; } -{LABEL} { SETSTR(yytext); return T_LABEL; } +{LABEL} { SETSTR(yytext); return T_LABEL; } :{SP}* { BEGIN(inst); return T_COLON; } add/{EOI} { BEGIN(args); return T_ADD; } @@ -74,12 +74,10 @@ HEX [0-9a-f] 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; } +@ { return T_DEREF; } [-+]?{DEC}+ { return intlit(yytext, 10, &yylval.lval); } 0x{HEX}+ { return intlit(yytext+2, 16, &yylval.lval); } {SP}*,{SP}* { return T_COMMA; } -{LABEL} { SETSTR(yytext); return T_LABEL; } {SP}*{COMMENT}?\n { BEGIN(INITIAL); return T_EOL; } {SP}*{COMMENT} { BEGIN(INITIAL); return T_EOL; } -- cgit v1.2.3