diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-01-28 23:32:25 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-01-28 23:32:25 (GMT) |
commit | 16e0fd9d89ef433848678dfc8dd20426844a2868 (patch) | |
tree | 79075ae02c133cea21ffb555b1086aae833b3aac /tools/d2c/bits/tokens.l | |
parent | 66c99d59d6a6d533de0bb65488de8243213bcdea (diff) |
Cleaned, rewritten and improved the whole code of the compiler.
Diffstat (limited to 'tools/d2c/bits/tokens.l')
-rw-r--r-- | tools/d2c/bits/tokens.l | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/d2c/bits/tokens.l b/tools/d2c/bits/tokens.l new file mode 100644 index 0000000..99fb96d --- /dev/null +++ b/tools/d2c/bits/tokens.l @@ -0,0 +1,33 @@ + +%top { + +#include "grammar.h" + +} + + +%option noyywrap +%option nounput +%option noinput +%option yylineno +%option stack +%option noyy_top_state + +%x bsize + + +%% + + +" " { } + +[A-Za-z_][A-Za-z0-9_]* { yylvalp->string = strdup(yytext); return NAME; } + +"(" { yy_push_state(bsize); } +<bsize>[0-9]+ { yylvalp->integer = atoi(yytext); return SIZE; } +<bsize>")" { yy_pop_state(); } + +[01] { yylvalp->integer = atoi(yytext); return BIT; } + + +%% |