Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mingodad opened this issue Jul 20, 2023 · 0 comments
Open

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

mingodad opened this issue Jul 20, 2023 · 0 comments

Comments

@mingodad
Copy link
Contributor

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
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant