Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
badw-it
DHParser
Commits
8e4dc4c5
Commit
8e4dc4c5
authored
Feb 20, 2019
by
eckhart
Browse files
- parse.py: Token, Regexp: Return EMPTY_NODE if content is empty string
parent
66c0d7a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
DHParser/error.py
View file @
8e4dc4c5
...
...
@@ -88,7 +88,6 @@ class Error:
MALFORMED_ERROR_STRING
=
ErrorCode
(
1060
)
AMBIGUOUS_ERROR_HANDLING
=
ErrorCode
(
1070
)
REDEFINED_DIRECTIVE
=
ErrorCode
(
1080
)
# INFINITE_LOOP = ErrorCode(1090)
def
__init__
(
self
,
message
:
str
,
pos
,
code
:
ErrorCode
=
ERROR
,
orig_pos
:
int
=
-
1
,
line
:
int
=
-
1
,
column
:
int
=
-
1
)
->
None
:
...
...
DHParser/parse.py
View file @
8e4dc4c5
...
...
@@ -1198,7 +1198,9 @@ class Token(Parser):
def
_parse
(
self
,
text
:
StringView
)
->
Tuple
[
Optional
[
Node
],
StringView
]:
if
text
.
startswith
(
self
.
text
):
return
Node
(
self
.
tag_name
,
self
.
text
,
True
),
text
[
self
.
len
:]
if
self
.
text
or
self
.
pname
:
return
Node
(
self
.
tag_name
,
self
.
text
,
True
),
text
[
self
.
len
:]
return
EMPTY_NODE
,
text
[
0
:]
return
None
,
text
def
__repr__
(
self
):
...
...
@@ -1257,8 +1259,11 @@ class RegExp(Parser):
match
=
text
.
match
(
self
.
regexp
)
if
match
:
capture
=
match
.
group
(
0
)
end
=
text
.
index
(
match
.
end
())
return
Node
(
self
.
tag_name
,
capture
,
True
),
text
[
end
:]
if
capture
or
self
.
pname
:
end
=
text
.
index
(
match
.
end
())
return
Node
(
self
.
tag_name
,
capture
,
True
),
text
[
end
:]
assert
text
.
index
(
match
.
end
())
==
0
return
EMPTY_NODE
,
text
[
0
:]
return
None
,
text
def
__repr__
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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