Преглед на файлове

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 години
committed by GitHub
родител
ревизия
605b948a6b
No known key found for this signature in database GPG ключ ID: 4AEE18F83AFDEB23
променени са 2 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. +2
    -1
      lark-stubs/reconstruct.pyi
  2. +2
    -2
      lark/reconstruct.py

+ 2
- 1
lark-stubs/reconstruct.pyi Целия файл

@@ -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 Целия файл

@@ -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


Зареждане…
Отказ
Запис