1.1 --- a/pyparser/pyparse.py Sun Jan 08 20:20:39 2017 +0100
1.2 +++ b/pyparser/pyparse.py Sun Jan 08 21:15:30 2017 +0100
1.3 @@ -161,6 +161,9 @@
1.4 self.root = None
1.5 if enc is not None:
1.6 compile_info.encoding = enc
1.7 + # Wrap the tree in a special encoding declaration for parser module
1.8 + # compatibility.
1.9 + tree = parser.NonterminalEnc(pygram.syms.encoding_decl, tree, enc)
1.10 return tree
1.11
1.12 def parse(filename):
1.13 @@ -188,6 +191,8 @@
1.14 l = [tree.type]
1.15 for i in range(0, tree.num_children()):
1.16 l.append(st2tuple(tree.get_child(i)))
1.17 + if isinstance(tree, parser.NonterminalEnc):
1.18 + l.append(tree.encoding)
1.19 return tuple(l)
1.20 elif isinstance(tree, parser.Terminal):
1.21 l = [tree.type, tree.value]