Commit 02ed4a39 authored by di68kap's avatar di68kap

- MLW-Fehlerkorrekturen

parent 3671bcc5
......@@ -164,6 +164,7 @@ class StringView: # collections.abc.Sized
return StringView(self._text, self._begin + start, self._begin + stop)
except AttributeError:
return StringView(self._text, self._begin + index, self._begin + index + 1)
# return self._text[self._begin + index] # leads to type errors
def get_text(self) -> str:
"""Returns the underlying string."""
......
......@@ -538,7 +538,7 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
def index(self, what: CriteriaType, start: int = 0, stop: int = sys.maxsize) -> int:
"""
Returns the first index of the child that fulfills the criteriuon
Returns the first index of the child that fulfills the criterion
`what`. If the parameters start and stop are given, the search is
restricted to the children with indices from the half-open interval
[start:end[. If no such child exists a ValueError is raised.
......@@ -1174,6 +1174,10 @@ def parse_sxpr(sxpr: Union[str, StringView]) -> Node:
level = 1
k = 1
while level > 0:
if s[k] in ("'", '"'):
k = s.find(str(s[k]), k+1)
if k < 0:
raise IndexError()
if s[k] == '(':
level += 1
elif s[k] == ')':
......
......@@ -332,7 +332,12 @@ class TestNodeFind:
class TestSerialization:
def test_sxpr_roundtrip(self):
pass
sxpr = ('(BelegText (Anker "interdico_1") (BelegLemma "inter.|ticente") (TEXT ", (") '
'(Anker "interdico_2") (BelegLemma "inter.|titente") (L " ") (Zusatz "var. l.") '
'(TEXT ") Deo."))')
tree = parse_sxpr(sxpr)
assert flatten_sxpr(tree.as_sxpr()) == sxpr
def test_sexpr_attributes(self):
tree = parse_sxpr('(A "B")')
......
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