A few updates to stubs (fix #856)tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.3
| @@ -6,4 +6,9 @@ class RuleOptions: | |||||
| expand1: bool | expand1: bool | ||||
| priority: int | priority: int | ||||
| template_source: Optional[str] | template_source: Optional[str] | ||||
| empty_indices: Tuple[bool, ...] | |||||
| empty_indices: Tuple[bool, ...] | |||||
| class Symbol: | |||||
| name: str | |||||
| is_term: bool | |||||
| @@ -3,9 +3,10 @@ | |||||
| from typing import Tuple, List, Iterator, Optional | from typing import Tuple, List, Iterator, Optional | ||||
| from abc import ABC, abstractmethod | from abc import ABC, abstractmethod | ||||
| from .lexer import Token | from .lexer import Token | ||||
| from .lark import PostLex | |||||
| class Indenter(ABC): | |||||
| class Indenter(PostLex, ABC): | |||||
| paren_level: Optional[int] | paren_level: Optional[int] | ||||
| indent_level: Optional[List[int]] | indent_level: Optional[List[int]] | ||||
| @@ -15,13 +16,6 @@ class Indenter(ABC): | |||||
| def handle_NL(self, token: Token) -> Iterator[Token]: | def handle_NL(self, token: Token) -> Iterator[Token]: | ||||
| ... | ... | ||||
| def process(self, stream: Iterator[Token]) -> Iterator[Token]: | |||||
| ... | |||||
| @property | |||||
| def always_accept(self) -> Tuple[str]: | |||||
| ... | |||||
| @property | @property | ||||
| @abstractmethod | @abstractmethod | ||||
| def NL_type(self) -> str: | def NL_type(self) -> str: | ||||
| @@ -65,7 +65,7 @@ class Lark: | |||||
| grammar: Union[Grammar, str, IO[str]], | grammar: Union[Grammar, str, IO[str]], | ||||
| *, | *, | ||||
| start: Union[None, str, List[str]] = "start", | start: Union[None, str, List[str]] = "start", | ||||
| parser: Literal["earley", "lalr", "cyk"] = "auto", | |||||
| parser: Literal["earley", "lalr", "cyk", "auto"] = "auto", | |||||
| lexer: Union[Literal["auto", "standard", "contextual", "dynamic", "dynamic_complete"], Type[Lexer]] = "auto", | lexer: Union[Literal["auto", "standard", "contextual", "dynamic", "dynamic_complete"], Type[Lexer]] = "auto", | ||||
| transformer: Optional[Transformer] = None, | transformer: Optional[Transformer] = None, | ||||
| postlex: Optional[PostLex] = None, | postlex: Optional[PostLex] = None, | ||||
| @@ -1,8 +1,8 @@ | |||||
| from typing import List, Tuple, Union, Callable, Dict, Optional | from typing import List, Tuple, Union, Callable, Dict, Optional | ||||
| from lark import Tree | |||||
| from lark.grammar import RuleOptions | |||||
| from lark.exceptions import UnexpectedInput | |||||
| from .tree import Tree | |||||
| from .grammar import RuleOptions | |||||
| from .exceptions import UnexpectedInput | |||||
| class Grammar: | class Grammar: | ||||
| @@ -11,8 +11,7 @@ from .lexer import TerminalDef | |||||
| class WriteTokensTransformer(Transformer_InPlace): | class WriteTokensTransformer(Transformer_InPlace): | ||||
| def __init__(self, tokens: Dict[str, TerminalDef], Dict[str, Callable[[Symbol], str]] = ...): | |||||
| ... | |||||
| def __init__(self, tokens: Dict[str, TerminalDef], term_subs: Dict[str, Callable[[Symbol], str]] = ...): ... | |||||
| class MatchTree(Tree): | class MatchTree(Tree): | ||||
| @@ -1,13 +1,14 @@ | |||||
| "Provides Indentation services for languages with indentation similar to Python" | "Provides Indentation services for languages with indentation similar to Python" | ||||
| from .exceptions import LarkError | from .exceptions import LarkError | ||||
| from .lark import PostLex | |||||
| from .lexer import Token | from .lexer import Token | ||||
| ###{standalone | ###{standalone | ||||
| class DedentError(LarkError): | class DedentError(LarkError): | ||||
| pass | pass | ||||
| class Indenter: | |||||
| class Indenter(PostLex): | |||||
| def __init__(self): | def __init__(self): | ||||
| self.paren_level = None | self.paren_level = None | ||||
| self.indent_level = None | self.indent_level = None | ||||
| @@ -1,4 +1,6 @@ | |||||
| from __future__ import absolute_import | from __future__ import absolute_import | ||||
| from lark.exceptions import ConfigurationError, assert_config | from lark.exceptions import ConfigurationError, assert_config | ||||
| import sys, os, pickle, hashlib | import sys, os, pickle, hashlib | ||||
| @@ -6,7 +8,7 @@ from io import open | |||||
| import tempfile | import tempfile | ||||
| from warnings import warn | from warnings import warn | ||||
| from .utils import STRING_TYPE, Serialize, SerializeMemoizer, FS, isascii, logger | |||||
| from .utils import STRING_TYPE, Serialize, SerializeMemoizer, FS, isascii, logger, ABC, abstractmethod | |||||
| from .load_grammar import load_grammar, FromPackageLoader, Grammar | from .load_grammar import load_grammar, FromPackageLoader, Grammar | ||||
| from .tree import Tree | from .tree import Tree | ||||
| from .common import LexerConf, ParserConf | from .common import LexerConf, ParserConf | ||||
| @@ -191,6 +193,14 @@ _VALID_PRIORITY_OPTIONS = ('auto', 'normal', 'invert', None) | |||||
| _VALID_AMBIGUITY_OPTIONS = ('auto', 'resolve', 'explicit', 'forest') | _VALID_AMBIGUITY_OPTIONS = ('auto', 'resolve', 'explicit', 'forest') | ||||
| class PostLex(ABC): | |||||
| @abstractmethod | |||||
| def process(self, stream): | |||||
| return stream | |||||
| always_accept = () | |||||
| class Lark(Serialize): | class Lark(Serialize): | ||||
| """Main interface for the library. | """Main interface for the library. | ||||
| @@ -56,7 +56,6 @@ EXTRACT_STANDALONE_FILES = [ | |||||
| 'utils.py', | 'utils.py', | ||||
| 'tree.py', | 'tree.py', | ||||
| 'visitors.py', | 'visitors.py', | ||||
| 'indenter.py', | |||||
| 'grammar.py', | 'grammar.py', | ||||
| 'lexer.py', | 'lexer.py', | ||||
| 'common.py', | 'common.py', | ||||
| @@ -65,6 +64,7 @@ EXTRACT_STANDALONE_FILES = [ | |||||
| 'parsers/lalr_analysis.py', | 'parsers/lalr_analysis.py', | ||||
| 'parser_frontends.py', | 'parser_frontends.py', | ||||
| 'lark.py', | 'lark.py', | ||||
| 'indenter.py', | |||||
| ] | ] | ||||
| def extract_sections(lines): | def extract_sections(lines): | ||||
| @@ -12,6 +12,15 @@ logger.addHandler(logging.StreamHandler()) | |||||
| # By default, we should not output any log messages | # By default, we should not output any log messages | ||||
| logger.setLevel(logging.CRITICAL) | logger.setLevel(logging.CRITICAL) | ||||
| if sys.version_info[0]>2: | |||||
| from abc import ABC, abstractmethod | |||||
| else: | |||||
| from abc import ABCMeta, abstractmethod | |||||
| class ABC(object): # Provide Python27 compatibility | |||||
| __slots__ = () | |||||
| __metclass__ = ABCMeta | |||||
| Py36 = (sys.version_info[:2] >= (3, 6)) | Py36 = (sys.version_info[:2] >= (3, 6)) | ||||
| NO_VALUE = object() | NO_VALUE = object() | ||||