Skip to content

Commit

Permalink
Merge pull request #1196 from bcr/whitespace-fixes
Browse files Browse the repository at this point in the history
Remove trailing whitespace
  • Loading branch information
erezsh authored Sep 23, 2022
2 parents f009312 + 1a86228 commit b07d6ff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
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

0 comments on commit b07d6ff

Please sign in to comment.