Extensible parsing via attributes
- token: Lean.Parser.Token → Lean.Parser.ParserExtension.OLeanEntry
- kind: Lean.SyntaxNodeKind → Lean.Parser.ParserExtension.OLeanEntry
- category: Lean.Name → Lean.Parser.LeadingIdentBehavior → Lean.Parser.ParserExtension.OLeanEntry
- parser: Lean.Name → Lean.Name → Nat → Lean.Parser.ParserExtension.OLeanEntry
- token: Lean.Parser.Token → Lean.Parser.ParserExtension.Entry
- kind: Lean.SyntaxNodeKind → Lean.Parser.ParserExtension.Entry
- category: Lean.Name → Lean.Parser.LeadingIdentBehavior → Lean.Parser.ParserExtension.Entry
- parser: Lean.Name → Lean.Name → Bool → Lean.Parser.Parser → Nat → Lean.Parser.ParserExtension.Entry
Equations
- Lean.Parser.ParserExtension.instInhabitedEntry = { default := Lean.Parser.ParserExtension.Entry.token default }
Equations
- One or more equations did not get rendered due to their size.
- tokens : Lean.Parser.TokenTable
- kinds : Lean.Parser.SyntaxNodeKindSet
- categories : Lean.Parser.ParserCategories
Equations
- Lean.Parser.ParserExtension.instInhabitedState = { default := { tokens := default, kinds := default, categories := default } }
@[inline]
Equations
- Lean.Parser.getCategory categories catName = Std.PersistentHashMap.find? categories catName
def
Lean.Parser.addLeadingParser
(categories : Lean.Parser.ParserCategories)
(catName : Lean.Name)
(p : Lean.Parser.Parser)
(prio : Nat)
:
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.addTrailingParser
(categories : Lean.Parser.ParserCategories)
(catName : Lean.Name)
(p : Lean.Parser.TrailingParser)
(prio : Nat)
:
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.addParser
(categories : Lean.Parser.ParserCategories)
(catName : Lean.Name)
(_declName : Lean.Name)
(leading : Bool)
(p : Lean.Parser.Parser)
(prio : Nat)
:
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.addParserTokens
(tokenTable : Lean.Parser.TokenTable)
(info : Lean.Parser.ParserInfo)
:
Equations
- Lean.Parser.addParserTokens tokenTable info = let newTokens := Lean.Parser.ParserInfo.collectTokens info []; List.foldlM Lean.Parser.addTokenConfig tokenTable newTokens
def
Lean.Parser.ParserExtension.addEntryImpl
(s : Lean.Parser.ParserExtension.State)
(e : Lean.Parser.ParserExtension.Entry)
:
Equations
- One or more equations did not get rendered due to their size.
- const: {α : Type} → α → Lean.Parser.AliasValue α
- unary: {α : Type} → (α → α) → Lean.Parser.AliasValue α
- binary: {α : Type} → (α → α → α) → Lean.Parser.AliasValue α
@[inline]
Equations
def
Lean.Parser.registerAliasCore
{α : Type}
(mapRef : IO.Ref (Lean.Parser.AliasTable α))
(aliasName : Lean.Name)
(value : Lean.Parser.AliasValue α)
:
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.getAlias
{α : Type}
(mapRef : IO.Ref (Lean.Parser.AliasTable α))
(aliasName : Lean.Name)
:
IO (Option (Lean.Parser.AliasValue α))
Equations
- Lean.Parser.getAlias mapRef aliasName = do let a ← ST.Ref.get mapRef pure (Lean.NameMap.find? a aliasName)
def
Lean.Parser.getConstAlias
{α : Type}
(mapRef : IO.Ref (Lean.Parser.AliasTable α))
(aliasName : Lean.Name)
:
IO α
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.getUnaryAlias
{α : Type}
(mapRef : IO.Ref (Lean.Parser.AliasTable α))
(aliasName : Lean.Name)
:
IO (α → α)
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.getBinaryAlias
{α : Type}
(mapRef : IO.Ref (Lean.Parser.AliasTable α))
(aliasName : Lean.Name)
:
IO (α → α → α)
Equations
- One or more equations did not get rendered due to their size.
@[inline]
Number of syntax nodes produced by this parser.
none
means "sum of input sizes".Whether arguments should be wrapped in
group(·)
if they do not produce exactly one syntax node.autoGroupArgs : Bool
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.registerAlias
(aliasName : Lean.Name)
(p : Lean.Parser.ParserAliasValue)
(kind? : optParam (Option Lean.SyntaxNodeKind) none)
(info : optParam Lean.Parser.ParserAliasInfo { stackSz? := some 1, autoGroupArgs := Option.isSome (some 1) })
:
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Parser.instCoeParserParserAliasValue = { coe := Lean.Parser.AliasValue.const }
Equations
- Lean.Parser.instCoeForAllParserParserAliasValue = { coe := Lean.Parser.AliasValue.unary }
Equations
- Lean.Parser.instCoeForAllParserParserAliasValue_1 = { coe := Lean.Parser.AliasValue.binary }
Equations
- Lean.Parser.isParserAlias aliasName = do let a ← Lean.Parser.getAlias Lean.Parser.parserAliasesRef aliasName match a with | some val => pure true | x => pure false
Equations
- Lean.Parser.getSyntaxKindOfParserAlias? aliasName = do let a ← ST.Ref.get Lean.Parser.parserAlias2kindRef pure (Lean.NameMap.find? a aliasName)
Equations
- Lean.Parser.ensureUnaryParserAlias aliasName = discard (Lean.Parser.getUnaryAlias Lean.Parser.parserAliasesRef aliasName)
Equations
- Lean.Parser.ensureBinaryParserAlias aliasName = discard (Lean.Parser.getBinaryAlias Lean.Parser.parserAliasesRef aliasName)
Equations
- Lean.Parser.ensureConstantParserAlias aliasName = discard (Lean.Parser.getConstAlias Lean.Parser.parserAliasesRef aliasName)
unsafe def
Lean.Parser.mkParserOfConstantUnsafe
(constName : Lean.Name)
(compileParserDescr : Lean.ParserDescr → Lean.ImportM Lean.Parser.Parser)
:
Equations
- One or more equations did not get rendered due to their size.
@[implementedBy Lean.Parser.mkParserOfConstantUnsafe]
opaque
Lean.Parser.mkParserOfConstantAux
(constName : Lean.Name)
(compileParserDescr : Lean.ParserDescr → Lean.ImportM Lean.Parser.Parser)
:
def
Lean.Parser.compileParserDescr
(categories : Lean.Parser.ParserCategories)
(d : Lean.ParserDescr)
:
Equations
- Lean.Parser.compileParserDescr categories d = Lean.Parser.compileParserDescr.visit categories d
def
Lean.Parser.mkParserOfConstant
(categories : Lean.Parser.ParserCategories)
(constName : Lean.Name)
:
Equations
- Lean.Parser.mkParserOfConstant categories constName = Lean.Parser.mkParserOfConstantAux constName (Lean.Parser.compileParserDescr categories)
- postAdd : Lean.Name → Lean.Name → Bool → Lean.AttrM Unit
Equations
- Lean.Parser.registerParserAttributeHook hook = ST.Ref.modify Lean.Parser.parserAttributeHooks fun hooks => hook :: hooks
def
Lean.Parser.runParserAttributeHooks
(catName : Lean.Name)
(declName : Lean.Name)
(builtin : Bool)
:
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Parser.isParserCategory env catName = Std.PersistentHashMap.contains (Lean.ScopedEnvExtension.getState Lean.Parser.parserExtension env).categories catName
def
Lean.Parser.addParserCategory
(env : Lean.Environment)
(catName : Lean.Name)
(behavior : Lean.Parser.LeadingIdentBehavior)
:
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
@[implementedBy Lean.Parser.evalParserConstUnsafe]
Run declName
if possible and inside a quotation, or else p
. The ParserInfo
will always be taken from p
.
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.addBuiltinParser
(catName : Lean.Name)
(declName : Lean.Name)
(leading : Bool)
(p : Lean.Parser.Parser)
(prio : Nat)
:
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.addBuiltinLeadingParser
(catName : Lean.Name)
(declName : Lean.Name)
(p : Lean.Parser.Parser)
(prio : Nat)
:
Equations
- Lean.Parser.addBuiltinLeadingParser catName declName p prio = Lean.Parser.addBuiltinParser catName declName true p prio
def
Lean.Parser.addBuiltinTrailingParser
(catName : Lean.Name)
(declName : Lean.Name)
(p : Lean.Parser.TrailingParser)
(prio : Nat)
:
Equations
- Lean.Parser.addBuiltinTrailingParser catName declName p prio = Lean.Parser.addBuiltinParser catName declName false p prio
Equations
- Lean.Parser.mkCategoryAntiquotParser kind = Lean.Parser.mkAntiquot (Lean.Name.toString kind) kind true true
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Parser.getSyntaxNodeKinds env = let kinds := (Lean.ScopedEnvExtension.getState Lean.Parser.parserExtension env).kinds; Std.PersistentHashMap.foldl kinds (fun ks k x => k :: ks) []
Equations
Equations
- Lean.Parser.mkInputContext input fileName = { input := input, fileName := fileName, fileMap := String.toFileMap input }
def
Lean.Parser.mkParserContext
(ictx : Lean.Parser.InputContext)
(pmctx : Lean.Parser.ParserModuleContext)
:
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Parser.mkParserState input = { stxStack := #[], lhsPrec := 0, pos := 0, cache := Lean.Parser.initCacheForInput input, errorMsg := none }
def
Lean.Parser.runParserCategory
(env : Lean.Environment)
(catName : Lean.Name)
(input : String)
(fileName : optParam String "<input>")
:
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.declareBuiltinParser
(addFnName : Lean.Name)
(catName : Lean.Name)
(declName : Lean.Name)
(prio : Nat)
:
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.declareLeadingBuiltinParser
(catName : Lean.Name)
(declName : Lean.Name)
(prio : Nat)
:
Equations
- Lean.Parser.declareLeadingBuiltinParser catName declName prio = Lean.Parser.declareBuiltinParser `Lean.Parser.addBuiltinLeadingParser catName declName prio
def
Lean.Parser.declareTrailingBuiltinParser
(catName : Lean.Name)
(declName : Lean.Name)
(prio : Nat)
:
Equations
- Lean.Parser.declareTrailingBuiltinParser catName declName prio = Lean.Parser.declareBuiltinParser `Lean.Parser.addBuiltinTrailingParser catName declName prio
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.registerBuiltinParserAttribute
(attrName : Lean.Name)
(catName : Lean.Name)
(behavior : optParam Lean.Parser.LeadingIdentBehavior Lean.Parser.LeadingIdentBehavior.default)
:
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
def
Lean.Parser.registerBuiltinDynamicParserAttribute
(attrName : Lean.Name)
(catName : Lean.Name)
:
Equations
- Lean.Parser.registerBuiltinDynamicParserAttribute attrName catName = Lean.registerBuiltinAttribute (Lean.Parser.mkParserAttributeImpl attrName catName)
def
Lean.Parser.registerParserCategory
(env : Lean.Environment)
(attrName : Lean.Name)
(catName : Lean.Name)
(behavior : optParam Lean.Parser.LeadingIdentBehavior Lean.Parser.LeadingIdentBehavior.default)
:
Equations
- One or more equations did not get rendered due to their size.
@[inline]
Equations
- Lean.Parser.commandParser rbp = Lean.Parser.categoryParser `command rbp
Equations
- One or more equations did not get rendered due to their size.
If the parsing stack is of the form #[.., openCommand]
, we process the open command, and execute p
Equations
- One or more equations did not get rendered due to their size.
@[inline]
Equations
- Lean.Parser.withOpen p = { info := p.info, fn := Lean.Parser.withOpenFn p.fn }
If the parsing stack is of the form #[.., openDecl]
, we process the open declaration, and execute p
Equations
- Lean.Parser.withOpenDeclFn p c s = if Array.size s.stxStack > 0 then let stx := Array.back s.stxStack; Lean.Parser.withOpenDeclFnCore stx p c s else p c s
@[inline]
Equations
- Lean.Parser.withOpenDecl p = { info := p.info, fn := Lean.Parser.withOpenDeclFn p.fn }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.