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
b329f3a9
Commit
b329f3a9
authored
Aug 06, 2014
by
dbarbera
Browse files
Merge remote-tracking branch 'upstream/master'
parents
3f45f64e
ee83d9b7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
ogParser.py
View file @
b329f3a9
This diff is collapsed.
Click to expand it.
opengeode.py
View file @
b329f3a9
...
...
@@ -57,7 +57,7 @@ import Connectors # NOQA
#from PySide import phonon
from
PySide
import
QtGui
,
QtCore
from
PySide.QtCore
import
Qt
,
QSize
,
QFile
,
QIODevice
,
QRectF
,
QTimer
from
PySide.QtCore
import
Qt
,
QSize
,
QFile
,
QIODevice
,
QRectF
,
QTimer
,
QPoint
from
PySide.QtUiTools
import
QUiLoader
from
PySide
import
QtSvg
...
...
@@ -342,6 +342,11 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
return
(
it
for
it
in
self
.
visible_symb
if
isinstance
(
it
,
Process
)
and
not
isinstance
(
it
,
Procedure
))
@
property
def
procedures
(
self
):
''' Return visible procedures components of the scene '''
return
(
it
for
it
in
self
.
visible_symb
if
isinstance
(
it
,
Procedure
))
@
property
def
states
(
self
):
''' Return visible state components of the scene '''
...
...
@@ -603,22 +608,6 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
except
StopIteration
:
LOG
.
info
(
'Pattern not found'
)
def
show_item
(
self
,
item
):
'''
Select an item and make sure it is visible
(used when user clicks on a warning or error to locate the symbol)
'''
abs_coordinates
=
item
.
data
(
Qt
.
UserRole
)
if
not
abs_coordinates
:
LOG
.
info
(
'Corresponding symbol not found'
)
return
item
=
self
.
itemAt
(
*
abs_coordinates
)
if
item
:
self
.
clearSelection
()
self
.
clear_focus
()
item
.
setSelected
(
True
)
item
.
ensureVisible
()
def
delete_selected_symbols
(
self
):
'''
Remove selected symbols from the scene, with proper re-connections
...
...
@@ -1457,15 +1446,21 @@ class SDL_View(QtGui.QGraphicsView, object):
error
[
0
]
=
'Internal error - '
+
str
(
error
[
0
])
LOG
.
error
(
error
[
0
])
item
=
QtGui
.
QListWidgetItem
(
u
'[ERROR] '
+
error
[
0
])
if
len
(
error
)
==
2
:
if
len
(
error
)
==
3
:
item
.
setData
(
Qt
.
UserRole
,
error
[
1
])
#found = self.scene().symbol_near(QPoint(*error[1]), 1)
# Pyside bug: setData cannot store 'found' directly
#item.setData(Qt.UserRole + 1, id(found))
item
.
setData
(
Qt
.
UserRole
+
1
,
error
[
2
])
if
self
.
messages_window
:
self
.
messages_window
.
addItem
(
item
)
for
warning
in
warnings
:
LOG
.
warning
(
warning
[
0
])
item
=
QtGui
.
QListWidgetItem
(
u
'[WARNING] '
+
str
(
warning
[
0
]))
if
len
(
warning
)
==
2
:
if
len
(
warning
)
==
3
:
item
.
setData
(
Qt
.
UserRole
,
warning
[
1
])
item
.
setData
(
Qt
.
UserRole
+
1
,
warning
[
2
])
#found = self.scene().symbol_near(QPoint(*warning[1]), 1)
if
self
.
messages_window
:
self
.
messages_window
.
addItem
(
item
)
if
not
errors
and
not
warnings
and
self
.
messages_window
:
...
...
@@ -1485,6 +1480,59 @@ class SDL_View(QtGui.QGraphicsView, object):
string
=
pr_data
)
self
.
log_errors
(
errors
,
warnings
)
def
show_item
(
self
,
item
):
'''
Select an item and make sure it is visible - change scene if needed
Used when user clicks on a warning or error to locate the symbol
'''
coord
=
item
.
data
(
Qt
.
UserRole
)
path
=
item
.
data
(
Qt
.
UserRole
+
1
)
if
not
coord
:
LOG
.
debug
(
'Corresponding symbol not found (no coordinates)'
)
return
# Find the scene containing the symbol
while
self
.
up_button
.
isEnabled
():
self
.
go_up
()
for
each
in
path
:
kind
,
name
=
each
.
split
()
name
=
unicode
(
name
).
lower
()
if
kind
==
'PROCESS'
:
for
process
in
self
.
scene
().
processes
:
if
unicode
(
process
).
lower
()
==
name
:
self
.
go_down
(
process
.
nested_scene
,
name
=
u
'process {}'
.
format
(
name
))
break
else
:
LOG
.
error
(
'Process {} not found'
.
format
(
name
))
elif
kind
==
'STATE'
:
for
state
in
self
.
scene
().
states
:
if
unicode
(
state
).
lower
()
==
name
:
self
.
go_down
(
state
.
nested_scene
,
name
=
u
'state {}'
.
format
(
name
))
break
else
:
LOG
.
error
(
'Composite state {} not found'
.
format
(
name
))
elif
kind
==
'PROCEDURE'
:
for
proc
in
self
.
scene
().
procedures
:
if
unicode
(
proc
).
lower
()
==
name
:
self
.
go_down
(
proc
.
nested_scene
,
name
=
u
'procedure {}'
.
format
(
name
))
break
else
:
LOG
.
error
(
'Procedure {} not found'
.
format
(
name
))
pos
=
QPoint
(
*
coord
)
symbol
=
self
.
scene
().
symbol_near
(
pos
=
pos
,
dist
=
1
)
if
symbol
:
self
.
scene
().
clearSelection
()
self
.
scene
().
clear_focus
()
symbol
.
select
()
symbol
.
ensureVisible
()
else
:
LOG
.
info
(
'No symbol at given coordinates in the current scene'
)
def
generate_ada
(
self
):
''' Generate Ada code '''
# If the current scene is a nested one, save the top parent
...
...
@@ -1611,7 +1659,7 @@ class OG_MainWindow(QtGui.QMainWindow, object):
messages
.
addItem
(
'Welcome to OpenGEODE.'
)
self
.
view
.
messages_window
=
messages
self
.
scene
.
messages_window
=
messages
messages
.
itemClicked
.
connect
(
self
.
scene
.
show_item
)
messages
.
itemClicked
.
connect
(
self
.
view
.
show_item
)
statechart_dock
=
self
.
findChild
(
QtGui
.
QDockWidget
,
'statechart_dock'
)
#statechart_dock.setWindowTitle('Statechart view - F4 to update')
...
...
tests/regression/test-substrings/myfunction.pr
View file @
b329f3a9
/* CIF PROCESS (200, 143), (150, 75) */
PROCESS myfunction;
/* CIF TEXT (7, 43), (334, 41) */
-- Test substrings in various contexts and operators
/* CIF ENDTEXT */
/* CIF TEXT (0, 133), (282, 136) */
dcl str MyOctStr := 'abc';
dcl variable_str String := 'Hello!';
...
...
@@ -12,6 +9,9 @@ dcl seqof MySeqOf := {hello, world};
dcl seqint seqInt := {1};
dcl seqbool seqBool := { true, false};
dcl seqbool2 seqBool2 := { true, false};
/* CIF ENDTEXT */
/* CIF TEXT (7, 43), (334, 41) */
-- Test substrings in various contexts and operators
/* CIF ENDTEXT */
/* CIF PROCEDURE (1416, 490), (91, 35) */
PROCEDURE factorial;
...
...
@@ -32,136 +32,140 @@ endfor;
ENDPROCEDURE;
/* CIF START (104, 273), (65, 37) */
START;
/* CIF DECISION (75, 325), (123, 50) */
/* CIF TASK (60, 325), (151, 35) */
TASK seqof := seqof(0,1)
/* CIF COMMENT (232, 325), (208, 35) */
COMMENT 'equivalent to seqof := seqof';
/* CIF DECISION (75, 375), (123, 50) */
DECISION hello in seqof
/* CIF COMMENT (218, 3
2
6), (179, 53) */
/* CIF COMMENT (218, 3
7
6), (179, 53) */
COMMENT 'Check IN operator with
enumerated type';
/* CIF ANSWER (4,
39
5), (70, 24) */
/* CIF ANSWER (4,
44
5), (70, 24) */
(true):
/* CIF PROCEDURECALL (-49, 4
3
4), (177, 35) */
/* CIF PROCEDURECALL (-49, 4
8
4), (177, 35) */
CALL writeln(hello in seqof)
/* CIF COMMENT (148, 4
3
4), (114, 35) */
/* CIF COMMENT (148, 4
8
4), (114, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (26
8
,
39
5), (70, 24) */
/* CIF ANSWER (26
7
,
44
5), (70, 24) */
(false):
ENDDECISION;
/* CIF DECISION (59,
48
4), (155, 50) */
/* CIF DECISION (59,
53
4), (155, 50) */
DECISION hello in seqof(0,0)
/* CIF COMMENT (242,
462
), (236, 56) */
/* CIF COMMENT (242,
507
), (236, 56) */
COMMENT 'Check IN operator with
list substring - first element only
should go to branch TRUE';
/* CIF ANSWER (
7
, 5
22
), (66, 33) */
/* CIF ANSWER (
6
, 5
67
), (66, 33) */
(true):
/* CIF PROCEDURECALL (-
59, 570
), (201, 35) */
/* CIF PROCEDURECALL (-
60, 615
), (201, 35) */
CALL writeln(hello in seqof(0,1))
/* CIF COMMENT (162,
570
), (114, 35) */
/* CIF COMMENT (162,
615
), (114, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (28
5
, 5
23
), (70, 24) */
/* CIF ANSWER (28
4
, 5
68
), (70, 24) */
(false):
ENDDECISION;
/* CIF PROCEDURECALL (40, 6
20
), (191, 35) */
/* CIF PROCEDURECALL (40, 6
65
), (191, 35) */
CALL writeln(variable_str(0,4))
/* CIF COMMENT (243,
57
0), (113, 35) */
/* CIF COMMENT (243,
61
0), (113, 35) */
COMMENT 'print "Hello"';
/* CIF TASK (48,
670
), (176, 56) */
/* CIF TASK (48,
715
), (176, 56) */
TASK for x in seqof:
call writeln(num(x));
endfor
/* CIF COMMENT (242, 6
2
8), (96, 56) */
/* CIF COMMENT (242, 6
6
8), (96, 56) */
COMMENT 'print:
12
13';
/* CIF TASK (46, 7
41
), (180, 56) */
/* CIF TASK (46, 7
86
), (180, 56) */
TASK for x in seqof(0,1):
call writeln(-num(x));
endfor
/* CIF COMMENT (244,
69
2), (96, 56) */
/* CIF COMMENT (244,
73
2), (96, 56) */
COMMENT 'print:
-12
-13';
/* CIF PROCEDURECALL (46, 8
12
), (180, 35) */
/* CIF PROCEDURECALL (46, 8
57
), (180, 35) */
CALL writeln(length(seqof))
/* CIF COMMENT (246,
77
7), (77, 35) */
/* CIF COMMENT (246,
81
7), (77, 35) */
COMMENT 'print 2';
/* CIF PROCEDURECALL (32,
862
), (209, 35) */
/* CIF PROCEDURECALL (32,
907
), (209, 35) */
CALL writeln(length(seqof(0,1)))
/* CIF COMMENT (261, 8
2
7), (77, 35) */
/* CIF COMMENT (261, 8
6
7), (77, 35) */
COMMENT 'print 2';
/* CIF LABEL (55, 9
12
), (162, 35) */
/* CIF LABEL (55, 9
57
), (162, 35) */
variable_length_seq:
/* CIF TASK (65,
962
), (142, 56) */
/* CIF TASK (65,
1007
), (142, 56) */
TASK for x in seqint:
call writeln(x);
endfor
/* CIF COMMENT (227, 9
1
3), (96, 53) */
/* CIF COMMENT (227, 9
5
3), (96, 53) */
COMMENT 'print:
1';
/* CIF TASK (60, 10
33
), (152, 56) */
/* CIF TASK (60, 10
78
), (152, 56) */
TASK for x in seqint(0,0):
call writeln(x);
endfor
/* CIF COMMENT (232,
98
4), (96, 53) */
/* CIF COMMENT (232,
102
4), (96, 53) */
COMMENT 'print:
1';
/* CIF DECISION (75, 11
0
4), (123, 50) */
/* CIF DECISION (75, 114
9
), (123, 50) */
DECISION 1 in seqint
/* CIF COMMENT (217, 10
5
9), (179, 53) */
/* CIF COMMENT (217, 10
9
9), (179, 53) */
COMMENT 'Check IN operator with
variable-length seqOf';
/* CIF ANSWER (
6
, 11
5
1), (66, 33) */
/* CIF ANSWER (
5
, 11
9
1), (66, 33) */
(true):
/* CIF PROCEDURECALL (-4
8
, 1
19
9), (177, 35) */
/* CIF PROCEDURECALL (-4
9
, 1
23
9), (177, 35) */
CALL writeln(1 in seqint)
/* CIF COMMENT (149, 1
19
9), (114, 35) */
/* CIF COMMENT (149, 1
23
9), (114, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (26
6
, 11
5
1), (70, 24) */
/* CIF ANSWER (26
5
, 11
9
1), (70, 24) */
(false):
ENDDECISION;
/* CIF DECISION (72, 12
4
9), (128, 50) */
/* CIF DECISION (72, 12
8
9), (128, 50) */
DECISION 1 in seqint(0,0)
/* CIF COMMENT (219, 12
04
), (179, 53) */
/* CIF COMMENT (219, 12
39
), (179, 53) */
COMMENT 'Check IN operator with
variable-length seqOf';
/* CIF ANSWER (5, 1
296
), (70, 24) */
/* CIF ANSWER (5, 1
331
), (70, 24) */
(true):
/* CIF PROCEDURECALL (-51, 13
35
), (182, 35) */
/* CIF PROCEDURECALL (-51, 13
70
), (182, 35) */
CALL writeln(1 in seqint(0,0))
/* CIF COMMENT (151, 13
35
), (114, 35) */
/* CIF COMMENT (151, 13
70
), (114, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (26
7
, 1
296
), (70, 24) */
/* CIF ANSWER (26
6
, 1
331
), (70, 24) */
(false):
ENDDECISION;
/* CIF PROCEDURECALL (46, 1
385
), (180, 35) */
/* CIF PROCEDURECALL (46, 1
420
), (180, 35) */
CALL writeln(length(seqint))
/* CIF COMMENT (246, 13
5
0), (77, 35) */
/* CIF COMMENT (246, 13
8
0), (77, 35) */
COMMENT 'print 1';
/* CIF PROCEDURECALL (30, 14
35
), (212, 35) */
/* CIF PROCEDURECALL (30, 14
70
), (212, 35) */
CALL writeln(length(seqint(0,0)))
/* CIF COMMENT (262, 14
0
0), (77, 35) */
/* CIF COMMENT (262, 14
3
0), (77, 35) */
COMMENT 'print 1';
/* CIF TASK (54, 1
485
), (163, 35) */
/* CIF TASK (54, 1
520
), (163, 35) */
TASK seqint := seqint // {2};
/* CIF TASK (41, 15
35
), (190, 35) */
/* CIF TASK (41, 15
70
), (190, 35) */
TASK seqint := seqint(0,0) // {5};
/* CIF TASK (65, 1
585
), (142, 56) */
/* CIF TASK (65, 1
620
), (142, 56) */
TASK for x in seqint:
call writeln(x);
endfor
/* CIF COMMENT (229, 15
6
0), (96, 56) */
/* CIF COMMENT (229, 15
9
0), (96, 56) */
COMMENT 'print:
1
5';
/* CIF TASK (20, 16
56
), (233, 35) */
/* CIF TASK (20, 16
91
), (233, 35) */
TASK seqbool := seqbool and seqbool
/* CIF COMMENT (273, 16
4
5), (194, 35) */
/* CIF COMMENT (273, 16
7
5), (194, 35) */
COMMENT 'should not raise any error';
/* CIF TASK (7, 17
06
), (258, 38) */
/* CIF TASK (7, 17
41
), (258, 38) */
TASK 'seqbool2 := seqbool2 and seqbool2'
/* CIF COMMENT (285, 17
0
7), (213, 35) */
/* CIF COMMENT (285, 17
3
7), (213, 35) */
COMMENT 'Variable-length -> raise error';
/* CIF NEXTSTATE (10
2
, 17
5
9), (68, 33) */
/* CIF NEXTSTATE (10
1
, 179
4
), (68, 33) */
NEXTSTATE Wait;
/* CIF STATE (839, 313), (70, 35) */
STATE wait;
...
...
tests/regression/test8/Makefile
View file @
b329f3a9
all
:
test-ada
edit
:
../../../opengeode.py orchestrator.pr system_structure.pr
test-parse
:
../../../opengeode.py
--check
orchestrator.pr system_structure.pr
...
...
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