2009/6/28 Gerald Pfeifer gerald@pfeifer.com:
diff --git a/tools/widl/parser.y b/tools/widl/parser.y index c2f1abc..01aa060 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -622,56 +633,54 @@ m_expr: { $$ = make_expr(EXPR_VOID); } | expr ;
-expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
- | aHEXNUM { $$ = make_exprl(EXPR_HEXNUM, $1); }
+expr: expr_int_const | aDOUBLE { $$ = make_exprd(EXPR_DOUBLE, $1); }
- | '-' aDOUBLE { $$ = make_exprd(EXPR_DOUBLE, -($2)); }
This is covered by the production for the binary minus operator that already exists, so I'm not sure what you're trying to achieve here.
| tFALSE { $$ = make_exprl(EXPR_TRUEFALSE, 0); }
- | tNULL { $$ = make_exprl(EXPR_NUM, 0); }
| tTRUE { $$ = make_exprl(EXPR_TRUEFALSE, 1); } | aSTRING { $$ = make_exprs(EXPR_STRLIT, $1); } | aWSTRING { $$ = make_exprs(EXPR_WSTRLIT, $1); }
- | aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); }
| expr '?' expr ':' expr { $$ = make_expr3(EXPR_COND, $1, $3, $5); } | expr LOGICALOR expr { $$ = make_expr2(EXPR_LOGOR, $1, $3); } | expr LOGICALAND expr { $$ = make_expr2(EXPR_LOGAND, $1, $3); }
- | expr '|' expr { $$ = make_expr2(EXPR_OR , $1, $3); }
- | expr '^' expr { $$ = make_expr2(EXPR_XOR, $1, $3); }
- | expr '&' expr { $$ = make_expr2(EXPR_AND, $1, $3); }
| expr EQUALITY expr { $$ = make_expr2(EXPR_EQUALITY, $1, $3); } | expr INEQUALITY expr { $$ = make_expr2(EXPR_INEQUALITY, $1, $3); } | expr '>' expr { $$ = make_expr2(EXPR_GTR, $1, $3); } | expr '<' expr { $$ = make_expr2(EXPR_LESS, $1, $3); } | expr GREATEREQUAL expr { $$ = make_expr2(EXPR_GTREQL, $1, $3); } | expr LESSEQUAL expr { $$ = make_expr2(EXPR_LESSEQL, $1, $3); }
- | expr SHL expr { $$ = make_expr2(EXPR_SHL, $1, $3); }
- | expr SHR expr { $$ = make_expr2(EXPR_SHR, $1, $3); }
- | expr '+' expr { $$ = make_expr2(EXPR_ADD, $1, $3); }
- | expr '-' expr { $$ = make_expr2(EXPR_SUB, $1, $3); }
- | expr '%' expr { $$ = make_expr2(EXPR_MOD, $1, $3); }
- | expr '*' expr { $$ = make_expr2(EXPR_MUL, $1, $3); }
- | expr '/' expr { $$ = make_expr2(EXPR_DIV, $1, $3); }
| '!' expr { $$ = make_expr1(EXPR_LOGNOT, $2); }
- | '~' expr { $$ = make_expr1(EXPR_NOT, $2); }
- | '+' expr %prec POS { $$ = make_expr1(EXPR_POS, $2); }
- | '-' expr %prec NEG { $$ = make_expr1(EXPR_NEG, $2); }
| '&' expr %prec ADDRESSOF { $$ = make_expr1(EXPR_ADDRESSOF, $2); } | '*' expr %prec PPTR { $$ = make_expr1(EXPR_PPTR, $2); } | expr MEMBERPTR aIDENTIFIER { $$ = make_expr2(EXPR_MEMBER, make_expr1(EXPR_PPTR, $1), make_exprs(EXPR_IDENTIFIER, $3)); } | expr '.' aIDENTIFIER { $$ = make_expr2(EXPR_MEMBER, $1, make_exprs(EXPR_IDENTIFIER, $3)); } | '(' type ')' expr %prec CAST { $$ = make_exprt(EXPR_CAST, $2, $4); }
- | tSIZEOF '(' type ')' { $$ = make_exprt(EXPR_SIZEOF, $3, NULL); }
| expr '[' expr ']' { $$ = make_expr2(EXPR_ARRAY, $1, $3); }
- | '(' expr ')' { $$ = $2; }
;
expr_list_int_const: expr_int_const { $$ = append_expr( NULL, $1 ); } | expr_list_int_const ',' expr_int_const { $$ = append_expr( $1, $3 ); } ;
-expr_int_const: expr { $$ = $1;
- if (!$$->is_const)
- error_loc("expression is not an integer constant\n");
- }
+expr_int_const: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
- | aHEXNUM { $$ = make_exprl(EXPR_HEXNUM, $1); }
- | tNULL { $$ = make_exprl(EXPR_NUM, 0); }
- | aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); }
aIDENTIFIER isn't necessarily a constant expression.
- | '~' expr_int_const { $$ = make_expr1(EXPR_NOT, $2); }
- | '+' expr_int_const %prec POS { $$ = make_expr1(EXPR_POS, $2); }
- | '-' expr_int_const %prec NEG { $$ = make_expr1(EXPR_NEG, $2); }
- | expr_int_const SHL expr_int_const { $$ = make_expr2(EXPR_SHL, $1, $3); }
- | expr_int_const SHR expr_int_const { $$ = make_expr2(EXPR_SHR, $1, $3); }
- | expr_int_const '+' expr_int_const { $$ = make_expr2(EXPR_ADD, $1, $3); }
- | expr_int_const '-' expr_int_const { $$ = make_expr2(EXPR_SUB, $1, $3); }
- | expr_int_const '%' expr_int_const { $$ = make_expr2(EXPR_MOD, $1, $3); }
- | expr_int_const '*' expr_int_const { $$ = make_expr2(EXPR_MUL, $1, $3); }
- | expr_int_const '/' expr_int_const { $$ = make_expr2(EXPR_DIV, $1, $3); }
- | expr_int_const '|' expr_int_const { $$ = make_expr2(EXPR_OR , $1, $3); }
- | expr_int_const '^' expr_int_const { $$ = make_expr2(EXPR_XOR, $1, $3); }
- | expr_int_const '&' expr_int_const { $$ = make_expr2(EXPR_AND, $1, $3); }
Using "expr_int_const" instead of "expr" here prevents a many forms of expressions from being parsed.
- | tSIZEOF '(' type ')' { $$ = make_exprt(EXPR_SIZEOF, $3, NULL); }
- | '(' expr ')' { $$ = $2; }
;
expr_const: expr { $$ = $1;
It looks like you'll have to find another way of fixing the issue you are trying to fix.