Skip to content

Commit

Permalink
Fixes according to review notes (make tree_class optional)
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Sep 25, 2023
1 parent b7f1ebb commit b8b69c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lark/parsers/earley.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
is explained here: https://lark-parser.readthedocs.io/en/latest/_static/sppf/sppf.html
"""

from typing import TYPE_CHECKING, Callable
from typing import TYPE_CHECKING, Callable, Optional, Sequence, Any
from collections import deque

from ..lexer import Token
Expand All @@ -30,7 +30,8 @@ class Parser:
debug: bool

def __init__(self, lexer_conf: 'LexerConf', parser_conf: 'ParserConf', term_matcher: Callable,
resolve_ambiguity: bool=True, debug: bool=False, tree_class: type=Tree, ordered_sets: bool=True):
resolve_ambiguity: bool=True, debug: bool=False,
tree_class: Optional[type]=Tree, ordered_sets: bool=True):
analysis = GrammarAnalyzer(parser_conf)
self.lexer_conf = lexer_conf
self.parser_conf = parser_conf
Expand Down
4 changes: 2 additions & 2 deletions lark/parsers/xearley.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Earley's power in parsing any CFG.
"""

from typing import TYPE_CHECKING, Callable
from typing import TYPE_CHECKING, Callable, Optional, Sequence, Any
from collections import defaultdict

from ..tree import Tree
Expand All @@ -30,7 +30,7 @@
class Parser(BaseParser):
def __init__(self, lexer_conf: 'LexerConf', parser_conf: 'ParserConf', term_matcher: Callable,
resolve_ambiguity: bool=True, complete_lex: bool=False, debug: bool=False,
tree_class: type=Tree, ordered_sets: bool=True):
tree_class: Optional[type]=Tree, ordered_sets: bool=True):
BaseParser.__init__(self, lexer_conf, parser_conf, term_matcher, resolve_ambiguity,
debug, tree_class, ordered_sets)
self.ignore = [Terminal(t) for t in lexer_conf.ignore]
Expand Down

0 comments on commit b8b69c7

Please sign in to comment.