Commit 05cb32cd authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

- slight adjustments

parent 9e1686d9
...@@ -1006,8 +1006,9 @@ class EBNFCompiler(Compiler): ...@@ -1006,8 +1006,9 @@ class EBNFCompiler(Compiler):
elif key == 'drop': elif key == 'drop':
check_argnum(2) check_argnum(2)
for child in node.children[1:]: for child in node.children[1:]:
node_type = child.content.lower() content = child.content
assert node_type in DROP_VALUES, child.content node_type = content.lower()
assert node_type in DROP_VALUES, content
self.directives[key].add(node_type) self.directives[key].add(node_type)
elif key == 'ignorecase': elif key == 'ignorecase':
...@@ -1190,8 +1191,8 @@ class EBNFCompiler(Compiler): ...@@ -1190,8 +1191,8 @@ class EBNFCompiler(Compiler):
if len(symlist) == 1: if len(symlist) == 1:
nd = symlist[0].children[1] nd = symlist[0].children[1]
break break
if (nd.tag_name != "regexp" or nd.content[:1] != '/' content = nd.content
or nd.content[-1:] != '/'): if (nd.tag_name != "regexp" or content[:1] != '/' or content[-1:] != '/'):
self.tree.new_error(node, "Lookbehind-parser can only be used with RegExp" self.tree.new_error(node, "Lookbehind-parser can only be used with RegExp"
"-parsers, not: " + nd.tag_name) "-parsers, not: " + nd.tag_name)
......
...@@ -198,9 +198,10 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil ...@@ -198,9 +198,10 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
errors = root.errors_sorted errors = root.errors_sorted
if errors: if errors:
e_pos = errors[0].pos e_pos = errors[0].pos
return self.content[:e_pos] + \ content = self.content
return content[:e_pos] + \
' <<< Error on "%s" | %s >>> ' % \ ' <<< Error on "%s" | %s >>> ' % \
(self.content[e_pos - self.pos:], '; '.join(e.message for e in errors)) (content[e_pos - self.pos:], '; '.join(e.message for e in errors))
return self.content return self.content
def __repr__(self): def __repr__(self):
...@@ -376,8 +377,8 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil ...@@ -376,8 +377,8 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
""" """
return ''.join(self._content()) return ''.join(self._content())
## unoptimized ## unoptimized
# return "".join(child.content for child in self.children) if self.children else str( # return "".join(child.content for child in self.children) if self.children \
# self._result) # else str(self._result)
## obsolete ## obsolete
# if self._content is None: # if self._content is None:
# if self.children: # if self.children:
......
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