Commit 023b0538 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Bigfix on op_minus operator

parent 0519ff0a
......@@ -685,11 +685,7 @@ def compare_types(type_a, type_b):
raise TypeError('One type is an REAL, not the other one')
elif all(side.kind.startswith('Integer') for side in (type_a, type_b)) \
or all(side.kind == 'RealType' for side in (type_a, type_b)):
pass # XXX no need for type check here, only at assignments
# if float(type_b.Min) < float(type_a.Min) \
# or float(type_b.Max) > float(type_a.Max):
# raise TypeError('Range [{}..{}] incompatible with range [{}..{}]'
# .format(type_b.Min, type_b.Max, type_a.Min, type_a.Max))
pass
else:
return
......@@ -1291,7 +1287,6 @@ def primary(root, context):
prim.inputString = get_input_string(root)
prim.line = root.getLine()
prim.charPositionInLine = root.getCharPositionInLine()
prim.op_not, prim.op_minus = op_not, op_minus
if op_not:
prim.op_not = True
if op_minus:
......
[C Code] Running test
0
-2 is FALSE
2 2 1
FALSE TRUE
......
......@@ -19,6 +19,7 @@ DCL def_val MySeq := { a 3, b taste };
dcl someReal MyReal := 1.5;
dcl largeReal LargerReal := 0.0;
dcl someInt t_uInt8 := 2;
dcl otherint T_uint8 := 1;
-- To test 'op_not'
dcl opnot T_boolean := not true;
......@@ -44,73 +45,75 @@ endfor;
ENDPROCEDURE;
/* CIF START (591, 0), (100, 50) */
START;
/* CIF PROCEDURECALL (430, 65), (421, 35) */
/* CIF PROCEDURECALL (552, 65), (177, 35) */
CALL writeln(1 + (-otherint));
/* CIF PROCEDURECALL (430, 115), (421, 35) */
CALL writeln(-someint, if someint>0 then ' is ' else 'Foo' fi, not true);
/* CIF PROCEDURECALL (514, 115), (254, 35) */
/* CIF PROCEDURECALL (514, 165), (254, 35) */
CALL write(if someint>0 then 2 else 1 fi);
/* CIF PROCEDURECALL (496, 165), (289, 35) */
/* CIF PROCEDURECALL (496, 215), (289, 35) */
CALL write(if someint>0 then someint else 1 fi);
/* CIF PROCEDURECALL (577, 215), (128, 35) */
/* CIF PROCEDURECALL (577, 265), (128, 35) */
CALL writeln(bar(1));
/* CIF PROCEDURECALL (532, 265), (217, 35) */
/* CIF PROCEDURECALL (532, 315), (217, 35) */
CALL writeln(opnot, ' ', not opnot);
/* CIF TASK (480, 315), (321, 35) */
/* CIF TASK (480, 365), (321, 35) */
TASK someInt := if someint = 0 then someint else 0 fi;
/* CIF DECISION (504, 365), (273, 87) */
/* CIF DECISION (504, 415), (273, 87) */
DECISION someint /=0 and then (10 / someInt > 0)
or else someint = 0
/* CIF COMMENT (793, 374), (179, 68) */
/* CIF COMMENT (793, 424), (179, 68) */
COMMENT 'Using "and else" is the
short-circuit form. The
second part should not
be evaluated.';
/* CIF ANSWER (561, 472), (70, 23) */
/* CIF ANSWER (561, 522), (70, 23) */
(true):
/* CIF TASK (541, 510), (110, 35) */
/* CIF TASK (541, 560), (110, 35) */
TASK someInt := 2;
/* CIF PROCEDURECALL (537, 560), (117, 38) */
/* CIF PROCEDURECALL (537, 610), (117, 38) */
CALL writeln('OK');
/* CIF ANSWER (664, 472), (70, 23) */
/* CIF ANSWER (664, 522), (70, 23) */
(false):
ENDDECISION;
/* CIF NEXTSTATE (608, 613), (65, 33) */
/* CIF NEXTSTATE (608, 663), (65, 33) */
NEXTSTATE Wait;
/* CIF STATE (608, 613), (65, 33) */
/* CIF STATE (608, 663), (65, 33) */
STATE Wait;
/* CIF INPUT (865, 666), (89, 33) */
/* CIF INPUT (865, 716), (89, 33) */
INPUT mytimer;
/* CIF PROCEDURECALL (818, 714), (182, 33) */
/* CIF PROCEDURECALL (818, 764), (182, 33) */
CALL writeln('timer expired');
/* CIF PROCEDURECALL (829, 762), (160, 33) */
/* CIF PROCEDURECALL (829, 812), (160, 33) */
CALL factorial(3, someint);
/* CIF NEXTSTATE (877, 810), (65, 33) */
/* CIF NEXTSTATE (877, 860), (65, 33) */
NEXTSTATE Wait;
/* CIF INPUT (421, 666), (181, 33) */
/* CIF INPUT (421, 716), (181, 33) */
INPUT start_something (toto);
/* CIF OUTPUT (376, 714), (270, 33) */
/* CIF OUTPUT (376, 764), (270, 33) */
OUTPUT result_data((toto+1) mod 2147483647);
/* CIF PROCEDURECALL (436, 762), (150, 48) */
/* CIF PROCEDURECALL (436, 812), (150, 48) */
CALL writeln
('Hello Toto', toto);
/* CIF PROCEDURECALL (413, 825), (196, 33) */
/* CIF PROCEDURECALL (413, 875), (196, 33) */
CALL set_timer(1000, myTimer);
/* CIF TASK (346, 873), (330, 35) */
/* CIF TASK (346, 923), (330, 35) */
TASK largeReal := power(someReal, 2);
/* CIF PROCEDURECALL (282, 923), (458, 35) */
/* CIF PROCEDURECALL (282, 973), (458, 35) */
CALL writeln(someReal, ' ** 2' , ' == ', largeReal, ' (should be 2.25 )');
/* CIF TASK (411, 973), (201, 35) */
/* CIF TASK (411, 1023), (201, 35) */
TASK someReal := float(someInt);
/* CIF TASK (391, 1023), (241, 35) */
/* CIF TASK (391, 1073), (241, 35) */
TASK someInt := fix(someReal) mod 255;
/* CIF TASK (435, 1073), (152, 35) */
/* CIF TASK (435, 1123), (152, 35) */
TASK opnot := not opnot;
/* CIF TASK (430, 1123), (163, 35) */
/* CIF TASK (430, 1173), (163, 35) */
TASK 'someint := -someint'
/* CIF COMMENT (613, 1123), (196, 35) */
/* CIF COMMENT (613, 1173), (196, 35) */
COMMENT 'XXX should raise an error!';
/* CIF TASK (429, 1173), (164, 35) */
/* CIF TASK (429, 1223), (164, 35) */
TASK someint := (-8) mod 5;
/* CIF NEXTSTATE (480, 1223), (63, 33) */
/* CIF NEXTSTATE (480, 1273), (63, 33) */
NEXTSTATE wait;
ENDSTATE;
ENDPROCESS myfunction;
\ 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