Commit 29081790 authored by Maxime Perrotin's avatar Maxime Perrotin

Regression fix - on index check and choice syntax check

parent a7387b78
......@@ -44,7 +44,8 @@ You need to install the following dependencies before you can run Opengeode:
$ cd /opt
$ sudo wget http://www.semantix.gr/asn1scc/asn1Comp.tar.gz
$ sudo tar zxvf asn1Comp.tar.gz
$ sudo apt-get install mono-runtime libmono-system-runtime4.0-cil
$ sudo apt-get install mono-runtime libmono-system-runtime4.0-cil libmono-i18n-west2.0-cil libmono-posix2.0-cil libmono-security2.0-cil
libmono-system-runtime-serialization4.0-cil
Check that it works:
$ asn1Comp/bin/asn1.exe
......
......@@ -57,7 +57,8 @@ Apart from pygraphviz, all of them exist for Linux, Windows, FreeBSD, and most l
On Debian, Ubuntu, and probably other distributions:
```bash
$ sudo apt-get install python-pyside pyside-tools graphviz pip gnat mono-runtime libmono-system-runtime4.0-cil
$ sudo apt-get install python-pyside pyside-tools graphviz pip gnat mono-runtime libmono-system-runtime4.0-cil libmono-i18n-west2.0-cil libmono-posix2.0-cil libmono-security2.0-cil
libmono-system-runtime-serialization4.0-cil
$ sudo pip install --upgrade graphviz enum34 singledispatch
$ sudo pip install antlr_python_runtime --allow-external antlr_python_runtime --allow-unverified antlr_python_runtime
```
......
......@@ -1452,12 +1452,15 @@ def primary_index(root, context):
if not is_integer(idx_bty):
errors.append(error(root, 'Index is not an integer'))
else:
if float(idx_bty.Min) < float(r_min) or\
float(idx_bty.Max) >= float(r_max):
if float(idx_bty.Max) >= float(r_max):
errors.append(error(root,
'Index outside of range [{} .. <{}]'
.format(r_min,
r_max)))
'Index range [{id1} .. {id2}] '
'outside of range [0 .. <{r2}]'
.format(id1=idx_bty.Min, id2=idx_bty.Max,
r2=r_max)))
elif float(idx_bty.Min) > float(r_min):
warnings.append(warning(root,
'Index higher than range min value'))
else:
msg = 'Index can only be applied to type SequenceOf'
errors.append(error(root, msg))
......@@ -1528,7 +1531,7 @@ def selector_expression(root, context):
field_name = root.children[1].text.replace('_', '-').lower()
try:
if receiver_bty.kind == 'ChoiceType':
errors.append(error(root, 'Wrong syntax for a CHOICE selector. '
warnings.append(error(root, 'Wrong syntax for a CHOICE selector. '
'Use "var := {field}: value" instead of '
'"var!{field} := value"'
.format(field=field_name)))
......@@ -3541,7 +3544,8 @@ def for_loop(root, context):
basic = find_basic_type(start_expr.exprType)
r_min = basic.Min if basic != UNKNOWN_TYPE else '0'
basic = find_basic_type(stop_expr.exprType)
r_max = basic.Max if basic != UNKNOWN_TYPE else '4294967295'
r_max = str(int(float(basic.Max) - 1)) \
if basic != UNKNOWN_TYPE else '4294967295'
# basic may be UNKNOWN_TYPE if the expression is a
# reference to an ASN.1 constant - their values are not
# currently visible to the SDL parser
......@@ -3715,6 +3719,9 @@ def pr_file(root):
# Can happen if DataView.py is not there
LOG.info('USE Clause did not contain ASN.1 filename')
LOG.debug(str(err))
except TypeError as err:
errors.append('ASN.1 compiler execution failed')
LOG.debug(str(err))
for child in systems:
LOG.debug('found SYSTEM')
......
all: test-ada
edit:
../../../opengeode.py orchestrator.pr system_structure.pr
test-parse:
../../../opengeode.py orchestrator.pr system_structure.pr --check
......
......@@ -20,29 +20,29 @@ dcl testvalue t_boolean := true;
dcl nested Nested := {a {b {c {p {x 1, y 2}, l {3, 4}}}}};
/* CIF ENDTEXT */
/* CIF START (672, 14), (68, 37) */
/* CIF START (632, 24), (68, 37) */
START;
/* CIF TASK (613, 66), (184, 72) */
TASK for x in count:
/* CIF TASK (573, 76), (184, 72) */
TASK for x in range(count):
count(x) := count_max
actual_count(x) := 0
endfor;
/* CIF TASK (557, 153), (298, 35) */
/* CIF TASK (517, 163), (298, 35) */
TASK nested := {a {b {c {p {x 1, y 2}, l {3, 4}}}}};
/* CIF NEXTSTATE (671, 203), (70, 35) */
/* CIF NEXTSTATE (631, 213), (70, 35) */
NEXTSTATE Wait;
/* CIF STATE (759, 11), (68, 35) */
/* CIF STATE (757, 11), (68, 35) */
STATE Wait;
ENDSTATE;
/* CIF STATE (671, 203), (70, 35) */
/* CIF STATE (631, 213), (70, 35) */
STATE Wait;
/* CIF INPUT (671, 258), (70, 35) */
/* CIF INPUT (631, 268), (70, 35) */
INPUT run;
/* CIF PROCEDURECALL (622, 308), (166, 35) */
/* CIF PROCEDURECALL (582, 318), (166, 35) */
CALL writeln('Computing');
/* CIF TASK (499, 358), (412, 216) */
/* CIF TASK (443, 368), (444, 216) */
TASK for x in range(exceed_nb):
for n in range(nb_bit):
for n in range(20): -- can't use nb_bit: asn1 constants are not visible
call pow(2, n, pow_value);
check := if val_max - x>0 and pow_value>0 then 1 else 0 fi
bitwise := bitwise and bitwise
......@@ -54,7 +54,7 @@ endfor;
call test((n+1) mod 255, testvalue);
endfor
endfor;
/* CIF NEXTSTATE (671, 589), (70, 35) */
/* CIF NEXTSTATE (631, 599), (70, 35) */
NEXTSTATE wait;
ENDSTATE;
ENDPROCESS challenge;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment