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.
- mk' :: (
- inputString : String
- fileName : String
- fileMap : FileMap
- endPos : String.Pos
- )
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Parser.InputContext.mk input fileName endPos endPos_valid fileMap = { inputString := input, fileName := fileName, fileMap := fileMap, endPos := endPos, endPos_valid := endPos_valid }
Instances For
Equations
- c.input = c.inputString.extract 0 c.endPos
Instances For
Returns true
if a specified byte position is greater than or equal to the position which points to
the end of the input string. Otherwise, returns false
.
Instances For
Returns the character at position p
of the input string. If p
is not a valid position, returns
the fallback value (default : Char)
, which is 'A'
, but does not panic.
Equations
- c.get p = c.inputString.get p
Instances For
Returns the character at position p
of the input string. Returns (default : Char)
, which is
'A'
, if p
is not a valid position.
Requires evidence, h
, that p
is within bounds instead of performing a run-time bounds check as
in InputContext.get
.
A typical pattern combines get'
with a dependent if
-expression to avoid the overhead of an
additional bounds check. For example:
def getInBounds? (s : String) (p : String.Pos) : Option Char :=
if h : s.atEnd p then none else some (s.get' p h)
Even with evidence of ¬ s.atEnd p
, p
may be invalid if a byte index points into the middle of a
multi-byte UTF-8 character.
Equations
- c.get' p h = c.inputString.get' p ⋯
Instances For
Returns the next position in the input string after position p
. If p
is not a valid position or
p = c.endPos
, returns the position one byte after p
.
A run-time bounds check is performed to determine whether p
is at the end of the string. If a
bounds check has already been performed, use InputContext.next'
to avoid a repeated check.
Equations
- c.next p = c.inputString.next p
Instances For
Returns the next position in the input string after position p
. The result is unspecified if p
is not a valid position.
Requires evidence, h
, that p
is within bounds. No run-time bounds check is performed.
Equations
- c.next' p h = c.inputString.next' p ⋯
Instances For
Creates a new string that consists of the region of the input string delimited by the two positions.
The result is ""
if the start position is greater than or equal to the end position or if the
start position is at the end of the string. If either position is invalid (that is, if either points
at the middle of a multi-byte UTF-8 character) then the result is unspecified.
Equations
- c.extract = c.inputString.extract
Instances For
Extracts a substring of the input string, bounded by startPos
and stopPos
.
Equations
Instances For
Returns the character position prior to pos
Equations
- c.prev pos = c.inputString.prev pos
Instances For
Input context derived from elaboration of previous commands.
- env : Environment
- options : Options
- currNamespace : Name
Instances For
Parser context parts that can be updated without invalidating the parser cache.
- prec : Nat
- quotDepth : Nat
- suppressInsideQuot : Bool
- savedPos? : Option String.Pos
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Parser.instBEqCacheableParserContext.beq x✝¹ x✝ = false
Instances For
Parser context updateable in adaptUncacheableContextFn
.
- tokens : TokenTable
Instances For
Opaque parser context updateable using adaptCacheableContextFn
and adaptUncacheableContextFn
.
Instances For
Equations
- Lean.Parser.instCoeParserContextInputContext = { coe := fun (x : Lean.Parser.ParserContext) => x.toInputContext }
Modifies the ending position of a parser context.
Equations
- One or more equations did not get rendered due to their size.
Instances For
- unexpectedTk : 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
Equations
Instances For
Equations
Instances For
Equations
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 : Syntax
Instances For
- parserName : Name
- pos : String.Pos
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Parser.instBEqParserCacheKey.beq x✝¹ x✝ = false
Instances For
Equations
- Lean.Parser.instHashableParserCacheKey = { hash := fun (k : Lean.Parser.ParserCacheKey) => hash (k.pos, k.parserName) }
- stx : Syntax
- lhsPrec : Nat
- newPos : String.Pos
Instances For
- tokenCache : TokenCacheEntry
- parserCache : Std.HashMap ParserCacheKey ParserCacheEntry
Instances For
Equations
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
Instances For
Equations
- stack.size = (Lean.Parser.SyntaxStack.raw✝ stack).size - Lean.Parser.SyntaxStack.drop✝ stack
Instances For
Instances For
Equations
- stack.shrink n = { raw := (Lean.Parser.SyntaxStack.raw✝ stack).shrink (Lean.Parser.SyntaxStack.drop✝ stack + n), drop := Lean.Parser.SyntaxStack.drop✝¹ stack }
Instances For
Equations
- stack.push a = { raw := (Lean.Parser.SyntaxStack.raw✝ stack).push a, drop := Lean.Parser.SyntaxStack.drop✝ stack }
Instances For
Equations
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 : 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 : ParserCache
- recoveredErrors : Array (String.Pos × SyntaxStack × Error)
Instances For
Instances For
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
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
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- s.mkError msg = (s.setError { 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 : FirstTokens
- unknown : FirstTokens
- tokens : List Token → FirstTokens
- optTokens : List Token → FirstTokens
Instances For
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
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
- collectKinds : SyntaxNodeKindSet → SyntaxNodeKindSet
- firstTokens : FirstTokens
Instances For
Equations
Equations
Instances For
Equations
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
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)