Przeglądaj źródła

Transformers now visit tokens by default

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.8.0
Erez Shinan 4 lat temu
rodzic
commit
175c403830
1 zmienionych plików z 4 dodań i 4 usunięć
  1. +4
    -4
      lark/visitors.py

+ 4
- 4
lark/visitors.py Wyświetl plik

@@ -22,8 +22,8 @@ class Transformer:
Can be used to implement map or reduce.
"""

__visit_tokens__ = False # For backwards compatibility
def __init__(self, visit_tokens=False):
__visit_tokens__ = True # For backwards compatibility
def __init__(self, visit_tokens=True):
self.__visit_tokens__ = visit_tokens

def _call_userfunc(self, tree, new_children=None):
@@ -189,7 +189,7 @@ class Visitor(VisitorBase):
def visit_topdown(self,tree):
for subtree in tree.iter_subtrees_topdown():
self._call_userfunc(subtree)
return tree
return tree

class Visitor_Recursive(VisitorBase):
"""Bottom-up visitor, recursive
@@ -212,7 +212,7 @@ class Visitor_Recursive(VisitorBase):
for child in tree.children:
if isinstance(child, Tree):
self.visit_topdown(child)
return tree




Ładowanie…
Anuluj
Zapisz