help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Resolving shift/reduce conflicts?


From: Christoph Grüninger
Subject: Resolving shift/reduce conflicts?
Date: Tue, 2 Feb 2021 07:50:39 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1

Dear Bisons,

I have another issue within the CMake parser code. When using the
attached cmDependsJavaParser.y with Bison 3.7.5, i get the following
warning: 4 shift/reduce conflicts [-Wconflicts-sr]. When adding
-Wcounterexamples I get the output below. Ok, I understand the issue and
Bison is right.
But what should I do to get rid of the problem?

Bye
Christoph


> bison --name-prefix=cmDependsJava_yy
--defines=cmDependsJavaParserTokens.h -Wcounterexamples
-ocmDependsJavaParser.cxx cmDependsJavaParser.y
cmDependsJavaParser.y: warning: 4 shift/reduce conflicts [-Wconflicts-sr]
cmDependsJavaParser.y: warning: shift/reduce conflict on token
jp_SEMICOL [-Wcounterexamples]
  Example: ClassBodyDeclarations MethodHeader MethodBody . jp_SEMICOL
  Shift derivation
    ClassBodyDeclarations
    `-> ClassBodyDeclarations ClassBodyDeclaration
                              `-> ClassMemberDeclaration
                                  `-> MethodDeclaration
                                      `-> MethodHeader MethodBody .
jp_SEMICOL
  Reduce derivation
    ClassBodyDeclarations
    `-> ClassBodyDeclarations
ClassBodyDeclaration
        `-> ClassBodyDeclarations ClassBodyDeclaration
`-> TypeDeclaration
                                  `-> ClassMemberDeclaration
    `-> jp_SEMICOL
                                      `-> MethodDeclaration
                                          `-> MethodHeader MethodBody .
cmDependsJavaParser.y: warning: shift/reduce conflict on token jp_DOT
[-Wcounterexamples]
  Example: jp_THIS . jp_DOT Identifier
  Shift derivation
    FieldAccess
    `-> jp_THIS . jp_DOT Identifier
  Reduce derivation
    FieldAccess
    `-> Primary               jp_DOT Identifier
        `-> PrimaryNoNewArray
            `-> jp_THIS .
cmDependsJavaParser.y: warning: shift/reduce conflict on token jp_DOT
[-Wcounterexamples]
  Example: jp_THIS . jp_DOT Identifier jp_PARESTART jp_PAREEND
  Shift derivation
    MethodInvocation
    `-> jp_THIS . jp_DOT Identifier jp_PARESTART ArgumentListopt jp_PAREEND
                                                 `-> %empty
  Reduce derivation
    MethodInvocation
    `-> Primary               jp_DOT Identifier jp_PARESTART
ArgumentListopt jp_PAREEND
        `-> PrimaryNoNewArray                                `-> %empty
            `-> jp_THIS .
cmDependsJavaParser.y: warning: shift/reduce conflict on token
jp_SEMICOL [-Wcounterexamples]
  Example: ClassBodyDeclarations Modifiersopt ConstructorDeclarator
Throwsopt ConstructorBody . jp_SEMICOL
  Shift derivation
    ClassBodyDeclarations
    `-> ClassBodyDeclarations ClassBodyDeclaration
                              `-> ConstructorDeclaration
                                  `-> Modifiersopt ConstructorDeclarator
Throwsopt ConstructorBody . jp_SEMICOL
  Reduce derivation
    ClassBodyDeclarations
    `-> ClassBodyDeclarations
                                 ClassBodyDeclaration
        `-> ClassBodyDeclarations ClassBodyDeclaration
                                 `-> TypeDeclaration
                                  `-> ConstructorDeclaration
                                     `-> jp_SEMICOL
                                      `-> Modifiersopt
ConstructorDeclarator Throwsopt ConstructorBody .
cmDependsJavaParser.y: warning: shift/reduce conflict on token jp_DOT
[-Wcounterexamples]
  Example: jp_THIS . jp_DOT Identifier
  Shift derivation
    FieldAccess
    `-> jp_THIS . jp_DOT Identifier
  Reduce derivation
    FieldAccess
    `-> Primary               jp_DOT Identifier
        `-> PrimaryNoNewArray
            `-> jp_THIS .
cmDependsJavaParser.y: warning: shift/reduce conflict on token jp_DOT
[-Wcounterexamples]
  Example: jp_THIS . jp_DOT Identifier jp_PARESTART jp_PAREEND
  Shift derivation
    MethodInvocation
    `-> jp_THIS . jp_DOT Identifier jp_PARESTART ArgumentListopt jp_PAREEND
                                                 `-> %empty
  Reduce derivation
    MethodInvocation
    `-> Primary               jp_DOT Identifier jp_PARESTART
ArgumentListopt jp_PAREEND
        `-> PrimaryNoNewArray                                `-> %empty
            `-> jp_THIS .

Attachment: cmDependsJavaParser.y
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]