fix(tests/playground/parser/parser): reset position
This commit is contained in:
parent
68e8faeef1
commit
a716528067
1 changed files with 12 additions and 3 deletions
|
|
@ -657,13 +657,22 @@ def tokenFn : BasicParserFn
|
|||
|
||||
def symbolFnAux (sym : String) (errorMsg : String) : BasicParserFn
|
||||
| cfg s d :=
|
||||
let d := tokenFn cfg s d in
|
||||
let iniPos := d.pos in
|
||||
let d := tokenFn cfg s d in
|
||||
if d.hasError then
|
||||
let d := d.setPos iniPos in
|
||||
d.mkError errorMsg
|
||||
else
|
||||
match d.stxStack.back with
|
||||
| Syntax.atom _ sym' := if sym == sym' then d else d.mkError errorMsg
|
||||
| _ := d.mkError errorMsg
|
||||
| Syntax.atom _ sym' :=
|
||||
if sym == sym' then
|
||||
d
|
||||
else
|
||||
let d := d.setPos iniPos in
|
||||
d.mkError errorMsg
|
||||
| _ :=
|
||||
let d := d.setPos iniPos in
|
||||
d.mkError errorMsg
|
||||
|
||||
@[inline] def symbolFn (sym : String) : BasicParserFn :=
|
||||
symbolFnAux sym ("expected '" ++ sym ++ "'")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue