1
%{
2
#include <stdlib.h>
3
4
#include "parser.h"
5
#include "lang.tab.h"
6
%}
7
8
%%
9
10
\"[^"\n]+\"? { yylval.expr = ast_string_alloc(yytext + 1); return IMM; }
11
[0-9]+ { yylval.expr = ast_integer_alloc(atoi(yytext)); return IMM; }
12
REM[^\n]+ { yylval.comment = ast_comment_alloc(yytext + 3, 1); return COMMENT; }
13
'[^\n]+ { yylval.comment = ast_comment_alloc(yytext + 1, 0); return COMMENT; }
14
[a-zA-Z]+ { yylval.token = ast_token_alloc(yytext); return TOKEN; }
15
[\t ]+ { }
16
. { return yytext[0]; }
17
\n { return NL; }
18
19
%%
20
21
void begin_scan(char const *s) {
22
yy_switch_to_buffer(yy_scan_string(s));
23
}
24
25
void finish_scan() {
26
yy_delete_buffer(YY_CURRENT_BUFFER);
27
}
28
29
/* vim: set sw=4 et: */
30