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
3963ff98
Commit
3963ff98
authored
Apr 23, 2016
by
Maxime Perrotin
Browse files
Support NULL type including value notation
parent
506cc52d
Changes
6
Show whitespace changes
Inline
Side-by-side
README.md
View file @
3963ff98
...
...
@@ -142,6 +142,9 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog
=========
1.
3.18 (04/2016)
-
Add support for value notation of NULL type
1.
3.17 (04/2016)
-
Add support for value notation of empty SEQUENCEs ("{}")
...
...
opengeode/AdaGenerator.py
View file @
3963ff98
...
...
@@ -1704,6 +1704,13 @@ def _boolean(primary):
return
[],
unicode
(
ada_string
),
[]
@
expression
.
register
(
ogAST
.
PrimNull
)
def
_boolean
(
primary
):
''' Generate code for a raw null value '''
ada_string
=
'0'
return
[],
unicode
(
ada_string
),
[]
@
expression
.
register
(
ogAST
.
PrimEmptyString
)
def
_empty_string
(
primary
):
''' Generate code for an empty SEQUENCE OF: {} '''
...
...
opengeode/ogAST.py
View file @
3963ff98
...
...
@@ -221,6 +221,9 @@ class PrimBoolean(Primary):
pass
class
PrimNull
(
Primary
):
pass
class
PrimConstant
(
Primary
):
is_raw
=
False
...
...
opengeode/ogParser.py
View file @
3963ff98
...
...
@@ -206,6 +206,11 @@ def is_boolean(ty):
return
find_basic_type
(
ty
).
kind
==
'BooleanType'
def
is_null
(
ty
):
''' Return true if a type is a NULL Type '''
return
find_basic_type
(
ty
).
kind
==
'NullType'
def
is_string
(
ty
):
''' Return true if a type is a String Type '''
return
find_basic_type
(
ty
).
kind
in
(
...
...
@@ -683,6 +688,9 @@ def check_type_compatibility(primary, type_ref, context):
elif
isinstance
(
primary
,
ogAST
.
PrimBoolean
)
and
is_boolean
(
type_ref
):
return
elif
isinstance
(
primary
,
ogAST
.
PrimNull
)
and
is_null
(
type_ref
):
return
elif
isinstance
(
primary
,
ogAST
.
PrimEmptyString
):
# Empty strings ("{ }") can be used for arrays and empty records
if
basic_type
.
kind
==
'SequenceOfType'
:
...
...
@@ -1674,6 +1682,10 @@ def primary(root, context):
prim
=
ogAST
.
PrimBoolean
()
prim
.
value
=
[
root
.
text
.
lower
()]
prim
.
exprType
=
type
(
'PrBool'
,
(
object
,),
{
'kind'
:
'BooleanType'
})
elif
root
.
type
==
lexer
.
NULL
:
prim
=
ogAST
.
PrimNull
()
prim
.
value
=
[
root
.
text
.
lower
()]
prim
.
exprType
=
type
(
'PrNull'
,
(
object
,),
{
'kind'
:
'NullType'
})
elif
root
.
type
==
lexer
.
FLOAT
:
prim
=
ogAST
.
PrimReal
()
prim
.
value
=
[
root
.
text
]
...
...
opengeode/opengeode.py
View file @
3963ff98
...
...
@@ -117,7 +117,7 @@ except ImportError:
__all__
=
[
'opengeode'
,
'SDL_Scene'
,
'SDL_View'
,
'parse'
]
__version__
=
'1.3.1
7
'
__version__
=
'1.3.1
8
'
if
hasattr
(
sys
,
'frozen'
):
# Detect if we are running on Windows (py2exe-generated)
...
...
tests/regression/test-emptysequence/og.pr
View file @
3963ff98
SYSTEM og;
/* CIF TEXT (159, 221), (28
7
, 188) */
/* CIF TEXT (159, 221), (28
9
, 188) */
-- Text area for declarations and comments
use dv comment 'dataview.asn';
...
...
@@ -18,15 +18,12 @@ signal we;
CONNECT c AND r;
/* CIF PROCESS (225, 49), (150, 75) */
PROCESS og;
/* CIF TEXT (57, 58), (
474
, 1
58
) */
/* CIF TEXT (57, 58), (
337
, 1
30
) */
-- Test support for empty sequences and NULL type
-- The parser does not support the value notation for NULL types yet
-- this demo proposes a workaround: define constants in the ASN.1 file
-- and use them when needed to define a variable of one of these types
dcl empty1 EmptySeq := c1;
dcl null1 NullType;
dcl null1 NullType
:= NULL
;
dcl choice1 ChoiceWithEmptySeq := a: n1;
/* CIF ENDTEXT */
...
...
@@ -34,25 +31,27 @@ dcl choice1 ChoiceWithEmptySeq := a: n1;
START;
/* CIF TASK (137, 276), (115, 35) */
TASK empty1 := c1
/* CIF COMMENT (272, 276), (13
8
, 35) */
/* CIF COMMENT (272, 276), (13
9
, 35) */
COMMENT 'Using a constant';
/* CIF TASK (1
40
, 326), (11
0
, 35) */
/* CIF TASK (1
38
, 326), (11
2
, 35) */
TASK empty1 := {}
/* CIF COMMENT (270, 326), (135, 35) */
COMMENT 'Classic notation';
/* CIF TASK (130, 376), (130, 35) */
TASK choice1 := b: c1;
/* CIF TASK (13
2
, 426), (12
5
, 35) */
/* CIF TASK (13
1
, 426), (12
6
, 35) */
TASK choice1 := b: {};
/* CIF TASK (14
6
, 476), (
97
, 35) */
/* CIF TASK (14
4
, 476), (
100
, 35) */
TASK null1 := n1;
/* CIF NEXTSTATE (160, 526), (70, 35) */
/* CIF TASK (134, 526), (121, 35) */
TASK null1 := null;
/* CIF NEXTSTATE (160, 576), (70, 35) */
NEXTSTATE wait;
/* CIF STATE (424, 231), (70, 35) */
STATE wait;
/* CIF INPUT (417, 286), (84, 35) */
INPUT dd;
/* CIF OUTPUT (41
5
, 336), (89, 35) */
/* CIF OUTPUT (41
4
, 336), (89, 35) */
OUTPUT we;
/* CIF NEXTSTATE (424, 386), (70, 35) */
NEXTSTATE wait;
...
...
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