Equations
- Lean.Parser.mkIdent info rawVal val = Lean.Syntax.ident info rawVal val []
Instances For
Return character after position pos
Equations
- Lean.Parser.getNext input pos = input.get (input.next pos)
Instances For
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
Instances For
Equations
Instances For
Instances For
Instances For
Equations
- s.insert k = Lean.PersistentHashMap.insert s k ()
Instances For
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.
- input : String
- fileName : String
- fileMap : Lean.FileMap
Instances For
Equations
- Lean.Parser.instInhabitedInputContext = { default := { input := default, fileName := default, fileMap := default } }
Input context derived from elaboration of previous commands.
- env : Lean.Environment
- options : Lean.Options
- currNamespace : Lean.Name
- openDecls : List Lean.OpenDecl
Instances For
Parser context parts that can be updated without invalidating the parser cache.
- prec : Nat
- quotDepth : Nat
- suppressInsideQuot : Bool
- savedPos? : Option String.Pos
- forbiddenTk? : Option Lean.Parser.Token
Instances For
Parser context updateable in adaptUncacheableContextFn
.
- tokens : Lean.Parser.TokenTable
Instances For
Opaque parser context updateable using adaptCacheableContextFn
and adaptUncacheableContextFn
.
Instances For
- unexpectedTk : Lean.Syntax
If not
missing
, used for lazily calculatingunexpected
message and range inmkErrorMessage
. Otherwise,ParserState.pos
is used as an empty range. - unexpected : String
Instances For
Equations
- Lean.Parser.instInhabitedError = { default := { unexpectedTk := 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.
Instances For
Equations
- Lean.Parser.Error.instToString = { toString := Lean.Parser.Error.toString }
Equations
- One or more equations did not get rendered due to their size.
Instances For
- 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 : Lean.Parser.ParserCacheKey) => 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 := input.endPos + ' ', stopPos := 0, token := Lean.Syntax.missing }, parserCache := ∅ }
Instances For
A syntax array with an inaccessible prefix, used for sound caching.
- raw : Array Lean.Syntax
- drop : Nat
Instances For
Equations
- stack.toSubarray = (Lean.Parser.SyntaxStack.raw stack).toSubarray (Lean.Parser.SyntaxStack.drop stack)
Instances For
Equations
- Lean.Parser.SyntaxStack.empty = { raw := #[], drop := 0 }
Instances For
Equations
- stack.size = (Lean.Parser.SyntaxStack.raw stack).size - Lean.Parser.SyntaxStack.drop stack
Instances For
Instances For
Equations
- stack.take n = { raw := (Lean.Parser.SyntaxStack.raw stack).take (Lean.Parser.SyntaxStack.drop stack + n), drop := Lean.Parser.SyntaxStack.drop stack }
Instances For
Instances For
Equations
- stack.push a = { raw := (Lean.Parser.SyntaxStack.raw stack).push a, drop := Lean.Parser.SyntaxStack.drop stack }
Instances For
Equations
- stack.pop = if stack.size > 0 then { raw := (Lean.Parser.SyntaxStack.raw stack).pop, drop := Lean.Parser.SyntaxStack.drop stack } else stack
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- stack.extract start stop = (Lean.Parser.SyntaxStack.raw stack).extract (Lean.Parser.SyntaxStack.drop stack + start) (Lean.Parser.SyntaxStack.drop stack + stop)
Instances For
Equations
- One or more equations did not get rendered due to their size.
- stxStack : Lean.Parser.SyntaxStack
- lhsPrec : Nat
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. - pos : String.Pos
- cache : Lean.Parser.ParserCache
- errorMsg : Option Lean.Parser.Error
- recoveredErrors : Array (String.Pos × Lean.Parser.SyntaxStack × Lean.Parser.Error)
Instances For
Instances For
Equations
- s.stackSize = s.stxStack.size
Instances For
Equations
- s.restore iniStackSz iniPos = { stxStack := s.stxStack.take iniStackSz, lhsPrec := s.lhsPrec, pos := iniPos, cache := s.cache, errorMsg := none, recoveredErrors := s.recoveredErrors }
Instances For
Equations
- s.setPos pos = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := pos, cache := s.cache, errorMsg := s.errorMsg, recoveredErrors := s.recoveredErrors }
Instances For
Equations
- s.setCache cache = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := s.pos, cache := cache, errorMsg := s.errorMsg, recoveredErrors := s.recoveredErrors }
Instances For
Equations
- s.pushSyntax n = { stxStack := s.stxStack.push n, lhsPrec := s.lhsPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg, recoveredErrors := s.recoveredErrors }
Instances For
Equations
- s.popSyntax = { stxStack := s.stxStack.pop, lhsPrec := s.lhsPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg, recoveredErrors := s.recoveredErrors }
Instances For
Equations
- s.takeStack iniStackSz = { stxStack := s.stxStack.take iniStackSz, lhsPrec := s.lhsPrec, pos := s.pos, cache := s.cache, errorMsg := s.errorMsg, recoveredErrors := s.recoveredErrors }
Instances For
Instances For
Equations
- s.next input pos = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := input.next pos, cache := s.cache, errorMsg := s.errorMsg, recoveredErrors := s.recoveredErrors }
Instances For
Equations
- s.next' input pos h = { stxStack := s.stxStack, lhsPrec := s.lhsPrec, pos := input.next' pos h, cache := s.cache, errorMsg := s.errorMsg, recoveredErrors := s.recoveredErrors }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- s.allErrors = s.recoveredErrors ++ (Option.map (fun (e : Lean.Parser.Error) => #[(s.pos, s.stxStack, e)]) s.errorMsg).getD #[]
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- s.mkError msg = (s.setError { unexpectedTk := Lean.Syntax.missing, unexpected := "", expected := [msg] }).pushSyntax Lean.Syntax.missing
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- s.mkEOIError expected = s.mkUnexpectedError "unexpected end of input" expected
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- s.mkErrorAt msg pos initStackSz? = s.mkErrorsAt [msg] pos initStackSz?
Instances For
Reports given 'expected' messages at range of top stack element (assumed to be a single token).
Replaces the element with missing
and resets position to the token position.
iniPos
can be specified to avoid this position lookup but still must be identical to the token position.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reports given 'expected' message at range of top stack element (assumed to be a single token).
Replaces the element with missing
and resets position to the token position.
iniPos
can be specified to avoid this position lookup but still must be identical to the token position.
Equations
- s.mkUnexpectedTokenError msg iniPos = s.mkUnexpectedTokenErrors [msg] iniPos
Instances For
Equations
- s.mkUnexpectedErrorAt msg pos = (s.setPos pos).mkUnexpectedError msg
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- Lean.Parser.instInhabitedParserFn = { default := fun (x : Lean.Parser.ParserContext) (s : Lean.Parser.ParserState) => 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
- Lean.Parser.FirstTokens.epsilon.seq x = x
- (Lean.Parser.FirstTokens.optTokens s₁).seq (Lean.Parser.FirstTokens.optTokens s₂) = Lean.Parser.FirstTokens.optTokens (s₁ ++ s₂)
- (Lean.Parser.FirstTokens.optTokens s₁).seq (Lean.Parser.FirstTokens.tokens s₂) = Lean.Parser.FirstTokens.tokens (s₁ ++ s₂)
- x✝.seq x = x✝
Instances For
Equations
- (Lean.Parser.FirstTokens.tokens tks).toOptional = Lean.Parser.FirstTokens.optTokens tks
- x.toOptional = x
Instances For
Equations
- Lean.Parser.FirstTokens.epsilon.merge x = x.toOptional
- x.merge Lean.Parser.FirstTokens.epsilon = x.toOptional
- (Lean.Parser.FirstTokens.tokens s₁).merge (Lean.Parser.FirstTokens.tokens s₂) = Lean.Parser.FirstTokens.tokens (s₁ ++ s₂)
- (Lean.Parser.FirstTokens.optTokens s₁).merge (Lean.Parser.FirstTokens.optTokens s₂) = Lean.Parser.FirstTokens.optTokens (s₁ ++ s₂)
- (Lean.Parser.FirstTokens.tokens s₁).merge (Lean.Parser.FirstTokens.optTokens s₂) = Lean.Parser.FirstTokens.optTokens (s₁ ++ s₂)
- (Lean.Parser.FirstTokens.optTokens s₁).merge (Lean.Parser.FirstTokens.tokens s₂) = Lean.Parser.FirstTokens.optTokens (s₁ ++ s₂)
- x✝.merge x = Lean.Parser.FirstTokens.unknown
Instances For
Equations
- Lean.Parser.FirstTokens.epsilon.toStr = "epsilon"
- Lean.Parser.FirstTokens.unknown.toStr = "unknown"
- (Lean.Parser.FirstTokens.tokens tks).toStr = toString tks
- (Lean.Parser.FirstTokens.optTokens tks).toStr = "?" ++ toString tks
Instances For
Equations
- Lean.Parser.FirstTokens.instToString = { toString := Lean.Parser.FirstTokens.toStr }
- 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 } }
Instances For
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 }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
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.
Instances For
Run p
with a fresh cache, restore outer cache afterwards.
p
may access the entire syntax stack.
Instances For
Run p
under the given context transformation with a fresh cache (see also withResetCacheFn
).
Equations
- One or more equations did not get rendered due to their size.
Instances For
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.
Instances For
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)
Instances For
Equations
- One or more equations did not get rendered due to their size.