1 %option reentrant noyywrap batch
2 %option bison-bridge bison-locations yylineno
4 %option prefix="mugiwara_"
10 #include <ozulis/core/assert.hh>
11 #include <ozulis/ast/ast.hh>
12 #include <ozulis/ast/node-factory.hh>
15 #define YY_USER_ACTION \
16 yylloc->first_line = yylineno; \
17 yylloc->last_line = yylineno; \
18 yylloc->first_column = yylloc->last_column; \
19 yylloc->last_column += yyleng;
21 #define MAKE_BOOL(Value) \
23 yylval->nbExp = new ozulis::ast::NumberExp(); \
24 yylval->nbExp->type = ozulis::ast::NodeFactory::createBoolType(); \
25 yylval->nbExp->number = Value; \
29 static ozulis::ast::NumberExp *
30 makeInteger(double value, int size, bool isSigned);
32 static ozulis::ast::NumberExp *
33 makeFloat(double value);
39 \n /* ignore end of line */yylloc->last_column = 0;
40 [ \t]+ /* ignore whitespace */;
41 \/\/.*$ /* line comment */
42 #.*$ /* line comment */
87 \"[^\"]*\" yylval->string = strdup(yytext); return STRING;
101 [a-zA-Z][a-zA-Z0-9_]* yylval->string = strdup(yytext); return ID;
104 yylval->nbExp = makeFloat(strtod(yytext, 0));
109 yylval->nbExp = makeInteger(strtod(yytext, 0), 32, true);
114 yylval->nbExp = makeInteger(strtod(yytext, 0), 32, false);
119 yylval->nbExp = makeInteger(strtod(yytext, 0), 64, true);
124 yylval->nbExp = makeInteger(strtod(yytext, 0), 64, false);
132 static ozulis::ast::NumberExp *
133 makeInteger(double value, int size, bool isSigned)
135 ozulis::ast::NumberExp * nbExp = new ozulis::ast::NumberExp();
136 ozulis::ast::IntegerType * nbType = new ozulis::ast::IntegerType();
138 nbType->isSigned = isSigned;
139 nbExp->type = nbType;
140 nbExp->number = value;
144 static ozulis::ast::NumberExp *
145 makeFloat(double value)
147 ozulis::ast::NumberExp * nbExp = new ozulis::ast::NumberExp();
148 ozulis::ast::FloatType * nbType = new ozulis::ast::FloatType();
149 nbExp->type = nbType;
150 nbExp->number = value;