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
2a9bea38
Commit
2a9bea38
authored
Feb 14, 2019
by
di68kap
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- DHParser/compile.py Source code wird dem Compile-object beim Aufruf mit übergeben
parent
4ac99699
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
DHParser/compile.py
DHParser/compile.py
+7
-3
No files found.
DHParser/compile.py
View file @
2a9bea38
...
...
@@ -97,6 +97,8 @@ class Compiler:
Attributes:
context: A list of parent nodes that ends with the currently
compiled node.
tree: The root of the abstract syntax tree.
source: The source code.
_dirty_flag: A flag indicating that the compiler has already been
called at least once and that therefore all compilation
...
...
@@ -107,11 +109,12 @@ class Compiler:
self
.
_reset
()
def
_reset
(
self
):
self
.
source
=
''
self
.
tree
=
ROOTNODE_PLACEHOLDER
# type: RootNode
self
.
context
=
[]
# type: List[Node]
self
.
_dirty_flag
=
False
def
__call__
(
self
,
root
:
RootNode
)
->
Any
:
def
__call__
(
self
,
root
:
RootNode
,
source
:
str
=
''
)
->
Any
:
"""
Compiles the abstract syntax tree with the root node `node` and
returns the compiled code. It is up to subclasses implementing
...
...
@@ -123,7 +126,8 @@ class Compiler:
if
self
.
_dirty_flag
:
self
.
_reset
()
self
.
_dirty_flag
=
True
self
.
tree
=
root
self
.
tree
=
root
# type: Node
self
.
source
=
source
# type: str
result
=
self
.
compile
(
root
)
return
result
...
...
@@ -242,7 +246,7 @@ def compile_source(source: str,
if
not
is_error
(
syntax_tree
.
error_flag
):
if
preserve_ast
:
ast
=
copy
.
deepcopy
(
syntax_tree
)
result
=
compiler
(
syntax_tree
)
result
=
compiler
(
syntax_tree
,
original_text
)
# print(syntax_tree.as_sxpr())
# messages.extend(syntax_tree.errors())
# syntax_tree.error_flag = max(syntax_tree.error_flag, efl)
...
...
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