lark API reference
59 public APIs from lark (lark-parser/lark) — 31 classes, 6 functions, 22 methods. Signatures extracted by static analysis of the actual source.
Repository: lark-parser/lark
| Kind | Count |
|---|---|
| Classes | 31 |
| Functions | 6 |
| Methods | 22 |
API list
class
lark.exceptions.UnexpectedInputUnexpectedInput Error.
class
lark.lark.LarkMain interface for the library.
method
lark.lark.Lark.get_terminal(name:str) -> TerminalDefGet information about a terminal
method
lark.lark.Lark.lex(text:TextOrSlice, dont_ignore:bool=False) -> Iterator[Token]Only lex (and postlex) the text, without parsing it.
method
lark.lark.Lark.parse_interactive(text:Optional[LarkInput]=None, start:Optional[str]=None) -> 'InteractiveParser'Start an interactive parsing session.
class
lark.lark.LarkOptionsSpecifies the options for Lark
method
lark.lexer.Lexer.make_lexer_state(text:str)Deprecated
class
lark.lexer.LineCounterA utility class for keeping track of line & column information
method
lark.lexer.LineCounter.from_text_slice(text_slice:TextSlice) -> 'LineCounter'Build a counter positioned at ``text_slice.start``.
class
lark.lexer.PatternAn abstraction over regular expressions.
method
lark.lexer.Scanner.search(text:TextSlice, pos:int) -> Optional[int]Find the position of the earliest match, starting at pos
class
lark.lexer.TerminalDefA definition of a terminal
class
lark.lexer.TokenA string with meta-information, that is produced by the lexer.
class
lark.load_grammar.PrepareAnonTerminalsCreate a unique list of anonymous terminals.
func
lark.load_grammar.nr_deepcopy_tree(t)Deepcopy tree `t` without recursion
class
lark.parser_frontends.ScanMatchA non-overlapping match found by ``Lark.scan()``.
class
lark.parsers.cyk.CnfWrapperCNF wrapper for grammar.
class
lark.parsers.cyk.GrammarContext-free grammar.
class
lark.parsers.cyk.ParserParser wrapper.
class
lark.parsers.cyk.RuleContext-free grammar rule.
class
lark.parsers.cyk.RuleNodeA node in the parse tree, which also contains the full rhs rule.
func
lark.parsers.earley.Parser.scan(i, token, to_scan)The core Earley Scanner.
class
lark.parsers.earley_common.ItemAn Earley Item, the atom of the algorithm.
class
lark.parsers.earley_forest.ForestSumVisitorA visitor for prioritizing ambiguous parts of the Forest.
class
lark.parsers.earley_forest.ForestToPyDotVisitorA Forest visitor which writes the SPPF to a PNG.
class
lark.parsers.earley_forest.ForestTransformerThe base class for a bottom-up forest transformation.
method
lark.parsers.earley_forest.ForestTransformer.transform(root)Perform a transformation on an SPPF.
method
lark.parsers.earley_forest.ForestTransformer.transform_packed_node(node, data)Transform a packed node.
method
lark.parsers.earley_forest.ForestTransformer.transform_symbol_node(node, data)Transform a symbol node.
method
lark.parsers.earley_forest.ForestTransformer.transform_token_node(node)Transform a ``Token``.
class
lark.parsers.earley_forest.ForestVisitorAn abstract base class for building forest visitors.
class
lark.parsers.earley_forest.PackedNodeA Packed Node represents a single derivation in a symbol node.
class
lark.parsers.earley_forest.SymbolNodeA Symbol Node represents a symbol (or Intermediate LR0).
func
lark.parsers.grammar_analysis.calculate_sets(rules)Calculate FOLLOW sets.
class
lark.parsers.lalr_analysis.IntParseTableParse-table whose key is int.
class
lark.parsers.lalr_analysis.ParseTableParse-table whose key is State, i.e.
func
lark.parsers.xearley.Parser.scan(i, to_scan)The core Earley Scanner.
class
lark.tree.TreeThe main tree class.
method
lark.tree.Tree.find_data(data:str) -> 'Iterator[Tree[_Leaf_T]]'Returns all nodes of the tree whose data equals the given data.
method
lark.tree.Tree.find_pred(pred:'Callable[[Tree[_Leaf_T]], bool]') -> 'Iterator[Tree[_Leaf_T]]'Returns all nodes of the tree that evaluate pred(node) as true.
method
lark.tree.Tree.find_token(token_type:str) -> Iterator[_Leaf_T]Returns all tokens whose type equals the given token_type.
method
lark.tree.Tree.iter_subtrees() -> 'Iterator[Tree[_Leaf_T]]'Depth-first iteration.
method
lark.tree.Tree.iter_subtrees_topdown()Breadth-first iteration.
method
lark.tree.Tree.pretty(indent_str:str=' ') -> strReturns an indented string representation of the tree.
method
lark.tree.Tree.scan_values(pred:'Callable[[Branch[_Leaf_T]], bool]') -> Iterator[_Leaf_T]Return all values in the tree that evaluate pred(value) as true.
method
lark.tree_matcher.TreeMatcher.match_tree(tree:Tree, rulename:str) -> TreeMatch the elements of `tree` to the symbols of rule `rulename`.
method
lark.tree_templates.Template.apply_vars(vars:Mapping[str, Tree[str]]) -> Tree[str]Apply vars to the template tree
method
lark.tree_templates.Template.match(tree:TreeOrCode) -> Optional[MatchResult]Match a tree template to a tree.
class
lark.tree_templates.TemplateTranslatorUtility class for translating a collection of patterns
class
lark.utils.OrderedSetA minimal OrderedSet implementation, using a dictionary.
class
lark.utils.SerializeMemoizerA version of serialize that memoizes objects to reduce space
func
lark.utils.small_factors(n:int, max_factor:int) -> List[Tuple[int, int]]Splits n up into smaller factors and summands <= max_factor.
class
lark.visitors.InterpreterInterpreter walks the tree starting at the root.
method
lark.visitors.Interpreter.visit_children(tree:Tree[_Leaf_T]) -> ListVisit all the children of this tree and return the results as a list.
method
lark.visitors.Transformer.transform(tree:Tree[_Leaf_T]) -> _Return_TTransform the given tree, and return the final result
class
lark.visitors.Transformer_NonRecursiveSame as Transformer but non-recursive.
class
lark.visitors.VisitorTree visitor, non-recursive (can handle huge trees).
class
lark.visitors.Visitor_RecursiveBottom-up visitor, recursive.
func
lark.visitors.visit_children_decor(func:_InterMethod) -> _InterMethodA wrapper around Interpreter methods.
About this data
These signatures were extracted from the public source of lark-parser/lark
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.