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