widl: Add support for "->" and "." operators in expressions.

This commit is contained in:
Rob Shearman 2008-04-20 22:15:43 +01:00 committed by Alexandre Julliard
parent efd10742ec
commit 03d5017416
5 changed files with 18 additions and 1 deletions

View File

@ -526,6 +526,8 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
case EXPR_SUB:
case EXPR_AND:
case EXPR_OR:
case EXPR_MEMBERPTR:
case EXPR_MEMBER:
if (brackets) fprintf(h, "(");
write_expr(h, e->ref, 1);
switch (e->type) {
@ -537,6 +539,8 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
case EXPR_SUB: fprintf(h, " - "); break;
case EXPR_AND: fprintf(h, " & "); break;
case EXPR_OR: fprintf(h, " | "); break;
case EXPR_MEMBERPTR: fprintf(h, "->"); break;
case EXPR_MEMBER: fprintf(h, "."); break;
default: break;
}
write_expr(h, e->u.ext, 1);

View File

@ -162,6 +162,7 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
<INITIAL,ATTR>{ws}
<INITIAL,ATTR>\<\< return SHL;
<INITIAL,ATTR>\>\> return SHR;
<INITIAL,ATTR>\-\> return MEMBERPTR;
<INITIAL,ATTR>. return yytext[0];
<<EOF>> {
if (import_stack_ptr)

View File

@ -180,6 +180,7 @@ static void add_explicit_handle_if_necessary(func_t *func);
%token <uuid> aUUID
%token aEOF
%token SHL SHR
%token MEMBERPTR
%token tAGGREGATABLE tALLOCATE tAPPOBJECT tASYNC tASYNCUUID
%token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT
%token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS
@ -294,6 +295,7 @@ static void add_explicit_handle_if_necessary(func_t *func);
%left '-' '+'
%left '*' '/'
%left SHL SHR
%left '.' MEMBERPTR
%right '~'
%right CAST
%right PPTR
@ -636,8 +638,10 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
| expr SHR expr { $$ = make_expr2(EXPR_SHR, $1, $3); }
| '~' expr { $$ = make_expr1(EXPR_NOT, $2); }
| '-' expr %prec NEG { $$ = make_expr1(EXPR_NEG, $2); }
| '&' expr %prec ADDRESSOF { $$ = make_expr1(EXPR_ADDRESSOF, $2); }
| '&' expr %prec ADDRESSOF { $$ = make_expr1(EXPR_ADDRESSOF, $2); }
| '*' expr %prec PPTR { $$ = make_expr1(EXPR_PPTR, $2); }
| expr MEMBERPTR expr { $$ = make_expr2(EXPR_MEMBERPTR, $1, $3); }
| expr '.' expr { $$ = make_expr2(EXPR_MEMBER, $1, $3); }
| '(' type ')' expr %prec CAST { $$ = make_exprt(EXPR_CAST, $2, $4); }
| tSIZEOF '(' type ')' { $$ = make_exprt(EXPR_SIZEOF, $3, NULL); }
| '(' expr ')' { $$ = $2; }

View File

@ -356,6 +356,8 @@ static int compare_expr(const expr_t *a, const expr_t *b)
case EXPR_DIV:
case EXPR_SHL:
case EXPR_SHR:
case EXPR_MEMBERPTR:
case EXPR_MEMBER:
ret = compare_expr(a->ref, b->ref);
if (ret != 0)
return ret;
@ -3151,6 +3153,8 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
case EXPR_SUB:
case EXPR_AND:
case EXPR_OR:
case EXPR_MEMBERPTR:
case EXPR_MEMBER:
if (brackets) fprintf(h, "(");
write_struct_expr(h, e->ref, 1, fields, structvar);
switch (e->type) {
@ -3162,6 +3166,8 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
case EXPR_SUB: fprintf(h, " - "); break;
case EXPR_AND: fprintf(h, " & "); break;
case EXPR_OR: fprintf(h, " | "); break;
case EXPR_MEMBERPTR: fprintf(h, "->"); break;
case EXPR_MEMBER: fprintf(h, "."); break;
default: break;
}
write_struct_expr(h, e->u.ext, 1, fields, structvar);

View File

@ -161,6 +161,8 @@ enum expr_type
EXPR_COND,
EXPR_TRUEFALSE,
EXPR_ADDRESSOF,
EXPR_MEMBERPTR,
EXPR_MEMBER,
};
enum type_kind