Skip to content

Commit 9905dc4

Browse files
committed
fix boolangery#11: no visitor found for class StringDelimiter
1 parent 3cbef8b commit 9905dc4

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

luaparser/printers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def visit(self, node):
3535
def visit(self, node):
3636
return str(node)
3737

38+
@visitor(Enum)
39+
def visit(self, node):
40+
return str(node.name)
41+
3842
def indent_str(self, newLine=True):
3943
res = ' ' * self.currentIndent
4044
if newLine:

luaparser/tests/test_integration.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from luaparser.utils import tests
1+
from luaparser.utils import tests
22
from luaparser import ast
33
from luaparser.astnodes import *
44
import textwrap
@@ -73,3 +73,47 @@ def test_cont_int_3(self):
7373
tree = ast.parse(textwrap.dedent(r'x.a'))
7474
exp = Chunk(Block([Index(idx=Name('a'), value=Name('x'))]))
7575
self.assertEqual(exp, tree)
76+
77+
# luaparser.utils.visitor.VisitorException: No visitor found for class <enum 'StringDelimiter'> #11
78+
def test_cont_int_4(self):
79+
tree = ast.parse(textwrap.dedent(r'''
80+
local function sayHello()
81+
print('hello world !')
82+
end
83+
sayHello()
84+
'''))
85+
pretty_str = ast.to_pretty_str(tree)
86+
exp = textwrap.dedent(r'''
87+
Chunk: {} 4 keys
88+
body: {} 4 keys
89+
Block: {} 4 keys
90+
body: [] 2 items
91+
0: {} 1 key
92+
LocalFunction: {} 6 keys
93+
start_char: 1
94+
stop_char: 56
95+
name: {} 4 keys
96+
Name: {} 4 keys
97+
id: 'sayHello'
98+
args: [] 0 item
99+
body: {} 4 keys
100+
Block: {} 4 keys
101+
stop_char: 56
102+
body: [] 1 item
103+
0: {} 1 key
104+
Call: {} 5 keys
105+
func: {} 4 keys
106+
Name: {} 4 keys
107+
id: 'print'
108+
args: [] 1 item
109+
0: {} 1 key
110+
String: {} 5 keys
111+
s: 'hello world !'
112+
delimiter: SINGLE_QUOTE
113+
1: {} 1 key
114+
Call: {} 5 keys
115+
func: {} 4 keys
116+
Name: {} 4 keys
117+
id: 'sayHello'
118+
args: [] 0 item''')
119+
self.assertEqual(exp, pretty_str)

0 commit comments

Comments
 (0)