Przeglądaj źródła

Merge pull request #921 from MegaIng/reconstructor-fixes

Update reconstruct.pyi + add insert_spaces
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.12.0
Erez Shinan 3 lat temu
committed by GitHub
rodzic
commit
605b948a6b
Nie znaleziono w bazie danych klucza dla tego podpisu ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 4 dodań i 3 usunięć
  1. +2
    -1
      lark-stubs/reconstruct.pyi
  2. +2
    -2
      lark/reconstruct.py

+ 2
- 1
lark-stubs/reconstruct.pyi Wyświetl plik

@@ -34,5 +34,6 @@ class Reconstructor:
def __init__(self, parser: Lark, term_subs: Dict[str, Callable[[Symbol], str]] = ...):
...

def reconstruct(self, tree: Tree, postproc: Callable[[Iterable[str]], Iterable[str]]) -> str:
def reconstruct(self, tree: Tree, postproc: Callable[[Iterable[str]], Iterable[str]]=None,
insert_spaces: bool = True) -> str:
...

+ 2
- 2
lark/reconstruct.py Wyświetl plik

@@ -87,14 +87,14 @@ class Reconstructor(TreeMatcher):
else:
yield item

def reconstruct(self, tree, postproc=None):
def reconstruct(self, tree, postproc=None, insert_spaces=True):
x = self._reconstruct(tree)
if postproc:
x = postproc(x)
y = []
prev_item = ''
for item in x:
if prev_item and item and is_id_continue(prev_item[-1]) and is_id_continue(item[0]):
if insert_spaces and prev_item and item and is_id_continue(prev_item[-1]) and is_id_continue(item[0]):
y.append(' ')
y.append(item)
prev_item = item


Ładowanie…
Anuluj
Zapisz