Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
4b9b6c8a
Commit
4b9b6c8a
authored
Jul 10, 2018
by
di68kap
Browse files
- bugs fixed in parse.py
- LOGGING constant at the beginning of dhparser added
parent
25628e0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
DHParser/parse.py
View file @
4b9b6c8a
...
...
@@ -1252,10 +1252,7 @@ class Option(UnaryOperator):
super
().
__init__
(
parser
)
# assert isinstance(parser, Parser)
assert
not
isinstance
(
parser
,
Option
),
\
"Redundant nesting of options: %s(%s)"
%
(
str
(
name
),
str
(
parser
.
name
))
# assert not isinstance(parser, Required), \
# "Nesting options with required elements is contradictory: " \
# "%s(%s)" % (str(name), str(parser.name))
"Redundant nesting of options: %s"
%
(
str
(
self
.
ptype
),
str
(
parser
.
name
))
def
__call__
(
self
,
text
:
StringView
)
->
Tuple
[
Optional
[
Node
],
StringView
]:
node
,
text
=
self
.
parser
(
text
)
...
...
@@ -1334,7 +1331,7 @@ class OneOrMore(UnaryOperator):
super
().
__init__
(
parser
)
assert
not
isinstance
(
parser
,
Option
),
\
"Use ZeroOrMore instead of nesting OneOrMore and Option: "
\
"%s(%s)"
%
(
str
(
nam
e
),
str
(
parser
.
name
))
"%s(%s)"
%
(
str
(
self
.
ptyp
e
),
str
(
parser
.
name
))
def
__call__
(
self
,
text
:
StringView
)
->
Tuple
[
Optional
[
Node
],
StringView
]:
results
=
()
# type: Tuple[Node, ...]
...
...
dhparser.py
View file @
4b9b6c8a
...
...
@@ -29,6 +29,8 @@ from DHParser.ebnf import get_ebnf_grammar, get_ebnf_transformer, get_ebnf_compi
from
DHParser.log
import
logging
from
DHParser.toolkit
import
re
LOGGING
=
True
dhparserdir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
EBNF_TEMPLATE
=
r
"""-grammar
...
...
@@ -325,7 +327,7 @@ def main():
print
(
'File %s not found! Aborting.'
%
file_path
)
sys
.
exit
(
1
)
elif
choice
.
strip
()
==
'3'
:
with
logging
(
False
):
with
logging
(
LOGGING
):
if
not
cpu_profile
(
selftest
,
1
):
print
(
"Selftest FAILED :-(
\n
"
)
sys
.
exit
(
1
)
...
...
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