Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
7112403f
Commit
7112403f
authored
Oct 24, 2014
by
Maxime Perrotin
Browse files
Check generation of system structure
parent
028040b1
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Pr.py
View file @
7112403f
...
...
@@ -43,29 +43,43 @@ def parse_scene(scene, full_model=False):
if
full_model
:
# Generate a complete SDL system - to have everything in a single file
# (1) get system name
# (2) get all signal names from declaration in text boxes
# (3) get signal directions from the connection of the process to env
# (4) generate all the text
# (2) get signal directions from the connection of the process to env
# (3) generate all the text
processes
=
list
(
scene
.
processes
)
system_name
=
unicode
(
processes
[
0
])
if
processes
else
u
'OpenGEODE'
signals
,
routes
=
[],
[]
pr_txt
=
[]
signals
=
[]
to_env
=
[]
from_env
=
[]
pr_txt
,
channels
,
routes
=
[],
[],
[]
for
each
in
scene
.
texts
:
# Parse text areas to retrieve signal names
# Parse text areas to retrieve signal names
USELESS
pr
=
generate
(
each
)
txt
=
'
\n
'
.
join
(
pr
)
pr_txt
.
append
(
txt
)
ast
,
_
,
_
,
_
,
_
=
each
.
parser
.
parseSingleElement
(
'text_area'
,
txt
)
signals
.
extend
([
'SIGNAL {}{};'
.
format
(
sig
[
'name'
],
(
'('
+
sig
[
'type'
]
+
')'
)
if
sig
[
'type'
]
else
''
)
for
sig
in
ast
.
signals
])
#routes = scene.CONTEXT.signalroutes
if
processes
:
to_env
=
processes
[
0
].
connection
.
out_sig
from_env
=
processes
[
0
].
connection
.
in_sig
if
to_env
or
from_env
:
channels
=
[
'CHANNEL c'
]
routes
=
[
'SIGNALROUTE r'
]
if
from_env
:
from_txt
=
'FROM ENV TO {} WITH {};'
\
.
format
(
system_name
,
from_env
)
channels
.
append
(
from_txt
)
routes
.
append
(
from_txt
)
if
to_env
:
to_txt
=
'FROM {} TO ENV WITH {};'
\
.
format
(
system_name
,
to_env
)
channels
.
append
(
to_txt
)
routes
.
append
(
to_txt
)
channels
.
append
(
'ENDCHANNEL;'
)
routes
.
append
(
'CONNECT c AND r;'
)
pr_data
.
append
(
'SYSTEM {};'
.
format
(
system_name
))
pr_data
.
extend
(
pr_txt
)
pr_data
.
extend
(
signals
)
#pr_data.extend(routes)
pr_data
.
extend
(
channels
)
pr_data
.
append
(
'BLOCK {};'
.
format
(
system_name
))
#
pr_data.extend(route)
pr_data
.
extend
(
route
s
)
for
each
in
processes
:
pr_data
.
extend
(
generate
(
each
))
pr_data
.
append
(
'ENDBLOCK;'
)
...
...
ogParser.py
View file @
7112403f
...
...
@@ -356,10 +356,13 @@ def get_interfaces(ast, process_name):
continue
for
sig_id
in
route
[
'signals'
]:
# Copy the signal to the result dict
found
,
=
[
dict
(
sig
)
for
sig
in
all_signals
if
sig
[
'name'
]
==
sig_id
]
found
[
'direction'
]
=
direction
async_signals
.
append
(
found
)
try
:
found
,
=
[
dict
(
sig
)
for
sig
in
all_signals
if
sig
[
'name'
]
==
sig_id
]
found
[
'direction'
]
=
direction
async_signals
.
append
(
found
)
except
ValueError
:
LOG
.
error
(
'Signal {} is not declared'
.
format
(
sig_id
))
return
async_signals
,
system
.
procedures
...
...
@@ -2314,6 +2317,7 @@ def text_area_content(root, ta_ast, context):
ta_ast
.
use_clauses
.
append
(
each
.
text
)
ta_ast
.
asn1_files
.
append
(
use_cmt
)
else
:
print
'HIM'
warnings
.
append
(
'Unsupported construct in text area content, type: '
+
str
(
child
.
type
))
...
...
@@ -3902,7 +3906,6 @@ def pr_file(root):
ast
.
asn1Modules
=
DV
.
asn1Modules
for
child
in
systems
:
LOG
.
debug
(
'found SYSTEM'
)
system
,
err
,
warn
=
system_definition
(
child
,
parent
=
ast
)
errors
.
extend
(
err
)
warnings
.
extend
(
warn
)
...
...
sdl92.g
View file @
7112403f
...
...
@@ -275,7 +275,7 @@ content
| synonym_definition)*
-> ^(TEXTAREA_CONTENT fpar* procedure* variable_definition*
syntype_definition* newtype_definition* timer_declaration*
synonym_definition*);
signal_declaration* use_clause*
synonym_definition*);
timer_declaration
...
...
sdl92Lexer.py
View file @
7112403f
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-10-2
3
1
4:32:25
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-10-2
4
1
0:10:52
import
sys
from
antlr3
import
*
...
...
@@ -3865,7 +3865,7 @@ class sdl92Lexer(Lexer):
_channel
=
DEFAULT_CHANNEL
# sdl92.g:1275:17: ( C O N S T A N T S )
# sdl92.g:1275:2
3
: C O N S T A N T S
# sdl92.g:1275:2
5
: C O N S T A N T S
pass
self
.
mC
()
self
.
mO
()
...
...
@@ -3898,7 +3898,7 @@ class sdl92Lexer(Lexer):
_channel
=
DEFAULT_CHANNEL
# sdl92.g:1276:17: ( S T R U C T )
# sdl92.g:1276:2
3
: S T R U C T
# sdl92.g:1276:2
5
: S T R U C T
pass
self
.
mS
()
self
.
mT
()
...
...
sdl92Parser.py
View file @
7112403f
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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