Commit 0b2dd583 authored by Eckhart Arnold's avatar Eckhart Arnold

- compile.py - removed obsolete compile children method

parent d43a732c
......@@ -131,23 +131,23 @@ class Compiler:
result = self.compile(root)
return result
def compile_children(self, node: Node) -> StrictResultType:
"""Compiles all children of the given node and returns the tuple
of the compiled children or the node's (potentially empty) result
in case the node does not have any children.
"""
if node.children:
return tuple(self.compile(child) for child in node.children)
else:
return node.result
# Obsolete, because never used...
# def compile_children(self, node: Node) -> StrictResultType:
# """Compiles all children of the given node and returns the tuple
# of the compiled children or the node's (potentially empty) result
# in case the node does not have any children.
# """
# if node.children:
# return tuple(self.compile(child) for child in node.children)
# else:
# return node.result
def fallback_compiler(self, node: Node) -> Any:
"""This is a generic compiler function which will be called on
all those node types for which no compiler method `on_XXX` has
been defined."""
if node.children:
result = tuple(self.compile(nd) for nd in node.children)
node.result = result
node.result = tuple(self.compile(nd) for nd in node.children)
return node
def compile(self, node: Node) -> Any:
......@@ -253,7 +253,7 @@ def compile_source(source: str,
# which could (fatally) break AST transformations.
try:
transformer(syntax_tree)
except Excpetion as e:
except Exception as e:
syntax_tree.new_error(syntax_tree,
"AST-Transformation failed due to earlier parser errors. "
"Crash Message: " + str(e), Error.AST_TRANSFORM_CRASH)
......
......@@ -573,7 +573,7 @@ class XMLCompiler(Compiler):
node.attr.update(attributes)
preserve_whitespace |= attributes.get('xml:space', '') == 'preserve'
node.tag_name = tag_name
content = self.compile_children(node.get('content', PLACEHOLDER))
content = tuple(self.compile(nd) for nd in node.get('content', PLACEHOLDER).children)
if len(content) == 1:
if content[0].tag_name == "CharData":
# reduce single CharData children
......
<?xml version="1.0" encoding="UTF-8"?>
<note date="2018-06-14">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body> Don't forget me this weekend! </body>
<priority level="high" />
Some Mixed Content...
</note>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment