source:
XIOS/trunk/src/parse_expr/lex_parser.lex
@
1545
Last change on this file since 1545 was 1158, checked in by oabramkina, 7 years ago | |
---|---|
|
|
File size: 1.3 KB |
Rev | Line | |
---|---|---|
[458] | 1 | %option noyywrap |
2 | %{ | |
3 | ||
4 | extern "C" | |
5 | { | |
6 | int yylex(void); | |
7 | } | |
8 | #undef YY_INPUT | |
[642] | 9 | #define YY_INPUT(b, r, s) readInputForLexer(b, &r, s) |
[458] | 10 | #include <string> |
11 | ||
[642] | 12 | int readInputForLexer(char* buffer, size_t* numBytesRead, size_t maxBytesToRead); |
[458] | 13 | |
[642] | 14 | #include "filter_expr_node.hpp" |
[458] | 15 | #include "yacc_parser.hpp" |
16 | ||
17 | %} | |
18 | ||
[642] | 19 | white [ \t]+ |
[458] | 20 | |
[642] | 21 | digit [0-9] |
[458] | 22 | integer {digit}+ |
23 | exponant [eE][+-]?{integer} | |
[642] | 24 | real {integer}("."{integer})?{exponant}? |
25 | id [a-zA-Z][a-zA-Z0-9_]* | |
26 | average @{id} | |
27 | var \${id} | |
28 | ||
[458] | 29 | %% |
30 | ||
[642] | 31 | {white} { /* We ignore white characters */ } |
[458] | 32 | |
[642] | 33 | {real} { |
34 | yylval.str = new std::string(yytext); | |
35 | return NUMBER; | |
36 | } | |
[458] | 37 | |
[642] | 38 | {average} { |
39 | yylval.str = new std::string(yytext + 1); | |
40 | return AVERAGE; | |
41 | } | |
[458] | 42 | |
[642] | 43 | {var} { |
44 | yylval.str = new std::string(yytext + 1); | |
45 | return VAR; | |
46 | } | |
[458] | 47 | |
[642] | 48 | {id} { |
49 | yylval.str = new std::string(yytext); | |
50 | return ID; | |
51 | } | |
[458] | 52 | |
53 | ||
[642] | 54 | "+" return PLUS; |
55 | "-" return MINUS; | |
[458] | 56 | |
[642] | 57 | "*" return TIMES; |
58 | "/" return DIVIDE; | |
[458] | 59 | |
[642] | 60 | "^" return POWER; |
[458] | 61 | |
[728] | 62 | "==" return EQ; |
63 | "<" return LT; | |
64 | ">" return GT; | |
65 | "<=" return LE; | |
66 | ">=" return GE; | |
[1158] | 67 | "/=" return NE; |
68 | "?" return QUESTION_MARK; | |
69 | ":" return COLON; | |
[642] | 70 | "(" return LEFT_PARENTHESIS; |
71 | ")" return RIGHT_PARENTHESIS; | |
[458] | 72 | |
[642] | 73 | "\0" return END; |
Note: See TracBrowser
for help on using the repository browser.