Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
DHParser
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
badw-it
DHParser
Commits
08ea3533
Commit
08ea3533
authored
Feb 18, 2019
by
di68kap
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- DHParser/parse.py ParserError bugfix
parent
4bff4c28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
DHParser/parse.py
DHParser/parse.py
+8
-4
test/test_parse.py
test/test_parse.py
+7
-1
No files found.
DHParser/parse.py
View file @
08ea3533
...
...
@@ -307,7 +307,7 @@ class Parser:
# apply reentry-rule or catch error at root-parser
if
i
<
0
:
i
=
1
nd
=
Node
(
ZOMBIE_TAG
,
rest
[:
i
])
nd
=
Node
(
ZOMBIE_TAG
,
rest
[:
i
])
.
with_pos
(
location
)
rest
=
rest
[
i
:]
assert
error
.
node
.
children
or
(
not
error
.
node
.
result
)
if
error
.
first_throw
:
...
...
@@ -316,15 +316,19 @@ class Parser:
else
:
# TODO: ggf. Fehlermeldung, die sagt, wo es weitergeht anfügen
# dürfte allerdings erst an den nächsten(!) Knoten angehängt werden (wie?)
node
=
Node
(
self
.
tag_name
,
(
Node
(
ZOMBIE_TAG
,
text
[:
gap
]),
error
.
node
,
nd
))
node
=
Node
(
self
.
tag_name
,
(
Node
(
ZOMBIE_TAG
,
text
[:
gap
]).
with_pos
(
location
),
error
.
node
,
nd
))
elif
error
.
first_throw
:
raise
ParserError
(
error
.
node
,
error
.
rest
,
first_throw
=
False
)
else
:
result
=
(
Node
(
ZOMBIE_TAG
,
text
[:
gap
]),
error
.
node
)
if
gap
else
error
.
node
# type: ResultType
result
=
(
Node
(
ZOMBIE_TAG
,
text
[:
gap
]).
with_pos
(
location
),
error
.
node
)
if
gap
\
else
error
.
node
# type: ResultType
if
grammar
.
tree__
.
errors
[
-
1
].
code
==
Error
.
MANDATORY_CONTINUATION_AT_EOF
:
# EXPERIMENTAL!!
node
=
error
.
node
else
:
raise
ParserError
(
Node
(
self
.
tag_name
,
result
),
text
,
first_throw
=
False
)
raise
ParserError
(
Node
(
self
.
tag_name
,
result
).
with_pos
(
location
),
text
,
first_throw
=
False
)
if
grammar
.
left_recursion_handling__
:
...
...
test/test_parse.py
View file @
08ea3533
...
...
@@ -27,15 +27,21 @@ sys.path.extend(['../', './'])
from
DHParser.toolkit
import
compile_python_object
,
get_config_value
,
set_config_value
from
DHParser.log
import
logging
,
is_logging
,
log_ST
,
log_parsing_history
from
DHParser.error
import
Error
,
is_error
from
DHParser.parse
import
Parser
,
Grammar
,
Forward
,
TKN
,
ZeroOrMore
,
RE
,
\
from
DHParser.parse
import
Parser
Error
,
Parser
,
Grammar
,
Forward
,
TKN
,
ZeroOrMore
,
RE
,
\
RegExp
,
Lookbehind
,
NegativeLookahead
,
OneOrMore
,
Series
,
Alternative
,
AllOf
,
SomeOf
,
\
UnknownParserError
,
MetaParser
,
GrammarError
,
EMPTY_NODE
from
DHParser
import
compile_source
from
DHParser.ebnf
import
get_ebnf_grammar
,
get_ebnf_transformer
,
get_ebnf_compiler
,
DHPARSER_IMPORTS
from
DHParser.dsl
import
grammar_provider
,
CompilationError
from
DHParser.syntaxtree
import
Node
from
DHParser.stringview
import
StringView
class
TestParserError
:
def
test_parser_error_str
(
self
):
pe
=
ParserError
(
Node
(
'TAG'
,
'test'
).
with_pos
(
0
),
StringView
(
'Beispiel'
),
True
)
assert
str
(
pe
).
find
(
'Beispiel'
)
>=
0
and
str
(
pe
).
find
(
'TAG'
)
>=
0
class
TestParserClass
:
def
test_apply
(
self
):
minilang
=
"""
...
...
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