diff options
Diffstat (limited to 'lex.l')
-rw-r--r-- | lex.l | 53 |
1 files changed, 0 insertions, 53 deletions
@@ -1,53 +0,0 @@ -%{ -#include "ast.h" -#include "grammar.tab.h" -%} - -%% -"+" { return OPERATOR_PLUS; } -"-" { return OPERATOR_MINUS; } -"=" { return ASSIGN; } - -"function" { return FUNCTION; } -"if" { return IF; } -"else" { return ELSE; } -"return" { return RETURN; } -"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; } -"}" { return BRACE_RIGHT; } -"[" { return BRACKET_LEFT; } -"]" { return BRACKET_RIGHT; } - -"," { return COMMA; } -":" { return COLON; } - -[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; } -[ \t] {} - -. { printf("undefined: %c\n", *yytext); } -%% - -void henshin_lex(int argc, char **argv) -{ - int tok; - - while (tok = yylex()) { - printf("%d", tok); - if (tok == NUMBER) { - printf(" = %d", yylval); - } - printf("\n"); - } -} |