lex.l 781 Bytes
Newer Older
Jayke Meijer's avatar
Jayke Meijer committed
1 2 3 4
%{
#include <stdio.h>
#include "y.tab.h"
%}
Jayke Meijer's avatar
Jayke Meijer committed
5
arg \$[a-zA-Z0-9\.]+
Jayke Meijer's avatar
Jayke Meijer committed
6 7 8

%%

Jayke Meijer's avatar
Jayke Meijer committed
9 10 11 12
#[^\n]*             { yylval.sval = yytext; return COMMENT; }    /* Comment */
[a-zA-Z0-9$\.]+:   { yylval.sval = yytext; return LABEL; }      /* Label */
{arg}               { yylval.sval = yytext; return ARG; }        /* Arg of instr */
[0-9]+(\({arg}\))?  { yylval.sval = yytext; return ARG; }        /* Arg of instr */
Jayke Meijer's avatar
Jayke Meijer committed
13
\.[^\n]*            { yylval.sval = yytext; return DIRECTIVE; }  /* Assembly */
Jayke Meijer's avatar
Jayke Meijer committed
14
[a-z\.]+            { yylval.sval = yytext; return INSTR; }      /* Instruction */
Jayke Meijer's avatar
Jayke Meijer committed
15 16
[,]                 { return COMMA; }                       /* Comma */
[\n]                { return NL; }                          /* New line */
Jayke Meijer's avatar
Jayke Meijer committed
17
	
Jayke Meijer's avatar
Jayke Meijer committed
18
[ \t]+             { ; }                            /* Ignore whitespace */