E
eliben
The "old standard" ANSI/ISO C (C89) had a known shift-reduce conflict
in its YACC grammar, because of the uncertainty of where to hang an
else in nested if statements. This conflict was resolved to "shift" by
YACC, which is fine for C's semantics.
It appears that C99 introduced two new shift/reduce conflicts with
these new derivations for postfix-expression:
( type-name ) { initializer-list }
( type-name ) { initializer-list , }
This is called compound literals and allows things like:
struct POINT p;
p = (struct POINT) {x, y};
int *ap;
ap = (int []) {1, 2, 3};
Can someone confirm that this indeed creates 2 new shift/reduce
conflicts in the grammar? Or am I defining it incorrectly?
This is the conflict report I'm getting from PLY (A particular
implementation of YACC, in Python):
(206) unary_expression -> SIZEOF LPAREN type_name RPAREN .
(221) postfix_expression -> LPAREN type_name RPAREN . LBRACE
initializer_list LBRACE
(222) postfix_expression -> LPAREN type_name RPAREN . LBRACE
initializer_list COMMA LBRACE
! shift/reduce conflict for LBRACE resolved as shift
Thanks in advance
in its YACC grammar, because of the uncertainty of where to hang an
else in nested if statements. This conflict was resolved to "shift" by
YACC, which is fine for C's semantics.
It appears that C99 introduced two new shift/reduce conflicts with
these new derivations for postfix-expression:
( type-name ) { initializer-list }
( type-name ) { initializer-list , }
This is called compound literals and allows things like:
struct POINT p;
p = (struct POINT) {x, y};
int *ap;
ap = (int []) {1, 2, 3};
Can someone confirm that this indeed creates 2 new shift/reduce
conflicts in the grammar? Or am I defining it incorrectly?
This is the conflict report I'm getting from PLY (A particular
implementation of YACC, in Python):
(206) unary_expression -> SIZEOF LPAREN type_name RPAREN .
(221) postfix_expression -> LPAREN type_name RPAREN . LBRACE
initializer_list LBRACE
(222) postfix_expression -> LPAREN type_name RPAREN . LBRACE
initializer_list COMMA LBRACE
! shift/reduce conflict for LBRACE resolved as shift
Thanks in advance