Skip to content

Instantly share code, notes, and snippets.

@shivansh
Created May 9, 2018 19:54
Show Gist options
  • Save shivansh/9d1b909206f84a3f0c44e0af37f849c6 to your computer and use it in GitHub Desktop.
Save shivansh/9d1b909206f84a3f0c44e0af37f849c6 to your computer and use it in GitHub Desktop.
This gist contains the debug output generated via `go test -v` which demonstrates the behavior of error recovery mode implemented in gocc.
=== RUN TestFail
input: a ; b
stack:
0: 0 , nil
S0 id(2,a) shift:3
stack:
0: 0 , nil
1: 3 , a
~~ No action exists for the current stack top and next input symbol ~~
Next recovery state: 0
Number of pops performed to reach the next recovery state: 1
Attribute corresponding to the popped non-recovery states: a
Next input symbol: ;
Pushing errorAttrib, look below for modified stack top
S4 id(2,b) reduce:4(Stmt : error << >>)
stack:
0: 0 , nil
1: 2 , Error in S0: INVALID(0,;), Pos(offset=2, line=1, column=3), expected one of: id error
S2 id(2,b) reduce:1(StmtList : Stmt << ast.NewStmtList(X[0]) >>)
stack:
0: 0 , nil
1: 1 , [Error in S0: INVALID(0,;), Pos(offset=2, line=1, column=3), expected one of: id error ]
S1 id(2,b) shift:3
stack:
0: 0 , nil
1: 1 , [Error in S0: INVALID(0,;), Pos(offset=2, line=1, column=3), expected one of: id error ]
2: 3 , b
S3 $(1,) reduce:3(Stmt : id << ast.NewStmt(X[0]) >>)
stack:
0: 0 , nil
1: 1 , [Error in S0: INVALID(0,;), Pos(offset=2, line=1, column=3), expected one of: id error ]
2: 5 , b
S5 $(1,) reduce:2(StmtList : StmtList Stmt << ast.AppendStmt(X[0], X[1]) >>)
stack:
0: 0 , nil
1: 1 , [Error in S0: INVALID(0,;), Pos(offset=2, line=1, column=3), expected one of: id error b]
S1 $(1,) accept(0)
output: [
Error in S0: INVALID(0,;), Pos(offset=2, line=1, column=3), expected one of: id error
b
]
--- PASS: TestFail (0.00s)
PASS
ok github.com/goccmack/gocc/example/errorrecovery 0.002s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment