Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-fplo
Commits
7d772581
Commit
7d772581
authored
Nov 06, 2016
by
Henning Glawe
Browse files
add special case root blocks for concrete/abstract syntax trees
parent
00cb6c27
Changes
1
Hide whitespace changes
Inline
Side-by-side
parser/parser-fplo/FploInputParser.py
View file @
7d772581
...
...
@@ -260,6 +260,10 @@ class AST_block(AST_node):
self
.
append
(
src_child
)
class
AST_root
(
AST_block
):
pass
class
AST_section
(
AST_block
):
"""section block (sequence of statements) in AST"""
def
declaration_nomadmetainfo
(
self
,
output_file
,
namespace
):
...
...
@@ -568,6 +572,20 @@ class concrete_block(concrete_node):
return
self
.
items
[
0
].
flag_names_values
()
class
concrete_root
(
concrete_block
):
def
to_AST
(
self
):
if
len
(
self
.
items
)
<
1
:
return
None
result
=
AST_root
()
for
item
in
self
.
items
:
item_AST
=
item
.
to_AST
()
if
item_AST
is
not
None
:
result
.
append
(
item_AST
)
if
len
(
result
)
is
not
None
:
return
result
return
None
class
concrete_subscript
(
concrete_statement
):
def
__str__
(
self
):
result
=
(
...
...
@@ -612,7 +630,7 @@ class FploInputParser(object):
self
.
__annotateFile
=
annotateFile
self
.
bad_input
=
False
# start with root block, and add empty statement to append to
self
.
concrete_statements
=
concrete_
block
(
None
)
self
.
concrete_statements
=
concrete_
root
(
None
)
self
.
concrete_statements
.
append
(
concrete_statement
(
self
.
concrete_statements
))
self
.
current_concrete_statement
=
self
.
concrete_statements
.
items
[
-
1
]
...
...
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