Commit 9d829062 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files better compilation of SomeOf, AllOf parsers

parent f53a902c
......@@ -829,8 +829,17 @@ class EBNFCompiler(Compiler):
"AST transformation!")
def on_unordered(self, node) -> str:
# TODO: implementation must support AllOf as well as SomeOf
return self.non_terminal(node, 'Unordered')
# return self.non_terminal(node, 'Unordered')
assert len(node.children) == 1
nd = node.children[0]
args = ', '.join(self.compile(r) for r in nd.children)
if == "term":
return "AllOf(" + args + ")"
elif == "expression":
return "SomeOf(" + args + ")"
node.add_error("Unordered sequence or alternative requires at least two elements.")
return ""
def on_symbol(self, node: Node) -> str: # called only for symbols on the right hand side!
symbol = str(node) # ; assert result == cast(str, node.result)
import cython
# type hints for Cython python -> C compiler
# type hints for Cython python -> C compiler to speed up the most
# critical code paths of
cdef int first_char(text, int begin, int end)
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