Where are the shift/reduce conflicts in this Bison code coming from?

后端 未结 3 506
旧时难觅i
旧时难觅i 2021-01-14 14:39

I\'m trying to parse this syntax:

34 + 1 − 8, 32 * 87 + 6 / 4, 34 / 8

I\'m expecting to ground it like this:

(, (- (+ 34 1)         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-14 15:16

    To find where the conflicts are, use the --verbose option and look at the file example.output where your input file is example.y. Here is the file I got from your input:

    State 7 conflicts: 2 shift/reduce
    

    (omitted)

    state 7
    
        2 term: term . op term
        2     | term op term .
    
        COMMA     shift, and go to state 4
        OPERATOR  shift, and go to state 5
    
        COMMA     [reduce using rule 2 (term)]
        OPERATOR  [reduce using rule 2 (term)]
        $default  reduce using rule 2 (term)
    
        op  go to state 6
    

提交回复
热议问题