11.08., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

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: ...@@ -131,23 +131,23 @@ class Compiler:
result = self.compile(root) result = self.compile(root)
return result return result
def compile_children(self, node: Node) -> StrictResultType: # Obsolete, because never used...
"""Compiles all children of the given node and returns the tuple # def compile_children(self, node: Node) -> StrictResultType:
of the compiled children or the node's (potentially empty) result # """Compiles all children of the given node and returns the tuple
in case the node does not have any children. # 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) # if node.children:
else: # return tuple(self.compile(child) for child in node.children)
return node.result # else:
# return node.result
def fallback_compiler(self, node: Node) -> Any: def fallback_compiler(self, node: Node) -> Any:
"""This is a generic compiler function which will be called on """This is a generic compiler function which will be called on
all those node types for which no compiler method `on_XXX` has all those node types for which no compiler method `on_XXX` has
been defined.""" been defined."""
if node.children: if node.children:
result = tuple(self.compile(nd) for nd in node.children) node.result = tuple(self.compile(nd) for nd in node.children)
node.result = result
return node return node
def compile(self, node: Node) -> Any: def compile(self, node: Node) -> Any:
...@@ -253,7 +253,7 @@ def compile_source(source: str, ...@@ -253,7 +253,7 @@ def compile_source(source: str,
# which could (fatally) break AST transformations. # which could (fatally) break AST transformations.
try: try:
transformer(syntax_tree) transformer(syntax_tree)
except Excpetion as e: except Exception as e:
syntax_tree.new_error(syntax_tree, syntax_tree.new_error(syntax_tree,
"AST-Transformation failed due to earlier parser errors. " "AST-Transformation failed due to earlier parser errors. "
"Crash Message: " + str(e), Error.AST_TRANSFORM_CRASH) "Crash Message: " + str(e), Error.AST_TRANSFORM_CRASH)
......
...@@ -573,7 +573,7 @@ class XMLCompiler(Compiler): ...@@ -573,7 +573,7 @@ class XMLCompiler(Compiler):
node.attr.update(attributes) node.attr.update(attributes)
preserve_whitespace |= attributes.get('xml:space', '') == 'preserve' preserve_whitespace |= attributes.get('xml:space', '') == 'preserve'
node.tag_name = tag_name 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 len(content) == 1:
if content[0].tag_name == "CharData": if content[0].tag_name == "CharData":
# reduce single CharData children # 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