diff options
Diffstat (limited to 'lexer.l')
-rw-r--r-- | lexer.l | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -2,10 +2,12 @@ #include <errno.h> #include <stdlib.h> +#include <string.h> #include "parser.h" #define SETVALUE(v) yylval.arg = (struct argument) { .value = (v) } +#define SETSTR(s) yylval.str = strdup(s) static int intlit(const char *s, int base, long *out) { @@ -22,6 +24,7 @@ static int intlit(const char *s, int base, long *out) %s inst %s args +LABEL [_a-zA-Z][_a-zA-Z0-9]* COMMENT #[^\n]* SP [ \t] EOI [ \t\n#] @@ -32,6 +35,8 @@ HEX [0-9a-f] %% <INITIAL>{SP}+ { BEGIN(inst); return T_SPACE; } +<INITIAL>{LABEL} { SETSTR(yytext); return T_LABEL; } +<INITIAL>:{SP}* { BEGIN(inst); return T_COLON; } <inst>add/{EOI} { BEGIN(args); return T_ADD; } <inst>sub/{EOI} { BEGIN(args); return T_SUB; } |