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
4fdc2673
Commit
4fdc2673
authored
May 10, 2021
by
Eckhart Arnold
Browse files
Merge branch 'development' of
https://gitlab.lrz.de/badw-it/DHParser
into development
# Conflicts: # DHParser/ebnf.py
parents
daf0ac66
faf6b810
Changes
4
Hide whitespace changes
Inline
Side-by-side
DHParser/syntaxtree.py
View file @
4fdc2673
...
...
@@ -1379,8 +1379,7 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
items
=
tuple
(
child
for
child
in
self
.
_children
if
mf
(
child
))
if
items
:
return
items
if
len
(
items
)
>=
2
else
items
[
0
]
raise
IndexError
(
'index out of range'
)
if
isinstance
(
key
,
int
)
\
else
KeyError
(
str
(
key
))
raise
IndexError
(
'index out of range'
)
if
isinstance
(
key
,
int
)
else
KeyError
(
str
(
key
))
def
__delitem__
(
self
,
key
:
Union
[
int
,
slice
,
CriteriaType
]):
"""
...
...
DHParser/toolkit.py
View file @
4fdc2673
...
...
@@ -75,8 +75,10 @@ __all__ = ('typing',
'ThreadLocalSingletonFactory'
,
'RX_NEVER_MATCH'
,
'RX_ENTITY'
,
'RX_NON_ASCII'
,
'validate_XML_attribute_value'
,
'fix_XML_attribute_value'
,
'fix_lxml_attribute_value'
,
'RxPatternType'
,
're_find'
,
'escape_re'
,
...
...
@@ -574,7 +576,7 @@ def validate_XML_attribute_value(value: Any) -> str:
def
fix_XML_attribute_value
(
value
:
Any
)
->
str
:
"""Returns the quote
s
XML-attribute value. In case the values
"""Returns the quote
d
XML-attribute value. In case the values
contains illegal characters, like '<', these will be replaced by
XML-entities."""
value
=
str
(
value
)
...
...
@@ -593,6 +595,22 @@ def fix_XML_attribute_value(value: Any) -> str:
return
value
RX_NON_ASCII
=
re
.
compile
(
r
'[^\U00000000-\U00000100]'
)
def
lxml_XML_attribute_value
(
value
:
Any
)
->
str
:
"""Makes sure that the attribute value works with the lxml-library,
at the cost of replacing all characters with a code > 256 by
a quesiton mark.
:param value: the original attribute value
:return: the quoted and lxml-compatible attribute value.
"""
value
=
str
(
value
)
value
=
RX_NON_ASCII
.
sub
(
'?'
,
value
)
return
fix_XML_attribute_value
(
value
)
#######################################################################
#
# type system support
...
...
examples/EBNF/grammar_examples/BNF.ebnf
0 → 100644
View file @
4fdc2673
@literalws = right
definitions = ~ definition { definition } EOF
definition = definiendum ":=" definiens
definiendum = word
definiens = word { word }
word = /[A-Z]?[a-z]*/
EOF = /$/
pyproject.toml
View file @
4fdc2673
...
...
@@ -53,7 +53,7 @@ packages = [
[tool.poetry.dependencies]
python
=
"^3.5"
regex
=
{
version
=
"
^2.5
"
,
optional
=
true
}
regex
=
{
version
=
"
*
"
,
optional
=
true
}
cython
=
{
version
=
"^0.29"
,
optional
=
true
}
...
...
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