@@ -106,7 +106,7 @@ class Callback(object): | |||||
pass | pass | ||||
def inline_args(func): | |||||
def ptb_inline_args(func): | |||||
@wraps(func) | @wraps(func) | ||||
def f(children): | def f(children): | ||||
return func(*children) | return func(*children) | ||||
@@ -154,7 +154,7 @@ class ParseTreeBuilder: | |||||
assert not getattr(f, 'meta', False), "Meta args not supported for internal transformer" | assert not getattr(f, 'meta', False), "Meta args not supported for internal transformer" | ||||
# XXX InlineTransformer is deprecated! | # XXX InlineTransformer is deprecated! | ||||
if getattr(f, 'inline', False) or isinstance(transformer, InlineTransformer): | if getattr(f, 'inline', False) or isinstance(transformer, InlineTransformer): | ||||
f = inline_args(f) | |||||
f = ptb_inline_args(f) | |||||
except AttributeError: | except AttributeError: | ||||
f = partial(self.tree_class, user_callback_name) | f = partial(self.tree_class, user_callback_name) | ||||
@@ -56,6 +56,7 @@ EXTRACT_STANDALONE_FILES = [ | |||||
'utils.py', | 'utils.py', | ||||
'common.py', | 'common.py', | ||||
'tree.py', | 'tree.py', | ||||
'visitors.py', | |||||
'indenter.py', | 'indenter.py', | ||||
'lexer.py', | 'lexer.py', | ||||
'parse_tree_builder.py', | 'parse_tree_builder.py', | ||||
@@ -161,7 +162,7 @@ class TreeBuilderAtoms: | |||||
self.ptb = lark._parse_tree_builder | self.ptb = lark._parse_tree_builder | ||||
def print_python(self): | def print_python(self): | ||||
print('class InlineTransformer: pass') | |||||
# print('class InlineTransformer: pass') | |||||
print('RULES = {') | print('RULES = {') | ||||
for i, r in enumerate(self.rules): | for i, r in enumerate(self.rules): | ||||
rule_ids[r] = i | rule_ids[r] = i | ||||
@@ -73,6 +73,7 @@ def smart_decorator(f, create_decorator): | |||||
return create_decorator(f.__func__.__call__, True) | return create_decorator(f.__func__.__call__, True) | ||||
###} | |||||
try: | try: | ||||
@@ -93,7 +94,6 @@ except ImportError: | |||||
except excs: | except excs: | ||||
pass | pass | ||||
###} | |||||
@@ -1,13 +1,14 @@ | |||||
from inspect import getmembers, getmro | |||||
from functools import wraps | from functools import wraps | ||||
from .utils import smart_decorator | from .utils import smart_decorator | ||||
from .tree import Tree | from .tree import Tree | ||||
###{standalone | |||||
from inspect import getmembers, getmro | |||||
class Discard(Exception): | class Discard(Exception): | ||||
pass | pass | ||||
# Transformers | # Transformers | ||||
class Transformer: | class Transformer: | ||||
@@ -250,3 +251,4 @@ def v_args(inline=False, meta=False, tree=False): | |||||
return _visitor_args_dec | return _visitor_args_dec | ||||
###} |