feat: add withPosition and checkCol constructors
This commit is contained in:
parent
8b4f2227f3
commit
34cba1ec2e
5 changed files with 10 additions and 0 deletions
|
|
@ -191,6 +191,8 @@ inductive ParserDescr
|
|||
| cat : Name → Nat → ParserDescr
|
||||
| parser : Name → ParserDescr
|
||||
| notFollowedBy : ParserDescr → ParserDescr
|
||||
| withPosition : ParserDescr → ParserDescr
|
||||
| checkCol : Bool → ParserDescr
|
||||
|
||||
instance : Inhabited ParserDescr := ⟨ParserDescr.symbol ""⟩
|
||||
abbrev TrailingParserDescr := ParserDescr
|
||||
|
|
|
|||
|
|
@ -214,6 +214,8 @@ partial def compileParserDescr (env : Environment) (opts : Options) (categories
|
|||
| ParserDescr.nameLit => pure $ nameLit
|
||||
| ParserDescr.interpolatedStr d => interpolatedStr <$> visit d
|
||||
| ParserDescr.ident => pure $ ident
|
||||
| ParserDescr.checkCol strict => pure $ if strict then checkColGt else checkColGe
|
||||
| ParserDescr.withPosition d => withPosition <$> visit d
|
||||
| ParserDescr.nonReservedSymbol tk includeIdent => pure $ nonReservedSymbol tk includeIdent
|
||||
| ParserDescr.parser constName => do
|
||||
let (_, p) ← mkParserOfConstantAux env opts categories constName visit;
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ def compileEmbeddedParsers : ParserDescr → MetaM Unit
|
|||
| ParserDescr.node k prec d => compileEmbeddedParsers d
|
||||
| ParserDescr.trailingNode k prec d => compileEmbeddedParsers d
|
||||
| ParserDescr.interpolatedStr d => compileEmbeddedParsers d
|
||||
| ParserDescr.withPosition d => compileEmbeddedParsers d
|
||||
| ParserDescr.checkCol _ => pure ()
|
||||
| ParserDescr.symbol tk => pure ()
|
||||
| ParserDescr.numLit => pure ()
|
||||
| ParserDescr.strLit => pure ()
|
||||
|
|
|
|||
|
|
@ -423,6 +423,8 @@ unsafe def interpretParserDescr : ParserDescr → CoreM Formatter
|
|||
| ParserDescr.interpolatedStr d => interpolatedStr.formatter <$> interpretParserDescr d
|
||||
| ParserDescr.nonReservedSymbol tk includeIdent => pure $ nonReservedSymbol.formatter tk
|
||||
| ParserDescr.noWs => pure $ checkNoWsBefore.formatter
|
||||
| ParserDescr.withPosition d => withPosition.formatter <$> interpretParserDescr d
|
||||
| ParserDescr.checkCol strict => pure $ if strict then checkColGt.formatter else checkColGe.formatter
|
||||
| ParserDescr.parser constName => combinatorFormatterAttribute.runDeclFor constName
|
||||
| ParserDescr.cat catName prec => pure $ categoryParser.formatter catName
|
||||
|
||||
|
|
|
|||
|
|
@ -500,6 +500,8 @@ unsafe def interpretParserDescr : ParserDescr → CoreM Parenthesizer
|
|||
| ParserDescr.interpolatedStr d => interpolatedStr.parenthesizer <$> interpretParserDescr d
|
||||
| ParserDescr.nonReservedSymbol tk includeIdent => pure $ nonReservedSymbol.parenthesizer tk includeIdent
|
||||
| ParserDescr.noWs => pure $ checkNoWsBefore.parenthesizer
|
||||
| ParserDescr.checkCol strict => pure $ if strict then checkColGt.parenthesizer else checkColGe.parenthesizer
|
||||
| ParserDescr.withPosition d => withPosition.parenthesizer <$> interpretParserDescr d
|
||||
| ParserDescr.parser constName => combinatorParenthesizerAttribute.runDeclFor constName
|
||||
| ParserDescr.cat catName prec => pure $ categoryParser.parenthesizer catName prec
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue