Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
8f399145
Commit
8f399145
authored
May 19, 2016
by
Maxime Perrotin
Browse files
Improve error reporting and better test
parent
e0897e45
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
opengeode/icons.py
View file @
8f399145
...
...
@@ -2,7 +2,7 @@
# Resource object code
#
# Created:
Wed
May 1
8
1
4:18:2
6 2016
# Created:
Thu
May 1
9
1
5:06:0
6 2016
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
opengeode/sdl92Lexer.py
View file @
8f399145
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2016-05-1
8
1
4:18:2
8
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2016-05-1
9
1
5:06:0
8
import
sys
from
antlr3
import
*
...
...
@@ -93,7 +93,7 @@ NOT=171
SPECIFIC
=
184
STIMULUS
=
96
THIS
=
160
ENDPROCEDURE
=
13
2
ENDPROCEDURE
=
13
3
END
=
187
AGGREGATION
=
140
FI
=
36
...
...
@@ -125,7 +125,7 @@ ACTION=4
T__229
=
229
STOPIF
=
98
T__228
=
228
START
=
13
5
START
=
13
6
FALSE
=
173
T__225
=
225
T__224
=
224
...
...
@@ -133,7 +133,7 @@ T__227=227
DEFAULT
=
143
T__226
=
226
IMPLIES
=
162
ENDCONNECTION
=
13
6
ENDCONNECTION
=
13
7
ENDDECISION
=
151
EXPORT
=
33
JOIN
=
55
...
...
@@ -153,10 +153,10 @@ IN=49
FIELD
=
37
DOT
=
215
SYNONYM
=
101
OUT
=
13
3
OUT
=
13
4
ENDBLOCK
=
127
STATELIST
=
95
SEMI
=
13
7
SEMI
=
13
2
CONNECT
=
20
ASN1
=
9
ASSIGN
=
10
...
...
@@ -216,7 +216,7 @@ ACTIVE=180
Exponent
=
218
L_PAREN
=
146
ANY
=
152
INT
=
13
4
INT
=
13
5
CHOICE
=
14
EXTERNAL
=
35
FIELD_NAME
=
38
...
...
opengeode/sdl92Parser.py
View file @
8f399145
This diff is collapsed.
Click to expand it.
sdl92.g
View file @
8f399145
...
...
@@ -281,11 +281,10 @@ parameters_of_sort
;
// procedure: missing the RETURNS statement
// (TODO - but check new SDL2000 syntax that has no RETURNS token)
// procedure
procedure
: cif?
PROCEDURE procedure_id e1=end
PROCEDURE procedure_id
(
e1=end
| SEMI)
fpar?
res=procedure_result?
(text_area | procedure)*
...
...
@@ -307,7 +306,7 @@ procedure_result
fpar
: FPAR formal_variable_param
(',' formal_variable_param)*
end
?
end
-> ^(FPAR formal_variable_param+)
;
...
...
@@ -481,7 +480,7 @@ floating_label
state
: cif?
hyperlink?
STATE statelist e=end
STATE statelist
(
e=end
| SEMI)
(state_part)*
ENDSTATE statename? f=end
-> ^(STATE cif? hyperlink? $e? statelist state_part*)
...
...
@@ -601,6 +600,7 @@ composite_state_body
| procedure
| (composite_state_preamble) =>composite_state)*
start* (state | floating_label)*
EOF?
;
...
...
tests/parser/aggreg.py
View file @
8f399145
#!/usr/bin/env python
from
opengeode.ogParser
import
parser_init
from
opengeode.ogParser
import
parser_init
,
antlr3
,
sdl92Parser
# detect syntax errors (missing semi after "entry")
# return a string corresponding to a token number:
token
=
lambda
num
:
sdl92Parser
.
tokenNames
[
num
]
def
test_composite_state_body_1
():
''' Detect the syntax error (missing SEMI after "procedure entry") '''
test
=
parser_init
(
string
=
'''state ENTRYA;
substructure
procedure entry EXTERNAL;
endsubstructure ENTRYA;
'''
)
test
.
composite_state_body
()
substructure
procedure entry external;
endsubstructure ENTRYA;'''
)
# Parse and then check that the reported error is the expected one
res
=
test
.
composite_state_body
()
assert
(
not
isinstance
(
res
.
tree
,
antlr3
.
tree
.
CommonErrorNode
))
composite
=
res
.
tree
.
children
[
0
]
compo_type
=
sdl92Parser
.
tokenNames
[
composite
.
type
]
assert
(
compo_type
==
'COMPOSITE_STATE'
)
for
each
in
composite
.
children
:
if
isinstance
(
each
,
antlr3
.
tree
.
CommonErrorNode
):
exception
=
each
.
trappedException
assert
(
isinstance
(
exception
,
antlr3
.
NoViableAltException
))
assert
(
token
(
exception
.
unexpectedType
)
==
'EXTERNAL'
)
def
test_composite_state_1
():
''' Detect the syntax error (missing SEMI after "procedure entry") '''
test
=
parser_init
(
string
=
'''state CHECKING;
substructure
...
...
@@ -43,7 +55,7 @@ def test_composite_state_2():
test
.
composite_state
()
def
test_composite_state_body_
1
():
def
test_composite_state_body_
2
():
print
(
'composite_state_body 2:'
)
test
=
parser_init
(
string
=
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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