+
Skip to content

How to produce an output similar to bison/byacc for debugging ? #51

@mingodad

Description

@mingodad

The error messages from lalr for shift/reduce and reduce/reduce conflicts are a bit dry.
How to produce an output similar to the ones bison/byacc produce when specifying -v ?

byacc:

...
state 8
	lines : lines line *  (2)

	.  reduce 2


9: shift/reduce conflict (shift 20, reduce 16 [vexp]) on '+'
9: shift/reduce conflict (shift 21, reduce 16 [vexp]) on '-'
9: shift/reduce conflict (shift 22, reduce 16 [vexp]) on '*'
9: shift/reduce conflict (shift 23, reduce 16 [vexp]) on '/'
9: shift/reduce conflict (shift 24, reduce 16 [vexp]) on '\n'
state 9
	line : dexp * '\n'  (3)
	dexp : dexp * '+' dexp  (10)
	dexp : dexp * '-' dexp  (11)
	dexp : dexp * '*' dexp  (12)
	dexp : dexp * '/' dexp  (13)
	vexp : dexp *  (16)
	vexp : dexp * '+' vexp  (20)
	vexp : dexp * '-' vexp  (22)
	vexp : dexp * '*' vexp  (24)
	vexp : dexp * '/' vexp  (26)

	'+'  shift 20
	'-'  shift 21
	'*'  shift 22
	'/'  shift 23
	'\n'  shift 24


state 10
...

bison:

...
State 9

    2 lines: lines line •

    $default  reduce using rule 2 (lines)


State 10

    3 line: dexp • '\n'
   10 dexp: dexp • '+' dexp
   11     | dexp • '-' dexp
   12     | dexp • '*' dexp
   13     | dexp • '/' dexp
   16 vexp: dexp •
   20     | dexp • '+' vexp
   22     | dexp • '-' vexp
   24     | dexp • '*' vexp
   26     | dexp • '/' vexp

    '+'   shift, and go to state 21
    '-'   shift, and go to state 22
    '*'   shift, and go to state 23
    '/'   shift, and go to state 24
    '\n'  shift, and go to state 25

    '+'   [reduce using rule 16 (vexp)]
    '-'   [reduce using rule 16 (vexp)]
    '*'   [reduce using rule 16 (vexp)]
    '/'   [reduce using rule 16 (vexp)]
    '\n'  [reduce using rule 16 (vexp)]


State 11
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载