Procházet zdrojové kódy

A tiny bit more typing info

gm/2021-09-23T00Z/github.com--lark-parser-lark/1.0b
Erez Sh před 3 roky
rodič
revize
a8473e7e5d
2 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. +1
    -1
      lark/lexer.py
  2. +3
    -1
      lark/parse_tree_builder.py

+ 1
- 1
lark/lexer.py Zobrazit soubor

@@ -184,7 +184,7 @@ class LineCounter:

return self.char_pos == other.char_pos and self.newline_char == other.newline_char

def feed(self, token, test_newline=True):
def feed(self, token: Token, test_newline=True):
"""Consume a token and calculate the new line & column.

As an optional optimization, set test_newline=False if token doesn't contain a newline.


+ 3
- 1
lark/parse_tree_builder.py Zobrazit soubor

@@ -1,3 +1,5 @@
from typing import List

from .exceptions import GrammarError, ConfigurationError
from .lexer import Token
from .tree import Tree
@@ -151,7 +153,7 @@ def _should_expand(sym):
return not sym.is_term and sym.name.startswith('_')


def maybe_create_child_filter(expansion, keep_all_tokens, ambiguous, _empty_indices: list):
def maybe_create_child_filter(expansion, keep_all_tokens, ambiguous, _empty_indices: List[bool]):
# Prepare empty_indices as: How many Nones to insert at each index?
if _empty_indices:
assert _empty_indices.count(False) == len(expansion)


Načítá se…
Zrušit
Uložit