From 9244eacb5ab0b9a11480d1ad40d4720575676877 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Tue, 17 Jan 2017 20:14:45 -0600 Subject: nqasm: parse labels --- lexer.l | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lexer.l') diff --git a/lexer.l b/lexer.l index 85021c5..28aa7fe 100644 --- a/lexer.l +++ b/lexer.l @@ -2,10 +2,12 @@ #include #include +#include #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] %% {SP}+ { BEGIN(inst); return T_SPACE; } +{LABEL} { SETSTR(yytext); return T_LABEL; } +:{SP}* { BEGIN(inst); return T_COLON; } add/{EOI} { BEGIN(args); return T_ADD; } sub/{EOI} { BEGIN(args); return T_SUB; } -- cgit v1.2.3