feat: add notFollowedBy
This commit is contained in:
parent
25384142c2
commit
2563d03ae2
3 changed files with 23 additions and 0 deletions
|
|
@ -475,6 +475,21 @@ fun c s =>
|
|||
{ info := p.info,
|
||||
fn := lookaheadFn p.fn }
|
||||
|
||||
@[inline] def notFollowedByFn (p : ParserFn) : ParserFn :=
|
||||
fun c s =>
|
||||
let iniSz := s.stackSize;
|
||||
let iniPos := s.pos;
|
||||
let s := p c s;
|
||||
if s.hasError then
|
||||
s.restore iniSz iniPos
|
||||
else
|
||||
let s := s.restore iniSz iniPos;
|
||||
s.mkError "notFollowedBy"
|
||||
|
||||
@[inline] def notFollowedBy (p : Parser) : Parser :=
|
||||
{ info := p.info,
|
||||
fn := notFollowedByFn p.fn }
|
||||
|
||||
@[specialize] partial def manyAux (p : ParserFn) : ParserFn
|
||||
| c, s =>
|
||||
let iniSz := s.stackSize;
|
||||
|
|
|
|||
|
|
@ -232,6 +232,10 @@ p
|
|||
def lookahead.formatter (p : Formatter) : Formatter :=
|
||||
pure ()
|
||||
|
||||
@[combinatorFormatter Lean.Parser.notFollowedBy]
|
||||
def notFollowedBy.formatter (p : Formatter) : Formatter :=
|
||||
pure ()
|
||||
|
||||
@[combinatorFormatter Lean.Parser.andthen]
|
||||
def andthen.formatter (p1 p2 : Formatter) : Formatter :=
|
||||
p2 *> p1
|
||||
|
|
|
|||
|
|
@ -324,6 +324,10 @@ p
|
|||
def lookahead.parenthesizer (p : Parenthesizer) : Parenthesizer :=
|
||||
pure ()
|
||||
|
||||
@[combinatorParenthesizer Lean.Parser.notFollowedBy]
|
||||
def notFollowedBy.parenthesizer (p : Parenthesizer) : Parenthesizer :=
|
||||
pure ()
|
||||
|
||||
@[combinatorParenthesizer Lean.Parser.andthen]
|
||||
def andthen.parenthesizer (p1 p2 : Parenthesizer) : Parenthesizer :=
|
||||
p2 *> p1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue