1 %option reentrant noyywrap batch
2 %option bison-bridge bison-locations yylineno
9 #include <ozulis/ast/ast.hh>
10 #include <ozulis/ast/node-factory.hh>
13 #define YY_USER_ACTION \
14 yylloc->first_line = yylineno; \
15 yylloc->last_line = yylineno; \
16 yylloc->first_column = yylloc->last_column; \
17 yylloc->last_column += yyleng;
19 #define MAKE_BOOL(Value) \
21 yylval->nbExp = new ozulis::ast::NumberExp(); \
22 yylval->nbExp->type = ozulis::ast::NodeFactory::createBoolType(); \
23 yylval->nbExp->number = Value; \
27 static ozulis::ast::NumberExp *
28 makeInteger(double value, int size, bool isSigned);
30 static ozulis::ast::NumberExp *
31 makeFloat(double value);
37 \n /* ignore end of line */yylloc->last_column = 0;
38 [ \t]+ /* ignore whitespace */;
39 \/\/.*$ /* line comment */
40 #.*$ /* line comment */
85 \"[^\"]*\" return STRING;
99 [a-zA-Z][a-zA-Z0-9_]* yylval->string = strdup(yytext); return ID;
102 yylval->nbExp = makeFloat(strtod(yytext, 0));
107 yylval->nbExp = makeInteger(strtod(yytext, 0), 32, true);
112 yylval->nbExp = makeInteger(strtod(yytext, 0), 32, false);
117 yylval->nbExp = makeInteger(strtod(yytext, 0), 64, true);
122 yylval->nbExp = makeInteger(strtod(yytext, 0), 64, false);
128 static ozulis::ast::NumberExp *
129 makeInteger(double value, int size, bool isSigned)
131 ozulis::ast::NumberExp * nbExp = new ozulis::ast::NumberExp();
132 ozulis::ast::IntegerType * nbType = new ozulis::ast::IntegerType();
134 nbType->isSigned = isSigned;
135 nbExp->type = nbType;
136 nbExp->number = value;
140 static ozulis::ast::NumberExp *
141 makeFloat(double value)
143 ozulis::ast::NumberExp * nbExp = new ozulis::ast::NumberExp();
144 ozulis::ast::FloatType * nbType = new ozulis::ast::FloatType();
145 nbExp->type = nbType;
146 nbExp->number = value;