parsing major operators.
Do not evaluate the expression, but rather only check
for syntatic errors and resolve for precedence.
* only enum_values are parsed.
* annotation parameter values, and array sizes are NOT parsed.
* Unary, binary, and ternary operators supported.
* Assignment operators are NOT considered.
* Cast is NOT supported.
* Pointers are NOT supported.
* Emitted expression doesn't work for Java.
See Ic1f524c604fc72b9d1b7b330b608ff38ce287921 for tests.
Along side with some code for handling float literals
for future use.
Change-Id: I67ff0767a67c66b62e5ddfe75954f94d45ac7793
diff --git a/hidl-gen_l.ll b/hidl-gen_l.ll
index d2066a9..2c69f96 100644
--- a/hidl-gen_l.ll
+++ b/hidl-gen_l.ll
@@ -16,6 +16,7 @@
#include "Annotation.h"
#include "AST.h"
#include "CompoundType.h"
+#include "ConstantExpression.h"
#include "EnumType.h"
#include "HandleType.h"
#include "Method.h"
@@ -94,6 +95,24 @@
"." { count(yyg); return('.'); }
"=" { count(yyg); return('='); }
"+" { count(yyg); return('+'); }
+"-" { count(yyg); return('-'); }
+"*" { count(yyg); return('*'); }
+"/" { count(yyg); return('/'); }
+"%" { count(yyg); return('%'); }
+"&" { count(yyg); return('&'); }
+"|" { count(yyg); return('|'); }
+"^" { count(yyg); return('^'); }
+"<<" { count(yyg); return(LSHIFT); }
+">>" { count(yyg); return(RSHIFT); }
+"&&" { count(yyg); return(LOGICAL_AND); }
+"||" { count(yyg); return(LOGICAL_OR); }
+"!" { count(yyg); return('!'); }
+"~" { count(yyg); return('~'); }
+"<=" { count(yyg); return(LEQ); }
+">=" { count(yyg); return(GEQ); }
+"==" { count(yyg); return(EQUALITY); }
+"!=" { count(yyg); return(NEQ); }
+"?" { count(yyg); return('?'); }
"@" { count(yyg); return('@'); }
{PATH}{VERSION}?"::"{PATH} { count(yyg); yylval->str = strdup(yytext); return FQNAME; }
@@ -105,6 +124,11 @@
0[xX]{H}+{IS}? { count(yyg); yylval->str = strdup(yytext); return(INTEGER); }
0{D}+{IS}? { count(yyg); yylval->str = strdup(yytext); return(INTEGER); }
{D}+{IS}? { count(yyg); yylval->str = strdup(yytext); return(INTEGER); }
+
+{D}+{E}{FS}? { count(yyg); yylval->str = strdup(yytext); return(FLOAT); }
+{D}+\.{E}?{FS}? { count(yyg); yylval->str = strdup(yytext); return(FLOAT); }
+{D}*\.{D}+{E}?{FS}? { count(yyg); yylval->str = strdup(yytext); return(FLOAT); }
+
L?\"(\\.|[^\\"])*\" { count(yyg); yylval->str = strdup(yytext); return(STRING_LITERAL); }
[ \t\v\n\f] { count(yyg); }