From b7f1ebbbf0421d27d958694f1032464660ed64a0 Mon Sep 17 00:00:00 2001 From: Erez Shinan Date: Sun, 24 Sep 2023 17:38:46 +0300 Subject: [PATCH] Fixes according to review notes --- lark/lark.py | 8 ++++---- lark/parser_frontends.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lark/lark.py b/lark/lark.py index fb0341d2..f07a7f35 100644 --- a/lark/lark.py +++ b/lark/lark.py @@ -62,7 +62,7 @@ class LarkOptions(Serialize): regex: bool g_regex_flags: int keep_all_tokens: bool - tree_class: Callable + tree_class: Optional[Callable[[str, Sequence], Any]] parser: _ParserArgType lexer: _LexerArgType ambiguity: 'Literal["auto", "resolve", "explicit", "forest"]' @@ -70,12 +70,12 @@ class LarkOptions(Serialize): priority: 'Optional[Literal["auto", "normal", "invert"]]' lexer_callbacks: Dict[str, Callable[[Token], Token]] use_bytes: bool + ordered_sets: bool edit_terminals: Optional[Callable[[TerminalDef], TerminalDef]] import_paths: 'List[Union[str, Callable[[Union[None, str, PackageResource], str], Tuple[str, str]]]]' source_path: Optional[str] - ordered_sets: bool - OPTIONS_DOC = """ + OPTIONS_DOC = r""" **=== General Options ===** start @@ -143,7 +143,7 @@ class LarkOptions(Serialize): use_bytes Accept an input of type ``bytes`` instead of ``str``. ordered_sets - Should Earley use ordered-sets to achieve stable output (~10%% slower than regular sets. Default: True) + Should Earley use ordered-sets to achieve stable output (~10% slower than regular sets. Default: True) edit_terminals A callback for editing the terminals before parse. import_paths diff --git a/lark/parser_frontends.py b/lark/parser_frontends.py index 199e4e2f..e7b19ff1 100644 --- a/lark/parser_frontends.py +++ b/lark/parser_frontends.py @@ -1,7 +1,7 @@ from typing import Any, Callable, Dict, Optional, Collection from .exceptions import ConfigurationError, GrammarError, assert_config -from .utils import get_regexp_width, Serialize, OrderedSet +from .utils import get_regexp_width, Serialize from .parsers.grammar_analysis import GrammarAnalyzer from .lexer import LexerThread, BasicLexer, ContextualLexer, Lexer from .parsers import earley, xearley, cyk