Gadgets for compiling parser declarations into other programs, such as pretty printers.
- varName : Lean.Name
- categoryAttr : Lean.KeyedDeclsAttribute α
- combinatorAttr : Lean.ParserCompiler.CombinatorAttribute
Instances For
Equations
- ctx.tyName = ctx.categoryAttr.defn.valueTypeName
Instances For
def
Lean.ParserCompiler.replaceParserTy
{α : Type}
(ctx : Lean.ParserCompiler.Context α)
(e : Lean.Expr)
:
Replace all references of Parser
with tyName
Equations
- One or more equations did not get rendered due to their size.
Instances For
Takes an expression of type Parser
, and determines the syntax kind of the root node it produces.
partial def
Lean.ParserCompiler.compileParserExpr
{α : Type}
(ctx : Lean.ParserCompiler.Context α)
(builtin force : Bool)
(e : Lean.Expr)
:
Translate an expression of type Parser
into one of type tyName
, tagging intermediary constants with
ctx.combinatorAttr
. If force
is false
, refuse to do so for imported constants.
def
Lean.ParserCompiler.compileEmbeddedParsers
{α : Type}
(ctx : Lean.ParserCompiler.Context α)
(builtin : Bool)
:
Equations
- One or more equations did not get rendered due to their size.
- Lean.ParserCompiler.compileEmbeddedParsers ctx builtin (Lean.ParserDescr.const name) = pure ()
- Lean.ParserCompiler.compileEmbeddedParsers ctx builtin (Lean.ParserDescr.unary name d) = Lean.ParserCompiler.compileEmbeddedParsers ctx builtin d
- Lean.ParserCompiler.compileEmbeddedParsers ctx builtin (Lean.ParserDescr.parser constName) = discard (Lean.ParserCompiler.compileParserExpr ctx builtin false (Lean.mkConst constName))
- Lean.ParserCompiler.compileEmbeddedParsers ctx builtin (Lean.ParserDescr.node kind prec d) = Lean.ParserCompiler.compileEmbeddedParsers ctx builtin d
- Lean.ParserCompiler.compileEmbeddedParsers ctx builtin (Lean.ParserDescr.nodeWithAntiquot name kind d) = Lean.ParserCompiler.compileEmbeddedParsers ctx builtin d
- Lean.ParserCompiler.compileEmbeddedParsers ctx builtin (Lean.ParserDescr.trailingNode kind prec lhsPrec d) = Lean.ParserCompiler.compileEmbeddedParsers ctx builtin d
- Lean.ParserCompiler.compileEmbeddedParsers ctx builtin (Lean.ParserDescr.symbol val) = pure ()
- Lean.ParserCompiler.compileEmbeddedParsers ctx builtin (Lean.ParserDescr.nonReservedSymbol val includeIdent) = pure ()
- Lean.ParserCompiler.compileEmbeddedParsers ctx builtin (Lean.ParserDescr.cat catName rbp) = pure ()
Instances For
unsafe def
Lean.ParserCompiler.registerParserCompiler
{α : Type}
(ctx : Lean.ParserCompiler.Context α)
:
Precondition: α
must match ctx.tyName
.