Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenGEODE
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
TASTE
OpenGEODE
Commits
940f237b
Commit
940f237b
authored
Jun 11, 2014
by
Maxime Perrotin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with procedure scope
parent
a1bf4b96
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
19 deletions
+22
-19
AdaGenerator.py
AdaGenerator.py
+8
-11
ogAST.py
ogAST.py
+1
-1
ogParser.py
ogParser.py
+12
-7
opengeode.py
opengeode.py
+1
-0
No files found.
AdaGenerator.py
View file @
940f237b
...
...
@@ -86,7 +86,6 @@ LOCAL_VAR = {}
# List of output signals and procedures
OUT_SIGNALS
=
[]
PROCEDURES
=
[]
INNER_PROCEDURES
=
[]
@
singledispatch
...
...
@@ -106,7 +105,6 @@ def _process(process):
TYPES
=
process
.
dataview
del
OUT_SIGNALS
[:]
del
PROCEDURES
[:]
del
INNER_PROCEDURES
[:]
OUT_SIGNALS
.
extend
(
process
.
output_signals
)
PROCEDURES
.
extend
(
process
.
procedures
)
...
...
@@ -120,7 +118,6 @@ def _process(process):
mapping
=
Helper
.
map_input_state
(
process
)
VARIABLES
.
update
(
process
.
variables
)
INNER_PROCEDURES
.
extend
(
process
.
content
.
inner_procedures
)
# Generate the code to declare process-level variables
process_level_decl
=
[]
...
...
@@ -303,8 +300,8 @@ package {process_name} is'''.format(process_name=process_name,
.
format
(
sig
=
signal
[
'name'
],
proc
=
process_name
))
# for the .ads file, generate the declaration of the external procedures
for
proc
in
process
.
procedures
:
ri_header
=
'procedure {sig_name}'
.
format
(
sig_name
=
proc
.
inputString
)
for
proc
in
(
proc
for
proc
in
process
.
procedures
if
proc
.
external
)
:
ri_header
=
u
'procedure {sig_name}'
.
format
(
sig_name
=
proc
.
inputString
)
params
=
[]
for
param
in
proc
.
fpar
:
typename
=
param
[
'type'
].
ReferencedTypeName
.
replace
(
'-'
,
'_'
)
...
...
@@ -517,15 +514,15 @@ def _call_external_function(output):
out_sig
,
=
[
sig
for
sig
in
OUT_SIGNALS
if
sig
[
'name'
].
lower
()
==
signal_name
.
lower
()]
except
ValueError
:
# Not an output, try if it is an external procedure
# Not an output, try if it is an external
or inner
procedure
try
:
out_sig
,
=
[
sig
for
sig
in
PROCEDURES
proc
,
=
[
sig
for
sig
in
PROCEDURES
if
sig
.
inputString
.
lower
()
==
signal_name
.
lower
()]
if
proc
.
external
:
out_sig
=
proc
except
ValueError
:
# Not external? Must be an inner procedure then.
# otherwise the parser would have barked
proc
,
=
[
sig
for
sig
in
INNER_PROCEDURES
if
sig
.
inputString
.
lower
()
==
signal_name
.
lower
()]
# Not there? Impossible, the parser would have barked
raise
ValueError
(
'Probably a bug - please report'
)
if
out_sig
:
list_of_params
=
[]
for
idx
,
param
in
enumerate
(
out
.
get
(
'params'
)
or
[]):
...
...
ogAST.py
View file @
940f237b
...
...
@@ -754,7 +754,7 @@ class Process(object):
# list of operators (not supported) and procedures
self
.
operators
=
{}
# list of Procedure (external procedures)
# list of Procedure (external
and inner
procedures)
self
.
procedures
=
[]
# The Mapping structure should be used for code generation backends
...
...
ogParser.py
View file @
940f237b
...
...
@@ -191,8 +191,6 @@ def valid_output(scope):
yield
proc
.
inputString
.
lower
()
for
special_op
in
SPECIAL_OPERATORS
:
yield
special_op
.
lower
()
for
inner_proc
in
scope
.
content
.
inner_procedures
:
yield
inner_proc
.
inputString
.
lower
()
def
get_interfaces
(
ast
,
process_name
):
...
...
@@ -369,8 +367,7 @@ def check_and_fix_op_params(op_name, expr_list, context):
break
else
:
# Procedures (inner and external)
for
inner_proc
in
(
context
.
content
.
inner_procedures
+
context
.
procedures
):
for
inner_proc
in
context
.
procedures
:
key
=
inner_proc
.
inputString
if
key
.
lower
()
==
op_name
.
lower
():
signature
=
inner_proc
.
fpar
...
...
@@ -1391,6 +1388,8 @@ def composite_state(root, parent=None, context=None):
elif
new_proc
.
inputString
.
strip
().
lower
()
==
'exit'
:
comp
.
exit_procedure
=
new_proc
comp
.
content
.
inner_procedures
.
append
(
new_proc
)
# Add procedure to the context, to make it visible at scope level
context
.
procedures
.
append
(
new_proc
)
elif
child
.
type
==
lexer
.
COMPOSITE_STATE
:
inner_composite
.
append
(
child
)
elif
child
.
type
==
lexer
.
STATE
:
...
...
@@ -1476,6 +1475,8 @@ def procedure(root, parent=None, context=None):
errors
.
extend
(
err
)
warnings
.
extend
(
warn
)
proc
.
content
.
inner_procedures
.
append
(
new_proc
)
# Add procedure to the context, to make it visible at scope level
context
.
procedures
.
append
(
new_proc
)
elif
child
.
type
==
lexer
.
EXTERNAL
:
proc
.
external
=
True
elif
child
.
type
==
lexer
.
FPAR
:
...
...
@@ -1582,6 +1583,8 @@ def text_area_content(root, ta_ast, context):
warnings
.
extend
(
warn
)
# Add procedure to the container (process or procedure)
context
.
content
.
inner_procedures
.
append
(
proc
)
# Add to context to make it visible at scope level
context
.
procedures
.
append
(
proc
)
elif
child
.
type
==
lexer
.
FPAR
:
params
,
err
,
warn
=
fpar
(
child
)
errors
.
extend
(
err
)
...
...
@@ -1816,6 +1819,8 @@ def process_definition(root, parent=None, context=None):
errors
.
extend
(
err
)
warnings
.
extend
(
warn
)
process
.
content
.
inner_procedures
.
append
(
proc
)
# Add it at process level so that it is in the scope
process
.
procedures
.
append
(
proc
)
elif
child
.
type
==
lexer
.
FLOATING_LABEL
:
lab
,
err
,
warn
=
floating_label
(
child
,
parent
=
None
,
context
=
process
)
...
...
@@ -2189,7 +2194,7 @@ def outputbody(root, context):
''' Parse an output body (the content excluding the CIF statement) '''
errors
=
[]
warnings
=
[]
body
=
{}
body
=
{
'outputName'
:
''
,
'params'
:[]
}
for
child
in
root
.
getChildren
():
if
child
.
type
==
lexer
.
ID
:
body
[
'outputName'
]
=
child
.
text
...
...
@@ -2214,10 +2219,10 @@ def outputbody(root, context):
LOG
.
debug
(
'[outputbody] call check_and_fix_op_params : '
+
get_input_string
(
root
)
+
str
(
op_err
))
LOG
.
debug
(
str
(
traceback
.
format_exc
()))
if
body
.
get
(
'params'
)
:
if
body
[
'params'
]
:
body
[
'tmpVars'
]
=
[]
global
TMPVAR
for
_
in
range
(
len
(
body
[
'params'
]))
:
for
_
in
body
[
'params'
]
:
body
[
'tmpVars'
].
append
(
TMPVAR
)
TMPVAR
+=
1
return
body
,
errors
,
warnings
...
...
opengeode.py
View file @
940f237b
...
...
@@ -29,6 +29,7 @@ from itertools import chain
# Added to please py2exe - NOQA makes flake8 ignore the following lines:
# pylint: disable=W0611
import
enum
# NOQA
import
subprocess
# NOQA
import
tempfile
# NOQA
import
uuid
# NOQA
...
...
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