Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
05cb32cd
Commit
05cb32cd
authored
Feb 19, 2019
by
Eckhart Arnold
Browse files
- slight adjustments
parent
9e1686d9
Changes
2
Show whitespace changes
Inline
Side-by-side
DHParser/ebnf.py
View file @
05cb32cd
...
...
@@ -1006,8 +1006,9 @@ class EBNFCompiler(Compiler):
elif
key
==
'drop'
:
check_argnum
(
2
)
for
child
in
node
.
children
[
1
:]:
node_type
=
child
.
content
.
lower
()
assert
node_type
in
DROP_VALUES
,
child
.
content
content
=
child
.
content
node_type
=
content
.
lower
()
assert
node_type
in
DROP_VALUES
,
content
self
.
directives
[
key
].
add
(
node_type
)
elif
key
==
'ignorecase'
:
...
...
@@ -1190,8 +1191,8 @@ class EBNFCompiler(Compiler):
if
len
(
symlist
)
==
1
:
nd
=
symlist
[
0
].
children
[
1
]
break
if
(
nd
.
tag_name
!=
"regexp"
or
nd
.
content
[:
1
]
!=
'/'
or
nd
.
content
[
-
1
:]
!=
'/'
):
content
=
nd
.
content
if
(
nd
.
tag_name
!=
"regexp"
or
content
[:
1
]
!=
'/'
or
content
[
-
1
:]
!=
'/'
):
self
.
tree
.
new_error
(
node
,
"Lookbehind-parser can only be used with RegExp"
"-parsers, not: "
+
nd
.
tag_name
)
...
...
DHParser/syntaxtree.py
View file @
05cb32cd
...
...
@@ -198,9 +198,10 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
errors
=
root
.
errors_sorted
if
errors
:
e_pos
=
errors
[
0
].
pos
return
self
.
content
[:
e_pos
]
+
\
content
=
self
.
content
return
content
[:
e_pos
]
+
\
' <<< 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
def
__repr__
(
self
):
...
...
@@ -376,8 +377,8 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
"""
return
''
.
join
(
self
.
_content
())
## unoptimized
# return "".join(child.content for child in self.children) if self.children
else str(
# self._result)
# return "".join(child.content for child in self.children) if self.children
\
#
else str(
self._result)
## obsolete
# if self._content is None:
# if self.children:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment