Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing whitespace #1196

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lark/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_context(self, text: str, span: int=40) -> str:
after = text[pos:end].split(b'\n', 1)[0]
return (before + after + b'\n' + b' ' * len(before.expandtabs()) + b'^\n').decode("ascii", "backslashreplace")

def match_examples(self, parse_fn: 'Callable[[str], Tree]',
def match_examples(self, parse_fn: 'Callable[[str], Tree]',
examples: Union[Mapping[T, Iterable[str]], Iterable[Tuple[T, Iterable[str]]]],
token_type_match_fallback: bool=False,
use_accepts: bool=True
Expand Down Expand Up @@ -229,7 +229,7 @@ class UnexpectedToken(ParseError, UnexpectedInput):

def __init__(self, token, expected, considered_rules=None, state=None, interactive_parser=None, terminals_by_name=None, token_history=None):
super(UnexpectedToken, self).__init__()

# TODO considered_rules and expected can be figured out using state
self.line = getattr(token, 'line', '?')
self.column = getattr(token, 'column', '?')
Expand Down
6 changes: 3 additions & 3 deletions lark/lark.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def __init__(self, grammar: 'Union[Grammar, str, IO[str]]', **options) -> None:
else:
if self.options.cache is not True:
raise ConfigurationError("cache argument must be bool or str")

try:
username = getpass.getuser()
except Exception:
Expand Down Expand Up @@ -339,7 +339,7 @@ def __init__(self, grammar: 'Union[Grammar, str, IO[str]]', **options) -> None:
pass
except Exception: # We should probably narrow done which errors we catch here.
logger.exception("Failed to load Lark from cache: %r. We will try to carry on.", cache_fn)

# In theory, the Lark instance might have been messed up by the call to `_load`.
# In practice the only relevant thing that might have been overwritten should be `options`
self.options = old_options
Expand Down Expand Up @@ -609,7 +609,7 @@ def lex(self, text: str, dont_ignore: bool=False) -> Iterator[Token]:
def get_terminal(self, name: str) -> TerminalDef:
"""Get information about a terminal"""
return self._terminals_dict[name]

def parse_interactive(self, text: Optional[str]=None, start: Optional[str]=None) -> 'InteractiveParser':
"""Start an interactive parsing session.

Expand Down
4 changes: 2 additions & 2 deletions lark/parser_frontends.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, lexer_conf, parser_conf, options, parser=None):

if lexer_conf.postlex:
self.lexer = PostLexConnector(self.lexer, lexer_conf.postlex)

def _verify_start(self, start=None):
if start is None:
start_decls = self.parser_conf.start
Expand All @@ -94,7 +94,7 @@ def parse(self, text, start=None, on_error=None):
kw = {} if on_error is None else {'on_error': on_error}
stream = self._make_lexer_thread(text)
return self.parser.parse(stream, chosen_start, **kw)

def parse_interactive(self, text=None, start=None):
chosen_start = self._verify_start(start)
if self.parser_conf.parser_type != 'lalr':
Expand Down