diff options
author | Daniel Weipert <code@drogueronin.de> | 2022-12-06 13:34:33 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2022-12-06 13:34:33 +0100 |
commit | f17b517e56503600355de910ce576efab56b1287 (patch) | |
tree | 48b3a03d0383bc1347d7a85b4f6bdc55f4b55e6b /lex.l | |
parent | 5b840fd4c56d835b067e4cf9a3e4af4442717d20 (diff) |
Tried to create an AST
Diffstat (limited to 'lex.l')
-rw-r--r-- | lex.l | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1,4 +1,5 @@ %{ +#include "ast.h" #include "grammar.tab.h" %} @@ -14,6 +15,10 @@ "const" { return CONST; } "var" { return VAR; } +"integer" { return TYPE_INTEGER; } +"string" { return TYPE_STRING; } +"void" { return TYPE_VOID; } + "(" { return PARENTHESIS_LEFT; } ")" { return PARENTHESIS_RIGHT; } "{" { return BRACE_LEFT; } @@ -22,9 +27,10 @@ "]" { return BRACKET_RIGHT; } "," { return COMMA; } +":" { return COLON; } -[0-9]+ { yylval = atoi(yytext); return NUMBER; } -[a-zA-Z]+[a-zA-Z0-9]* { return IDENTIFIER; } +[a-zA-Z][a-zA-Z0-9]* { yylval.string = yytext; return IDENTIFIER; } +[0-9]+ { yylval.number = atoi(yytext); return NUMBER; } "//".* { return COMMENT; } \n { return END_OF_LINE; } |