I understand that I am having a shift/reduce conflict on a Tk_left_paren
'(' character with the Declarator production. Is my interpretation of
the first line right?
shift/reduce conflict in state [stack: PDirectDeclarator *] on TTkLeftParen in {
[ PDeclarator = PDirectDeclarator * ] followed by TTkLeftParen (reduce),
[ PDirectDeclarator = PDirectDeclarator * TTkLeftParen PParameterDeclarationClause TTkRightParen PCvQualifierSeq PExceptionSpecification ] (shift),
[ PDirectDeclarator = PDirectDeclarator * TTkLeftParen PParameterDeclarationClause TTkRightParen PCvQualifierSeq ] (shift),
[ PDirectDeclarator = PDirectDeclarator * TTkLeftParen PParameterDeclarationClause TTkRightParen PExceptionSpecification ] (shift),
[ PDirectDeclarator = PDirectDeclarator * TTkLeftParen PParameterDeclarationClause TTkRightParen ] (shift)
}
The rules below are from a C++ grammar. I read the rules from the ANSI
standard I found on the web, ofcourse this does not mean what Iread is
right (see http://www.csci.csusb.edu/dick/c++std/cd2/gram.html ).
declarator =
{dd} direct_declarator |
{ptr} ptr_operator declarator;
declarator_id =
{first} tk_double_colon
id_expression |
{nested} tk_double_colon
nested_name_specifier
type_name;
direct_declarator =
{di} declarator_id |
{dd} direct_declarator
tk_left_paren
parameter_declaration_clause
tk_right_paren
cv_qualifier_seq?
exception_specification? |
{dd_array} direct_declarator
tk_left_bracket
constant_expression?
tk_right_bracket|
{paren} tk_left_paren
declarator
tk_right_paren;
I believe that the published ANSI grammar did not have a shift-reduce
conflict in it. So my guess is I am messing up somewhere. I could alter
the grammar so that the left paren has the same level of precedence but
I feel that is going too far. The whole grammar is attached (tar.gz).
What is a good technique for eliminating shift-reduce conflicts in a
grammar?
Stephen
Attachment:
cplusplus.tar.gz
Description: application/compressed-tar