Equations
- Lean.Parser.mkAtom info val = Lean.Syntax.atom info val
Equations
- Lean.Parser.mkIdent info rawVal val = Lean.Syntax.ident info rawVal val []
Return character after position pos
Equations
- Lean.Parser.getNext input pos = String.get input (String.next input pos)
Maximal (and function application) precedence.
In the standard lean language, no parser has precedence higher than maxPrec
.
Note that nothing prevents users from using a higher precedence, but we strongly discourage them from doing it.
Equations
- Lean.Parser.maxPrec = 1024
- input : String
- fileName : String
- fileMap : Lean.FileMap
Input string and related data. Recall that the FileMap
is a helper structure for mapping
String.Pos
in the input string to line/column information.
Instances For
Equations
- Lean.Parser.instInhabitedInputContext = { default := { input := default, fileName := default, fileMap := default } }
- env : Lean.Environment
- options : Lean.Options
- currNamespace : Lean.Name
- openDecls : List Lean.OpenDecl
Input context derived from elaboration of previous commands.
Instances For
- prec : Nat
- quotDepth : Nat
- suppressInsideQuot : Bool
- savedPos? : Option String.Pos
- forbiddenTk? : Option Lean.Parser.Token
Parser context parts that can be updated without invalidating the parser cache.
Instances For
- tokens : Lean.Parser.TokenTable
Parser context updateable in adaptUncacheableContextFn
.
Instances For
Opaque parser context updateable using adaptCacheableContextFn
and adaptUncacheableContextFn
.
Instances For
Equations
- Lean.Parser.instInhabitedError = { default := { unexpected := default, expected := default } }
Equations
- Lean.Parser.instBEqError = { beq := Lean.Parser.beqError✝ }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Parser.Error.instToStringError = { toString := Lean.Parser.Error.toString }
Equations
- One or more equations did not get rendered due to their size.
- startPos : String.Pos
- stopPos : String.Pos
- token : Lean.Syntax
Instances For
- parserName : Lean.Name
- pos : String.Pos
Instances For
Equations
Equations
- Lean.Parser.instHashableParserCacheKey = { hash := fun k => hash (k.pos, k.parserName) }
- stx : Lean.Syntax
- lhsPrec : Nat
- newPos : String.Pos
- errorMsg : Option Lean.Parser.Error
Instances For
- tokenCache : Lean.Parser.TokenCacheEntry
Instances For
Equations
- Lean.Parser.initCacheForInput input = { tokenCache := { startPos := String.endPos input + Char.ofNat 32, stopPos := 0, token := Lean.Syntax.missing }, parserCache := ∅ }
- raw : Array Lean.Syntax
- drop : Nat
A syntax array with an inaccessible prefix, used for sound caching.
Instances For
Equations
- Lean.Parser.SyntaxStack.toSubarray stack = Array.toSubarray stack.raw stack.drop (Array.size stack.raw)
Equations
- Lean.Parser.SyntaxStack.empty = { raw := #[], drop := 0 }
Equations
- Lean.Parser.SyntaxStack.size stack = Array.size stack.raw - stack.drop
Equations
- Lean.Parser.SyntaxStack.isEmpty stack = (Lean.Parser.SyntaxStack.size stack == 0)
Equations
- Lean.Parser.SyntaxStack.shrink stack n = { raw := Array.shrink stack.raw (stack.drop + n), drop := stack.drop }
Equations
- Lean.Parser.SyntaxStack.push stack a = { raw := Array.push stack.raw a, drop := stack.drop }
Equations
- Lean.Parser.SyntaxStack.pop stack = if Lean.Parser.SyntaxStack.size stack > 0 then { raw := Array.pop stack.raw, drop := stack.drop } else stack
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.SyntaxStack.extract stack start stop = Array.extract stack.raw (stack.drop + start) (stack.drop + stop)
Equations
- Lean.Parser.SyntaxStack.instHAppendSyntaxStackArraySyntax = { hAppend := fun stack stxs => { raw := stack.raw ++ stxs, drop := stack.drop } }
- stxStack : Lean.Parser.SyntaxStack
Set to the precedence of the preceding (not surrounding) parser by
runLongestMatchParser
for the use ofcheckLhsPrec
in trailing parsers. Note that with chaining, the preceding parser can be another trailing parser: in1 * 2 + 3
, the preceding parser is '*' when '+' is executed.lhsPrec : Nat- pos : String.Pos
- cache : Lean.Parser.ParserCache
- errorMsg : Option Lean.Parser.Error
Instances For
Equations
- Lean.Parser.ParserState.hasError s = (s.errorMsg != none)
Equations
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Parser.ParserState.setPos s pos = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := pos, cache := s.cache, errorMsg := s.errorMsg }
Equations
- Lean.Parser.ParserState.setCache s cache = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := s.pos, cache := cache, errorMsg := s.errorMsg }
Equations
- Lean.Parser.ParserState.pushSyntax s n = { stxStack := Lean.Parser.SyntaxStack.push s.stxStack n, lhsPrec := s.lhsPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg }
Equations
- Lean.Parser.ParserState.popSyntax s = { stxStack := Lean.Parser.SyntaxStack.pop s.stxStack, lhsPrec := s.lhsPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Parser.ParserState.next s input pos = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := String.next input pos, cache := s.cache, errorMsg := s.errorMsg }
Equations
- Lean.Parser.ParserState.next' s input pos h = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := String.next' input pos h, cache := s.cache, errorMsg := s.errorMsg }
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
- 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.ParserState.mkEOIError s expected = Lean.Parser.ParserState.mkUnexpectedError s "unexpected end of input" expected
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.instInhabitedParserFn = { default := fun x s => s }
- epsilon: Lean.Parser.FirstTokens
- unknown: Lean.Parser.FirstTokens
- tokens: List Lean.Parser.Token → Lean.Parser.FirstTokens
- optTokens: List Lean.Parser.Token → Lean.Parser.FirstTokens
Instances For
Equations
- Lean.Parser.instInhabitedFirstTokens = { default := Lean.Parser.FirstTokens.epsilon }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Parser.FirstTokens.toOptional x = match x with | Lean.Parser.FirstTokens.tokens tks => Lean.Parser.FirstTokens.optTokens tks | tks => tks
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.
- collectTokens : List Lean.Parser.Token → List Lean.Parser.Token
- collectKinds : Lean.Parser.SyntaxNodeKindSet → Lean.Parser.SyntaxNodeKindSet
- firstTokens : Lean.Parser.FirstTokens
Instances For
Equations
- Lean.Parser.instInhabitedParserInfo = { default := { collectTokens := default, collectKinds := default, firstTokens := default } }
- info : Lean.Parser.ParserInfo
- fn : Lean.Parser.ParserFn
Instances For
Equations
- Lean.Parser.instInhabitedParser = { default := { info := default, fn := default } }
Create a simple parser combinator that inherits the info
of the nested parser.
Equations
- Lean.Parser.withFn f p = { info := p.info, fn := f p.fn }
Equations
- One or more equations did not get rendered due to their size.
Run p
with a fresh cache, restore outer cache afterwards.
p
may access the entire syntax stack.
Equations
- One or more equations did not get rendered due to their size.
Run p
with a fresh cache, restore outer cache afterwards.
p
may access the entire syntax stack.
Run p
under the given context transformation with a fresh cache (see also withResetCacheFn
).
Equations
- Lean.Parser.adaptUncacheableContextFn f p = Lean.Parser.withResetCacheFn fun c s => p { toParserContextCore := f c.toParserContextCore } s
Run p
and record result in parser cache for any further invocation with this parserName
, parser context, and parser state.
p
cannot access syntax stack elements pushed before the invocation in order to make caching independent of parser history.
As this excludes trailing parsers from being cached, we also reset lhsPrec
, which is not read but set by leading parsers, to 0
in order to increase cache hits. Finally, errorMsg
is also reset to none
as a leading parser should not be called in the first
place if there was an error.
Equations
- One or more equations did not get rendered due to their size.
Run p
and record result in parser cache for any further invocation with this parserName
, parser context, and parser state.
p
cannot access syntax stack elements pushed before the invocation in order to make caching independent of parser history.
As this excludes trailing parsers from being cached, we also reset lhsPrec
, which is not read but set by leading parsers, to 0
in order to increase cache hits. Finally, errorMsg
is also reset to none
as a leading parser should not be called in the first
place if there was an error.
Equations
- Lean.Parser.withCache parserName = Lean.Parser.withFn (Lean.Parser.withCacheFn parserName)
Equations
- One or more equations did not get rendered due to their size.