Commit f27d3e6a authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fix syntax check in for loops with range

syntax errors on the 3rd parameters were not caught and led to an
exception
parent 4e2d6bf8
...@@ -148,10 +148,11 @@ The fonts are the fonts from Ubuntu, check licence in file FONT-LICENSE.TXT ...@@ -148,10 +148,11 @@ The fonts are the fonts from Ubuntu, check licence in file FONT-LICENSE.TXT
Changelog Changelog
========= =========
1.2.7 (10/2015) 1.2.8 (10/2015)
- Better support of renamePolicy - Better support of renamePolicy
- Better handling of models without CIF coordinates - Better handling of models without CIF coordinates
- Minor bug fixes - Minor bug fixes
- Forloop syntax error handled correctly when using range
1.2.4 (07/2015) 1.2.4 (07/2015)
- Use version 3.2.x of the ASN1SCC compiler with new -renamePolicy flag - Use version 3.2.x of the ASN1SCC compiler with new -renamePolicy flag
......
...@@ -936,7 +936,7 @@ def _task_forloop(task, **kwargs): ...@@ -936,7 +936,7 @@ def _task_forloop(task, **kwargs):
else: else:
# Step is not directly supported in Ada, we need to use 'while' # Step is not directly supported in Ada, we need to use 'while'
stmt.extend(['declare', stmt.extend(['declare',
u'{it} : Integer := {start};' u'{it} : Asn1Int := {start};'
.format(it=loop['var'], .format(it=loop['var'],
start=start_str), start=start_str),
'', '',
......
...@@ -3854,7 +3854,7 @@ def for_loop(root, context): ...@@ -3854,7 +3854,7 @@ def for_loop(root, context):
forloop['type'] = basic_type.type forloop['type'] = basic_type.type
# Set the type of the iterator # Set the type of the iterator
context.variables[forloop['var']] = (forloop['type'], 0) context.variables[forloop['var']] = (forloop['type'], 0)
else: elif forloop['range']:
# Using a range - set type of iterator to standard integer # Using a range - set type of iterator to standard integer
start_expr, stop_expr = forloop['range']['start'], \ start_expr, stop_expr = forloop['range']['start'], \
forloop['range']['stop'] forloop['range']['stop']
......
...@@ -116,7 +116,7 @@ except ImportError: ...@@ -116,7 +116,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse'] __all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '1.2.7' __version__ = '1.2.8'
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated) # Detect if we are running on Windows (py2exe-generated)
......
include ../shared.mk
all: test-ada test-llvm
edit:
$(OPENGEODE) og.pr
test-parse:
$(OPENGEODE) og.pr --check
test-ada:
$(OPENGEODE) og.pr --toAda
$(ASN1SCC) -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
$(GNATMAKE) -O$(O) -c *.adb
$(GNATBIND) -n og.ali
test-c:
$(OPENGEODE) og.pr --toC
$(ASN1SCC) -c dataview-uniq.asn -typePrefix asn1Scc -equal
$(CC) -O$(O) -c *.c
test-llvm:
$(OPENGEODE) og.pr --llvm -O$(O)
$(LLC) *.ll
$(CC) -O$(O) -c *.s
coverage:
coverage run -p $(OPENGEODE) og.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
TASTE-Dataview DEFINITIONS ::=
BEGIN
MyInteger ::= INTEGER (0..255)
MyReal ::= REAL
My-OctStr ::= OCTET STRING (SIZE (0..20))
SeqOf ::= SEQUENCE (SIZE(0..100)) OF MyInteger
END
SYSTEM og;
/* CIF TEXT (159, 221), (287, 188) */
-- Text area for declarations and comments
use dv comment 'dataview-uniq.asn';
--use dv2 comment 'dataview2.asn';
signal dd(myinteger);
signal we(myinteger);
procedure anExternalProc;
fpar in/out a_param MyInteger;
external;
/* CIF ENDTEXT */
CHANNEL c
FROM ENV TO og WITH dd;
FROM og TO ENV WITH we;
ENDCHANNEL;
BLOCK og;
SIGNALROUTE r
FROM ENV TO og WITH dd;
FROM og TO ENV WITH we;
CONNECT c AND r;
/* CIF PROCESS (225, 49), (150, 75) */
PROCESS og;
/* CIF TEXT (57, 58), (303, 140) */
-- Test the proper check of RANGE parameters
dcl foo SeqOf;
dcl a, b MyInteger;
dcl c,d MyREAL;
/* CIF ENDTEXT */
/* CIF START (184, 217), (70, 35) */
START;
/* CIF TASK (86, 267), (266, 53) */
TASK for each in range (fix(1),fix(20.0) , 2):
call writeln(each);
endfor;
/* CIF NEXTSTATE (184, 350), (70, 35) */
NEXTSTATE wait;
/* CIF STATE (419, 218), (70, 35) */
STATE wait;
ENDSTATE;
ENDPROCESS og;
ENDBLOCK;
ENDSYSTEM;
\ 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