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.
Hi Rob, first of all sorry for the delay in getting back to this. I kept looking for alternative approaches, but now ended up figuring that really laying down the issue at hand I was trying to solve in front of everyone a priori will be the better approach.
Let me first respond to concrete feedback you provided, and than show why I started down this road.
On Thu, 2 Jul 2009, Rob Shearman wrote:
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.
Yes, alas the current widl parser is somewhat special: it uses quite general rules (too general rules, one could argue), only to perform tighter checks later on, in the C component of the productions.
This basically combines the styles of bison parser with a recursive descending parser (manually written), and I tried to clear this a bit.
Using "expr_int_const" instead of "expr" here prevents a many forms of expressions from being parsed.
It did suffice to build all of Wine without problems, but if we expect out of tree users, that could be a problem indeed.
It looks like you'll have to find another way of fixing the issue you are trying to fix.
Okay, so here is the issue. Wine kind of abuses enums a bit, injecting additional values by means of #defines (that are not part of the enum proper) which will make GCC 4.5, without extra options!, issue the following litany of warnings:
utils.c:269:9: warning: case value '827606349' not in enumerated type 'WINED3DFORMAT' utils.c:264:9: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT' utils.c:258:9: warning: case value '842094169' not in enumerated type 'WINED3DFORMAT' utils.c:265:9: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT' utils.c:252:9: warning: case value '844715353' not in enumerated type 'WINED3DFORMAT' utils.c:266:9: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT' utils.c:267:9: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT' utils.c:268:9: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT' utils.c:270:9: warning: case value '1111970375' not in enumerated type 'WINED3DFORMAT' utils.c:271:9: warning: case value '1195525970' not in enumerated type 'WINED3DFORMAT' utils.c:251:9: warning: case value '1498831189' not in enumerated type 'WINED3DFORMAT' directx.c:2863:9: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT' directx.c:2864:9: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT' directx.c:2865:9: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT' directx.c:2866:9: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT' directx.c:2867:9: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT' directx.c:3116:9: warning: case value '827606349' not in enumerated type 'WINED3DFORMAT' directx.c:3017:9: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT' directx.c:3060:9: warning: case value '842094169' not in enumerated type 'WINED3DFORMAT' directx.c:3121:9: warning: case value '843666497' not in enumerated type 'WINED3DFORMAT' directx.c:3018:9: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT' directx.c:3052:9: warning: case value '844715353' not in enumerated type 'WINED3DFORMAT' directx.c:3019:9: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT' directx.c:3020:9: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT' directx.c:3021:9: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT' directx.c:3115:9: warning: case value '1111970375' not in enumerated type 'WINED3DFORMAT' directx.c:3114:9: warning: case value '1195525970' not in enumerated type 'WINED3DFORMAT' directx.c:3141:9: warning: case value '1397249614' not in enumerated type 'WINED3DFORMAT' directx.c:3103:9: warning: case value '1414745673' not in enumerated type 'WINED3DFORMAT' directx.c:3140:9: warning: case value '1430804046' not in enumerated type 'WINED3DFORMAT' directx.c:3051:9: warning: case value '1498831189' not in enumerated type 'WINED3DFORMAT' directx.c:3709:13: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT' directx.c:3710:13: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT' directx.c:3711:13: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT' directx.c:3712:13: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT' directx.c:3713:13: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT' utils.c:1227:5: warning: case value '827606349' not in enumerated type 'WINED3DFORMAT' utils.c:1222:5: warning: case value '827611204' not in enumerated type 'WINED3DFORMAT' utils.c:1221:5: warning: case value '842094169' not in enumerated type 'WINED3DFORMAT' utils.c:1239:5: warning: case value '843666497' not in enumerated type 'WINED3DFORMAT' utils.c:1223:5: warning: case value '844388420' not in enumerated type 'WINED3DFORMAT' utils.c:1220:5: warning: case value '844715353' not in enumerated type 'WINED3DFORMAT' utils.c:1224:5: warning: case value '861165636' not in enumerated type 'WINED3DFORMAT' utils.c:1225:5: warning: case value '877942852' not in enumerated type 'WINED3DFORMAT' utils.c:1226:5: warning: case value '894720068' not in enumerated type 'WINED3DFORMAT' utils.c:1228:5: warning: case value '1111970375' not in enumerated type 'WINED3DFORMAT' utils.c:1229:5: warning: case value '1195525970' not in enumerated type 'WINED3DFORMAT' utils.c:1241:5: warning: case value '1397249614' not in enumerated type 'WINED3DFORMAT' utils.c:1240:5: warning: case value '1430804046' not in enumerated type 'WINED3DFORMAT' utils.c:1219:5: warning: case value '1498831189' not in enumerated type 'WINED3DFORMAT' utils.c:1777:5: warning: case value '256' not in enumerated type 'WINED3DTRANSFORMSTATETYPE'
My original idea was to extend the syntax used by widl slightly to allow for injecting those values more directly into the enum itself, and that required changes to the parser which were hard without the changes I ended up submitting.
How shall we best tackle this?
Gerald
2009/12/21 Gerald Pfeifer gerald@pfeifer.com:
How shall we best tackle this?
At least for the wined3d ones, we might as well just add them to the enum, the macros aren't strictly necessary.