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
3d660ec8
Commit
3d660ec8
authored
May 06, 2019
by
di68kap
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- MLWCompiler.py: Weitere Schönheitsfehler korrigiert
parent
8dd3f2de
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
DHParser/compile.py
DHParser/compile.py
+16
-3
DHParser/configuration.py
DHParser/configuration.py
+11
-0
No files found.
DHParser/compile.py
View file @
3d660ec8
...
...
@@ -43,7 +43,7 @@ from DHParser.transform import TransformationFunc
from
DHParser.parse
import
Grammar
from
DHParser.error
import
adjust_error_locations
,
is_error
,
is_fatal
,
Error
from
DHParser.log
import
log_parsing_history
,
log_ST
,
is_logging
,
logfile_basename
from
DHParser.toolkit
import
load_if_file
from
DHParser.toolkit
import
load_if_file
,
get_config_value
__all__
=
(
'CompilerError'
,
...
...
@@ -107,6 +107,12 @@ class Compiler:
_dirty_flag: A flag indicating that the compiler has already been
called at least once and that therefore all compilation
variables must be reset when it is called again.
_debug: A flag indicating that debugging is turned on the value
for this flag is read before each call of the configuration
(see debugging section in DHParser.configuration)
If debugging is turned on the compiler class raises en
error if a node is attempted to be compiled twice.
_debug_already_compiled: A set of nodes that have already been compiled.
"""
def
__init__
(
self
):
...
...
@@ -118,6 +124,8 @@ class Compiler:
self
.
context
=
[]
# type: List[Node]
self
.
_None_check
=
True
# type: bool
self
.
_dirty_flag
=
False
self
.
_debug
=
get_config_value
(
'debug'
)
# type: bool
self
.
_debug_already_compiled
=
set
()
# type: Set[Node]
def
__call__
(
self
,
root
:
RootNode
)
->
Any
:
"""
...
...
@@ -151,8 +159,9 @@ class Compiler:
"""This is a generic compiler function which will be called on
all those node types for which no compiler method `on_XXX` has
been defined."""
if
node
.
children
:
node
.
result
=
tuple
(
self
.
compile
(
nd
)
for
nd
in
node
.
children
)
children
=
node
.
children
if
children
:
node
.
result
=
tuple
(
self
.
compile
(
nd
)
for
nd
in
children
)
return
node
def
compile
(
self
,
node
:
Node
)
->
Any
:
...
...
@@ -168,6 +177,10 @@ class Compiler:
for the parsers of the sub nodes by itself. Rather, this should
be done within the compilation methods.
"""
if
self
.
_debug
:
assert
node
not
in
self
.
_debug_already_compiled
self
.
_debug_already_compiled
.
add
(
node
)
elem
=
node
.
tag_name
if
elem
.
startswith
(
':'
):
elem
=
elem
[
1
:]
...
...
DHParser/configuration.py
View file @
3d660ec8
...
...
@@ -162,6 +162,17 @@ CONFIG_PRESET['server_default_host'] = "127.0.0.1"
CONFIG_PRESET
[
'server_default_port'
]
=
8888
########################################################################
#
# debugging support configuration
#
########################################################################
# Turn on (costly) debugging functionality.
# Default value: True
CONFIG_PRESET
[
'debug'
]
=
True
########################################################################
#
# testing framework configuration
...
...
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