Equations
- StrataDDM.Parser.TokenTable.addParser tt p = List.foldl (fun (tt : Lean.Parser.TokenTable) (t : String) => Lean.Data.Trie.insert tt t t) tt (p.info.collectTokens [])
Instances For
Create an input context from a string.
Equations
- StrataDDM.Parser.stringInputContext fileName contents = { inputString := contents, fileName := fileName.toString, fileMap := Lean.FileMap.ofString contents, endPos_valid := ⋯ }
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
- 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
- One or more equations did not get rendered due to their size.
Instances For
Equations
- StrataDDM.Parser.hexNumberFn startPos c s = StrataDDM.Parser.mkNodeToken✝ Lean.numLitKind startPos c (StrataDDM.Parser.takeDigitsFn✝ StrataDDM.Parser.isHexDigit "hexadecimal number" true c s)
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
- One or more equations did not get rendered due to their size.
Instances For
Parses a token and asserts the result is of the given kind.
desc is used in error messages as the token kind.
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
- StrataDDM.Parser.symbolFnAux sym errorMsg = StrataDDM.Parser.satisfySymbolFn (fun (s : String) => s == sym) [errorMsg]
Instances For
Equations
- StrataDDM.Parser.symbolFn sym = StrataDDM.Parser.symbolFnAux sym ("'" ++ sym ++ "'")
Instances For
Equations
- StrataDDM.Parser.symbolNoAntiquot sym = { info := Lean.Parser.symbolInfo sym, fn := StrataDDM.Parser.symbolFn sym }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- StrataDDM.Parser.numLit = { info := Lean.Parser.mkAtomicInfo "num", fn := StrataDDM.Parser.expectTokenFn Lean.numLitKind "numeral" }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- StrataDDM.Parser.decimalLit = { info := Lean.Parser.mkAtomicInfo "scientific", fn := StrataDDM.Parser.expectTokenFn Lean.scientificLitKind "scientific number" }
Instances For
Equations
- StrataDDM.Parser.strLit = { info := Lean.Parser.mkAtomicInfo "str", fn := StrataDDM.Parser.expectTokenFn Lean.strLitKind "string literal" }
Instances For
Equations
- StrataDDM.Parser.identName nm = (Lean.Name.anonymous.str nm.dialect).str nm.name
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- StrataDDM.Parser.peekToken c s = if (s.cache.tokenCache.startPos == s.pos) = true then (s, Except.ok s.cache.tokenCache.token) else StrataDDM.Parser.peekTokenAux c s
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- StrataDDM.Parser.longestMatchMkResult startSize s = if s.stackSize > startSize + 1 then s.mkNode Lean.choiceKind startSize else s
Instances For
Equations
- StrataDDM.Parser.longestMatchFnAux left? startSize startLhsPrec startPos prevPrio ps = StrataDDM.Parser.longestMatchFnAux.parse✝ left? startSize startLhsPrec startPos prevPrio ps
Instances For
Equations
- One or more equations did not get rendered due to their size.
- StrataDDM.Parser.longestMatchFn left? [] = fun (x : Lean.Parser.ParserContext) (s : Lean.Parser.ParserState) => s.mkError "longestMatch: empty list"
- StrataDDM.Parser.longestMatchFn left? [p] = fun (c : Lean.Parser.ParserContext) (s : Lean.Parser.ParserState) => Lean.Parser.runLongestMatchParser left? s.lhsPrec p.fst.fn c s
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Implements a variant of Pratt's algorithm. In Pratt's algorithms tokens have a right and left binding power.
In our implementation, parsers have precedence instead. This method selects a parser (or more, via
longestMatchFn) from leadingTable based on the current token. Note that the unindexed leadingParsers parsers
are also tried. We have the unidexed leadingParsers because some parsers do not have a "first token". Example:
syntax term:51 "≤" ident "<" term "|" term : index
Example, in principle, the set of first tokens for this parser is any token that can start a term, but this set
is always changing. Thus, this parsing rule is stored as an unindexed leading parser at leadingParsers.
After processing the leading parser, we chain with parsers from trailingTable/trailingParsers that have precedence
at least c.prec where c is the ParsingContext. Recall that c.prec is set by categoryParser.
Note that in the original Pratt's algorithm, precedences are only checked before calling trailing parsers. In our implementation, leading and trailing parsers check the precedence. We claim our algorithm is more flexible, modular and easier to understand.
antiquotParser should be a mkAntiquot parser (or always fail) and is tried before all other parsers.
It should not be added to the regular leading parsers because it would heavily
overlap with antiquotation parsers nested inside them.
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
Describes the atoms in a pattern to identify left-recusive syntax.
- isLeading
(atoms : List SyntaxDefAtom)
: LhsRec
This atom is not left-recursive and uses the
seqatoms. - isTrailing
(minArgPrec : Nat)
(remaining : List SyntaxDefAtom)
: LhsRec
This atom is left-recursive The initial argument must have precedence ≥ prec. The remaining syntax is given.
- invalid
(message : StrataFormat)
: LhsRec
Classification failed with message
Instances For
Equations
Information about a parser.
- category : QualifiedIdent
- outerPrec : Nat
- isLeading : Bool
- parser : Parser
Instances For
- fixedParsers : Std.HashMap QualifiedIdent Parser
Instances
Equations
- One or more equations did not get rendered due to their size.
Instances For
Parser function for given syntax category
Equations
- ctx.atomCatParser cat = match StrataDDM.Parser.ParsingContext.fixedParsers[cat]? with | some p => p | x => StrataDDM.Parser.dynamicParser cat
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
Parser function for given syntax category
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- ctx.fnDeclParser dialect decl = ctx.opSyntaxParser { dialect := "Init", name := "Expr" } { dialect := dialect, name := decl.name } decl.argDecls decl.syntaxDef
Instances For
Equations
- ctx.opDeclParser dialect decl = ctx.opSyntaxParser decl.category { dialect := dialect, name := decl.name } decl.argDecls decl.syntaxDef
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.