# HG changeset patch # User mario # Date 1202543834 -3600 # Node ID f9e001952488e13f476dfc88638f4a6d551a2246 # Parent ff5c92df0c78e1f9dd4f89a413e060a8bd69feb1 Regression tests. Test correct parsing of identifiers. diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/Makefile Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,15 @@ + + +default: runtests + + +runtests: + ./runtests + + +clean: + rm -f *.iec + rm -f *.err + rm -f *.err2 + rm -f *.out + rm -f *.out2 diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/basic_code.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/basic_code.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,685 @@ +(* This file includes normal standard ST and IL code. + * This code is then included into other tests, once + * possibly strange things have been defined. + * + * Including this normal code will test whether the strange + * things somehow breack the correct parsing and compiling + * of normal code. + * + * Code in this file must not use the XXXX identfier! + *) + + + +(***************************************************************************) +(* Test if generic IL code is not affected by any previous declarations... *) +(***************************************************************************) + + +(* Test each IL operator *) +(* Since our compiler needs to distinguish + * between IL and ST code, we place each IL + * operator in a distinct function, to test whether + * the use of that IL operator as the first IL + * instruction does not confuse the logic + * use to determine whether ST or IL is being parsed. + *) + +function bar0005 : int + var + e_1, f_1 : int; + end_var + & 10 +end_function + + + +function bar0006 : int + var + e_1, f_1 : int; + end_var + &N 10 +end_function + + + +function bar0007 : int + var + e_1, f_1 : int; + end_var + ADD 10 +end_function + + + +function bar0008 : int + var + e_1, f_1 : int; + end_var + AND TRUE +end_function + + +function bar0009 : int + var + e_1, f_1 : int; + end_var + ANDN TRUE +end_function + + +function_block bar0010 + var + e_1, f_1 : int; + tt : TP; + end_var + CAL tt +end_function_block + + +function_block bar0011 + var + e_1, f_1 : int; + tt : TP; + end_var + CALC tt +end_function_block + + +function_block bar0012 + var + e_1, f_1 : int; + tt : TP; + end_var + CALCN tt +end_function_block + + +function_block bar0013 + var + e_1, f_1 : int; + tt : CTUD; + end_var + CU tt +end_function_block + + +function_block bar0014 + var + e_1, f_1 : int; + tt : CTUD; + end_var + CD tt +end_function_block + + +function_block bar0015 + var + e_1, f_1 : int; + tt : R_TRIG; + end_var + CLK tt +end_function_block + + +function bar0016 : int + var + e_1, f_1 : int; + end_var + DIV e_1 +end_function + + +function bar0017 : int + var + e_1, f_1 : int; + end_var + EQ e_1 +end_function + + +function bar0018 : int + var + e_1, f_1 : int; + end_var + GE e_1 +end_function + + +function bar0019 : int + var + e_1, f_1 : int; + end_var + GT e_1 +end_function + + +function_block bar0020 + var + e_1, f_1 : int; + tt : TP; + end_var + IN tt +end_function_block + + +function bar0021 : int + var + e_1, f_1 : int; + end_var + JMP ll + ll: LD FALSE +end_function + + + +function bar0022 : int + var + e_1, f_1 : int; + end_var + JMPC ll + ll: LD FALSE +end_function + + +function bar0023 : int + var + e_1, f_1 : int; + end_var + JMPCN ll + ll: LD FALSE +end_function + + + +function bar0024 : int + var + e_1, f_1 : int; + end_var + LD TRUE +end_function + + +function bar0025 : int + var + e_1, f_1 : int; + end_var + LDN TRUE +end_function + + +function bar0026 : int + var + e_1, f_1 : int; + end_var + LE e_1 +end_function + + +function bar0027 : int + var + e_1, f_1 : int; + end_var + LT e_1 +end_function + + +function bar0028 : int + var + e_1, f_1 : int; + end_var + MOD e_1 +end_function + + +function bar0029 : int + var + e_1, f_1 : int; + end_var + MUL e_1 +end_function + + +function bar0030 : int + var + e_1, f_1 : int; + end_var + NE e_1 +end_function + + +function bar0031 : int + var + e_1, f_1 : int; + end_var + NOT TRUE +end_function + + +function bar0032 : int + var + e_1, f_1 : int; + end_var + OR TRUE +end_function + + +function bar0033 : int + var + e_1, f_1 : int; + end_var + ORN TRUE +end_function + + +function_block bar0034 + var + e_1, f_1 : int; + tt : TP; + end_var + PT tt +end_function_block + + +function_block bar0035 + var + e_1, f_1 : int; + tt : CTUD; + end_var + PV tt +end_function_block + + +function bar0036 : int + var + e_1, f_1 : bool; + end_var + R e_1 (* IL operand *) +end_function + + +function_block bar0037 + var + e_1, f_1 : int; + tt : SR; + end_var + R tt (* FB call *) +end_function_block + + +function_block bar0038 + var + e_1, f_1 : int; + tt : SR; + end_var + R1 tt (* FB call *) +end_function_block + + +function bar0039 : int + var + e_1, f_1 : bool; + end_var + RET +end_function + + +function bar0040 : int + var + e_1, f_1 : bool; + end_var + RETC +end_function + + +function bar0041 : int + var + e_1, f_1 : bool; + end_var + RETCN +end_function + + +function bar0042 : int + var + e_1, f_1 : bool; + end_var + S e_1 +end_function + + +function_block bar0043 + var + e_1, f_1 : int; + tt : SR; + end_var + S1 tt (* FB call *) +end_function_block + + +function bar0044 : int + var + e_1, f_1 : bool; + end_var + ST e_1 +end_function + + +function bar0045 : int + var + e_1, f_1 : bool; + end_var + STN e_1 +end_function + + +function bar0046 : int + var + e_1, f_1 : int; + end_var + SUB e_1 +end_function + + +function bar0047 : int + var + e_1, f_1 : bool; + end_var + XOR e_1 +end_function + + +function bar0048 : int + var + e_1, f_1 : bool; + end_var + XORN e_1 +end_function + + + + + + + + + +(***************************************************************************) +(* Test if generic ST code is not affected by any previous declarations... *) +(***************************************************************************) + +(* A helper FUNCTION BLOCK declaration *) +function_block bar1000 + var_input + a_1, b_1: int; + end_var + var_output + c_1, d_1: int; + end_var + c_1 := 10 + b_1; +end_function_block + + +(* A FUNCTION declaration *) +function bar1001 : int + var_input + a_1, b_1: int; + end_var + var_output + c_1, d_1: int; + end_var + c_1 := 10 + b_1; +end_function + + +(* Generic ST code *) + +function_block bar1002 + var + e_1, f_1 : int; + g_1 : int; + fb : bar1000; + end_var + fb(g_1, 20); + fb (10, g_1, e_1, f_1); + fb (a_1 := g_1, b_1:=g_1, c_1=>g_1, d_1=>f_1); + fb(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>g_1); + fb (c_1=>g_1, a_1:=20, d_1=>f_1); + g_1 := fb.c_1; + fb.a_1 := g_1 + g_1 * 2 * (g_1) / bar1001(g_1, 10, g_1, e_1) MOD g_1 MOD g_1 ** g_1; + IF (g_1 >= 10) THEN g_1 := 10; END_IF; + CASE (g_1 + 10) OF + 10: g_1 := 10; + 10..20:g_1 := 20; + ELSE g_1 := 20; + END_CASE; + FOR g_1 := 10 TO 20 BY 2 DO + g_1 := g_1 + 1; + END_FOR; + FOR e_1 := g_1 TO 20 DO + g_1 := g_1 + 1; + END_FOR; + FOR e_1 := 10 TO g_1 BY 2 DO + g_1 := g_1 + 1; + END_FOR; + FOR e_1 := 10 TO g_1 DO + g_1 := g_1 + 1; + END_FOR; + FOR e_1 := 10 TO 20 BY g_1 DO + g_1 := g_1 + 1; + END_FOR; + WHILE (g_1 >= 10) DO + g_1 := 10; + END_WHILE; + REPEAT g_1 := 10; UNTIL (g_1 >= 10) END_REPEAT; +end_function_block + + + + + + + + + + +(****************************************************************************) +(* Test if generic SFC code is not affected by any previous declarations... *) +(****************************************************************************) + +PROGRAM bar2001 + VAR + QX1 AT %QX1 : BOOL := 1; + QX2 AT %QX2 : BOOL := 0; + QX3 AT %QX3 : BOOL; + IX1 AT %IX1 : BOOL; + IX2 AT %IX2 : BOOL; + IX3 AT %IX3 : BOOL; + END_VAR + VAR + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + STEP STEP1: + ONSTEP1(); + END_STEP + + ACTION ONSTEP1: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION + + TRANSITION (PRIORITY := 4) FROM STEP1 TO STEP2 + := IX2 = TRUE; + END_TRANSITION + + STEP STEP2: + INLINE1(D, T#1s); + END_STEP + + ACTION INLINE1: + QX1 := QX2 XOR QX1; QX2 := NOT QX2; + END_ACTION + + TRANSITION transition_id1 FROM STEP2 TO A1 + := QX1 = FALSE AND QX2 = FALSE; + END_TRANSITION + + STEP A1: + INLINE2(DS, T#1s); + END_STEP + + ACTION INLINE2: + IX1 := TRUE; + END_ACTION + + TRANSITION transition_id2 (PRIORITY := 3) FROM A1 TO STEP2 + := IX1 = TRUE; + END_TRANSITION + + TRANSITION FROM STEP2 TO (D1, D2, D3) + := QX1 = TRUE AND QX2 = TRUE; + END_TRANSITION + + STEP D1: + INLINE5(L, T#1s); + END_STEP + + ACTION INLINE5: + QX1 := FALSE; + END_ACTION + + TRANSITION FROM D1 TO E1 + := NOT ( QX1 OR QX2 OR QX3 ); + END_TRANSITION + + STEP E1: + INLINE8(N); + END_STEP + + ACTION INLINE8: + QX1 := TRUE; + END_ACTION + + TRANSITION FROM (E1, E2, E3) TO GO + := QX1 AND QX2 AND QX3; + END_TRANSITION + + STEP D2: + INLINE6(P); + END_STEP + + ACTION INLINE6: + QX2 := FALSE; + END_ACTION + + TRANSITION FROM D2 TO E2 + := NOT ( QX1 OR QX2 OR QX3 ); + END_TRANSITION + + STEP E2: + INLINE9(R); + END_STEP + + ACTION INLINE9: + QX2 := TRUE; + END_ACTION + + STEP D3: + INLINE7(S); + END_STEP + + ACTION INLINE7: + QX2 := FALSE; + END_ACTION + + TRANSITION FROM D3 TO E3 + := NOT ( QX1 OR QX2 OR QX3 ); + END_TRANSITION + + STEP E3: + INLINE10(SD, T#1s); + END_STEP + + ACTION INLINE10: + QX3 := TRUE; + END_ACTION + + TRANSITION FROM STEP2 TO A3 + := QX1 = TRUE AND QX2 = FALSE; + END_TRANSITION + + STEP A3: + INLINE4(SL, T#1s); + END_STEP + + ACTION INLINE4: + IX1 := TRUE; + END_ACTION + + TRANSITION FROM A3 TO STEP2 + := IX1 = TRUE; + END_TRANSITION + + TRANSITION FROM STEP2 TO A2 + := QX1 = FALSE AND QX2 = TRUE; + END_TRANSITION + + STEP A2: + INLINE3(L, delta_1); + END_STEP + + ACTION INLINE3: + IX1 := FALSE; + END_ACTION + + TRANSITION FROM A2 TO STEP2 + := IX1 = FALSE; + END_TRANSITION + + STEP A01: + INLINE01(L, delta_1, IX1, QX1); + END_STEP + + ACTION INLINE01: + IX1 := FALSE; + END_ACTION + + TRANSITION FROM STEP2 TO A01 + := IX1 = FALSE; + END_TRANSITION + + STEP A02: + INLINE01(L, delta_1, IX1, QX1); + INLINE1 (L, delta_1, IX1, QX1); + INLINE2 (S); + INLINE3 (); + END_STEP + + TRANSITION FROM STEP2 TO A02 + := IX1 = FALSE; + END_TRANSITION +END_PROGRAM + + + + + + +(*********************************************************************************) +(* Test if generic CONFIGURATION is not affected by any previous declarations... *) +(*********************************************************************************) + +CONFIGURATION CONF0001 + RESOURCE STD_RESSOURCE ON BEREMIZ + TASK STD_TASK(INTERVAL := t#100ms,PRIORITY := 0); + PROGRAM MAIN_INSTANCE : bar2001; + END_RESOURCE +END_CONFIGURATION diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier.txt Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,57 @@ +################ +# IL operators # +################ +# which are not simultaneously +# - keywords (AND, OR, NOT, MOD, XOR), +# - or standard funtion name (which by implication are also keywords) +# (AND, OR, NOT, MOD, XOR, as well as, GE, GT, LE, LT, EQ, NE, SUB, ADD, MUL, DIV) +# - or standard function block name (which by implication are also keywords) +# - invalid identifier name (&, &N) +ANDN +CAL +CALC +CALCN +CD +CLK +CU +IN +JMP +JMPC +JMPCN +LD +LDN +ORN +PT +PV +R +R1 +RET +RETC +RETCN +S +S1 +ST +STN +XORN + + +################## +# SFC qualifiers # +################## +D +DS +L +N +P +#R -> also an IL operator +#S -> also an IL operator +SD +SL + + +##################### +# Task initialisers # +##################### +PRIORITY +SINGLE +INTERVAL diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_configuration.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_configuration.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,48 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * CONFIGURATION identifier + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* +#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN PT PV R R1 RET RETC RETCN S S1 ST STN XORN +#SFC_qualifiers D DS L N P #R #S SD SL + NOTE: R and S are identical to IL operators!! +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + + + +(* a helper program *) +PROGRAM bar000 +VAR_INPUT + a_1 : BOOL; +END_VAR +VAR_OUTPUT + b_1 : BOOL; +END_VAR + a_1 := TRUE; +END_PROGRAM + + + (* using in program parameter *) +CONFIGURATION XXXX + TASK fast(PRIORITY := 4); + PROGRAM foo WITH fast: + bar000(a_1 := TRUE); +END_CONFIGURATION + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_datatype.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_datatype.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,46 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * derived data type identifier + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* +#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN PT PV R R1 RET RETC RETCN S S1 ST STN XORN +#SFC_qualifiers D DS L N P #R #S SD SL + NOTE: R and S are identical to IL operators!! +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + + + + +TYPE + XXXX : real := 50; +END_TYPE + + + +function foo : int + var_input + a_1, b_1: XXXX; + end_var + var + c_1, d_1: int; + end_var + c_1 := 0; +end_function + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_enumerationvalue.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_enumerationvalue.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,60 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * enumeration value + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* +#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN PT PV R R1 RET RETC RETCN S S1 ST STN XORN +#SFC_qualifiers D DS L N P #R #S SD SL + NOTE: R and S are identical to IL operators!! +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + + + + +TYPE + enum_type00 : (enum_v1, XXXX, enum_v2) := XXXX; +END_TYPE + +TYPE + enum_type01 : (XXXX, enum_v2) := XXXX; +END_TYPE + +TYPE + enum_type02 : (enum_v1, XXXX) := XXXX; +END_TYPE + +TYPE + enum_type03 : (XXXX) := XXXX; +END_TYPE + + + + +function foo : int + var_input + a_1, b_1: int; + end_var + var + c_1, d_1: enum_type00; + end_var + c_1 := enum_type00#XXXX; + c_1 := XXXX; +end_function + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_function1.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_function1.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,164 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * FUNCTION declaration + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* This file is specific for identifiers identical to IL operators. + * See the note following the identifier list + *) +(* +#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN PT PV R R1 RET RETC RETCN S S1 ST STN XORN +#SFC_qualifiers #D #DS #L #N #P #R #S #SD #SL +#Task_initialisers #PRIORITY #SINGLE #INTERVAL +*) + +(* NOTE: The identifier as a function test has some special cases. + * Namely, when using IL operators as function names. + * For example, if a function LD has been previoulsy defined, + * The following IL code may be interpreted as either a + * function call or an IL operation + * LD 10 + * Due to undefined situations as the above, our + * IEC compiler currently will always interpret IL operator identifiers. + * inside IL code as an IL operator. + * This means that calling, from IL code, of functions whose names + * coincide with an IL operator is not possible. + * + * The following test code must therefore consider two possibilities: + * - if the identifier under test is an IL operator + * - if the identifier under test is not an IL operator + *) + + + + + +(* The FUNCTION declaration *) + +function XXXX : int + var_input + a_1, b_1: int; + end_var + XXXX := a_1 + b_1; +end_function + + + +(* Calling of the function from within ST code *) +function foo : int + var + c_1, d_1 : int; + e_1, f_1 : int; + end_var + d_1 := XXXX(c_1, d_1); + d_1 := XXXX(10, 20); + c_1 := XXXX(20, 22); + c_1 := XXXX(b_1 := e_1, a_1 := f_1); + c_1 := XXXX (a_1 := e_1, b_1 := f_1); +end_function + + + + +(* Calling of the function from within IL code *) +(* NOTE: some legal identifiers, for ex. IL operators, + * will not actually be interpreted as a reference to + * the function, but rather as an IL operator. + * However, no error should occur, as the compiler is written + * to give priority to interpreting it as an IL operator. + *) + +(* +function bar000 : int + var + e_1, f_1 : int; + end_var + XXXX 10 + LD 20 + XXXX 30 + XXXX 10, 20 + XXXX ( + b_1 := 10, + a_1 := 20 + ) + XXXX( + b_1 := 10, + a_1 := 20 + ) + XXXX ( + b_1 := 10 + ) + XXXX( + b_1 := 10 + ) +end_function +*) + + + + +(* Checking whether the use of XXXX will confuse the logic + * used to determine if a POU body is in IL or ST language. + *) + +(* +function bar001 : int + var + e_1, f_1 : int; + end_var + XXXX 10 +end_function + + +function bar002 : int + var + e_1, f_1 : int; + end_var + XXXX 10, 20 +end_function + + +function bar003 : int + var + e_1, f_1 : int; + end_var + XXXX( + b_1 := 10, + a_1 := 20 + ) +end_function + + +function bar004 : int + var + e_1, f_1 : int; + end_var + XXXX ( + b_1 := 10, + a_1 := 20 + ) +end_function +*) + + + + + + + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test"} + + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_function2.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_function2.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,149 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * FUNCTION declaration + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* This file is specific for identifiers NOT identical to IL operators. + * See the note following the identifier list + *) +(* +#IL_operators #ANDN #CAL #CALC #CALCN #CD #CLK #CU #IN #JMP #JMPC #JMPCN #LD #LDN #ORN +#IL_operators #PT #PV #R #R1 #RET #RETC #RETCN #S #S1 #ST #STN #XORN + NOTE: R and S are identical to IL operators!! +#SFC_qualifiers D DS L N P #R #S SD SL +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + +(* NOTE: The identifier as a function test has some special cases. + * Namely, when using IL operators as function names. + * For example, if a function LD has been previoulsy defined, + * The following IL code may be interpreted as either a + * function call or an IL operation + * LD 10 + * Due to undefined situations as the above, our + * IEC compiler currently will always interpret IL operator identifiers. + * inside IL code as an IL operator. + * This means that calling, from IL code, of functions whose names + * coincide with an IL operator is not possible. + * + * The following test code must therefore consider two possibilities: + * - if the identifier under test is an IL operator + * - if the identifier under test is not an IL operator + *) + + + +(* The FUNCTION declaration *) + +function XXXX : int + var_input + a_1, b_1: int; + end_var + XXXX := a_1 + b_1; +end_function + + + +(* Calling of the function from within ST code *) +function foo : int + var + c_1, d_1 : int; + e_1, f_1 : int; + end_var + d_1 := XXXX(c_1, d_1); + d_1 := XXXX(10, 20); + c_1 := XXXX(20, 22); + c_1 := XXXX(b_1 := e_1, a_1 := f_1); + c_1 := XXXX (a_1 := e_1, b_1 := f_1); +end_function + + + +(* Calling of the function from within IL code *) + +function bar000 : int + var + e_1, f_1 : int; + end_var + XXXX 10 + LD 20 + XXXX 30 + XXXX 10, 20 + XXXX ( + b_1 := 10, + a_1 := 20 + ) + XXXX( + b_1 := 10, + a_1 := 20 + ) + XXXX ( + b_1 := 10 + ) + XXXX( + b_1 := 10 + ) +end_function + + + +(* Checking whether the use of XXXX will confuse the logic + * used to determine if a POU body is in IL or ST language. + *) + +function bar001 : int + var + e_1, f_1 : int; + end_var + XXXX 10 +end_function + + +function bar002 : int + var + e_1, f_1 : int; + end_var + XXXX 10, 20 +end_function + + +function bar003 : int + var + e_1, f_1 : int; + end_var + XXXX( + b_1 := 10, + a_1 := 20 + ) +end_function + + +function bar004 : int + var + e_1, f_1 : int; + end_var + XXXX ( + b_1 := 10, + a_1 := 20 + ) +end_function + + + + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_functionblock.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_functionblock.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,103 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * FUNCTION_BLOCK declaration + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* +#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN +#IL_operators PT PV R R1 RET RETC RETCN S S1 ST STN XORN + NOTE: R and S are identical to IL operators!! +#SFC_qualifiers D DS L N P #R #S SD SL +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + + + + + +(* The FUNCTION BLOCK declaration *) +function_block XXXX + var_input + a_1, b_1: int; + end_var + var_output + c_1, d_1: int; + end_var + c_1 := 10 + b_1; +end_function_block + + +(* Calling of the function block from within ST code *) + +function_block foo + var + e_1, f_1 : int; + fb : XXXX; + end_var + fb(10, 20); + fb (10, 20, e_1, f_1); + fb (a_1 := 10, b_1:=20, c_1=>e_1, d_1=>f_1); + fb(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>f_1); + fb (c_1=>e_1, a_1:=20, d_1=>f_1); + f_1 := fb.c_1; + fb.a_1 := e_1; +end_function_block + + + +(* Calling of the function block from within IL code *) +function_block bar + var + e_1, f_1 : int; + fb : XXXX; + end_var + CAL fb + LD fb.a_1 + ST fb.b_1 + CAL fb (10) + CAL fb(30, 20, e_1, f_1) + CAL fb ( + a_1 := 10, + c_1 => f_1 + ) + CAL fb( + a_1 := 10, + c_1 => f_1 + ) +end_function_block + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + + + + + + + + + +(* + +CONFIGURATION +...... +using these XXXX identifiers within a configuration + +especially a task initialisation, as Priority, single and interval may clash here. +(they shouldn't, but if the parser has an error, they will....) + +END_CONFIGURATION + +*) diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_label.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_label.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,65 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * IL label name/identifier + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* +#IL_operators #ANDN #CAL #CALC #CALCN #CD #CLK #CU #IN #JMP #JMPC #JMPCN +#IL_operators #LD #LDN #ORN #PT #PV #R #R1 #RET #RETC #RETCN #S #S1 #ST #STN #XORN +#SFC_qualifiers D DS L N P #R #S SD SL + NOTE: R and S are identical to IL operators!! +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + +(* NOTE: Currently the matiec compiler does not yet support + * the use of identifiers identical to IL operators + * in IL code. In ther words, in IL code we cannot use + * identifiers identical to IL operators to identify variables, + * functions, etc... + * Identifiers identical to IL operators are therefore + * commented out. + *) + + + + + +function foo : int + var + e, f : bool; + end_var + + XXXX: R e + JMP XXXX +end_function + + + +function bar : int + var + e, f : bool; + end_var + + JMP XXXX + XXXX: R e +end_function + + + + + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_program.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_program.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,66 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * Program identifier + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* This file is specific for identifiers identical to IL operators. + * See the note following the identifier list + *) +(* +#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN PT PV R R1 RET RETC RETCN S S1 ST STN XORN +#SFC_qualifiers D DS L N P #R #S SD SL + NOTE: R and S are identical to IL operators!! +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + +(* NOTE: The identifier as a variable test has some special cases. + * Namely, when using IL operators as variable names. + * Even though the syntax of the IL language would not result + * in ambiguities in the above case, our parser does not currently + * allow the use of variables (with names identical to IL + * operators) within IL code. + * + * The following test code must therefore consider two possibilities: + * - if the identifier under test is an IL operator + * - if the identifier under test is not an IL operator + *) + + + + + + +PROGRAM XXXX +VAR_INPUT + a_1 : BOOL; +END_VAR + LD a_1 +END_PROGRAM + + + + + +CONFIGURATION config1 + TASK fast(PRIORITY := 4); + PROGRAM P1 WITH fast: + XXXX(a_1 := TRUE); +END_CONFIGURATION + + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_variable1.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_variable1.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,389 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * variable name/identifier + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* +#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN PT PV R R1 RET RETC RETCN S S1 ST STN XORN +#SFC_qualifiers D DS L N P #R #S SD SL + NOTE: R and S are identical to IL operators!! +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + +(* NOTE: The identifier as a variable test has some special cases. + * Namely, when using IL operators as variable names. + * Even though the syntax of the IL language would not result + * in ambiguities in the above case, our parser does not currently + * allow the use of variables (with names identical to IL + * operators) within IL code. + * + * The following test code must therefore consider two possibilities: + * - if the identifier under test is an IL operator + * - if the identifier under test is not an IL operator + * + * The test code in this file should be valid for all identifiers. + * Test code that is only valid for identifiers not identical to IL operators + * is placed in another test file (identifier_as_variable2.test). + *) + + + + +(* A helper FUNCTION BLOCK declaration *) +function_block foo_fb + var_input + a_1, b_1: int; + end_var + var_output + c_1, d_1: int; + end_var + c_1 := 10 + b_1; +end_function_block + + +(* A helper FUNCTION declaration *) +function foo_f1 : int + var_input + a_1, b_1: int; + end_var + var_output + c_1, d_1: int; + end_var + c_1 := 10 + b_1; +end_function + +(* Another helper FUNCTION declaration *) +function foo_f2 : int + var_input + a_1, b_1: foo_fb; + end_var + var_output + c_1, d_1: int; + end_var + c_1 := 10; +end_function + + + +(*********************************************************************) +(* Testing use of XXXX in several locations of variable declarations *) +(*********************************************************************) + +function bar01 : int + var_input + XXXX, a_1, b_1: int; + end_var + a_1 := 1; +end_function + +function_block bar02 + var_input + a_1, XXXX, b_1: int; + end_var + a_1 := 1; +end_function_block + +function_block bar03 + var_input + a_1, b_1, XXXX: int; + end_var + a_1 := 1; +end_function_block + + +function_block bar04 + var_output + XXXX, a_1, b_1: int; + end_var + a_1 := 1; +end_function_block + +function_block bar05 + var_output + a_1, XXXX, b_1: int; + end_var + a_1 := 1; +end_function_block + +function_block bar06 + var_output + a_1, b_1, XXXX: int; + end_var + a_1 := 1; +end_function_block + + +function_block bar07 + var_in_out + XXXX, a_1, b_1: int; + end_var + a_1 := 1; +end_function_block + +function_block bar08 + var_in_out + a_1, XXXX, b_1: int; + end_var + a_1 := 1; +end_function_block + +function_block bar09 + var_in_out + a_1, b_1, XXXX: int; + end_var + a_1 := 1; +end_function_block + +function_block bar10 + var_external + XXXX: int; + a_1 : int; + end_var + a_1 := 1; +end_function_block + +function_block bar11 + var_external + a_1 : int; + XXXX : int; + end_var + a_1 := 1; +end_function_block + +function_block bar12 + var + XXXX, a_1, b_1: int; + end_var + a_1 := 1; +end_function_block + +function_block bar13 + var + a_1, XXXX, b_1: int; + end_var + a_1 := 1; +end_function_block + +function_block bar14 + var + a_1, b_1, XXXX: int; + end_var + a_1 := 1; +end_function_block + + + +(************************************************) +(* Using XXXX as a standard variable name in ST *) +(************************************************) + +function_block bar90 + var + e_1, f_1 : int; + XXXX : int; + fb : foo_fb; + end_var + e_1 := bar01 (XXXX := 10); + e_1 := bar01 (a_1 := XXXX); + e_1 := bar01 (XXXX := XXXX); + fb(XXXX, 20); + fb (10, XXXX, e_1, f_1); + fb (a_1 := XXXX, b_1:=XXXX, c_1=>XXXX, d_1=>f_1); + fb(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>XXXX); + fb (c_1=>XXXX, a_1:=20, d_1=>f_1); + XXXX := fb.c_1; + fb.a_1 := XXXX + XXXX * 2 * (XXXX) / foo_f1(XXXX, 10, XXXX, e_1) MOD XXXX MOD XXXX ** XXXX; + IF (XXXX >= 10) THEN XXXX := 10; END_IF; + CASE (XXXX + 10) OF + 10: XXXX := 10; + 10..20:XXXX := 20; + ELSE XXXX := 20; + END_CASE; + FOR XXXX := 10 TO 20 BY 2 DO + XXXX := XXXX + 1; + END_FOR; + FOR e_1 := XXXX TO 20 DO + XXXX := XXXX + 1; + END_FOR; + FOR e_1 := 10 TO XXXX BY 2 DO + XXXX := XXXX + 1; + END_FOR; + FOR e_1 := 10 TO XXXX DO + XXXX := XXXX + 1; + END_FOR; + FOR e_1 := 10 TO 20 BY XXXX DO + XXXX := XXXX + 1; + END_FOR; + WHILE (XXXX >= 10) DO + XXXX := 10; + END_WHILE; + REPEAT XXXX := 10; UNTIL (XXXX >= 10) END_REPEAT; +end_function_block + + + +(* Using XXXX as a function block instance/variable name in ST *) + +function_block bar91 + var + e_1, f_1 : int; + XXXX : foo_fb; + end_var + XXXX(e_1, 20); + XXXX (10, e_1, e_1, f_1); + XXXX (a_1 := e_1, b_1:=e_1 , c_1=>e_1, d_1=>f_1); + XXXX(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>e_1); + XXXX (c_1=>e_1, a_1:=20, d_1=>f_1); + e_1 := XXXX.c_1; + XXXX.a_1 := e_1; + e_1 := foo_f2(XXXX, XXXX, e_1, f_1); + e_1 := foo_f2 (XXXX, XXXX); + e_1 := foo_f2 (c_1 => e_1, b_1 := XXXX, d_1 := 10, a_1 := XXXX); + e_1 := foo_f2 (b_1 := XXXX); +end_function_block + + + + +(************************************************) +(* Using XXXX as a standard variable name in IL *) +(************************************************) + +(* NOTE: Currently not supported for identifiers identical to IL operators. + * We therefore have two versions of this file, one with the following code + * commented out (used to test the identifiers that clash with IL operators) + * and a second with the following code included (used to test identifiers + * that do not clash with IL operators, such as PRIORITY, SINGLE, etc...) + *) + + +(* +function_block bar93 + var + e_1, f_1 : int; + end_var + + (* Calling function with input parameter named XXXX ** + bar01 ( + XXXX := 10 + ) +end_function_block +*) + + +(* +function_block bar99 +(...) +end_function_block +*) + + + + + + +(*************************************************************************************) +(* Using XXXX as a function block instance/variable/program name in a configuration. *) +(*************************************************************************************) + +(* a helper program *) +PROGRAM bar000 +VAR_INPUT + a_1, XXXX : BOOL; +END_VAR +VAR_OUTPUT + b_1 : BOOL; +END_VAR + a_1 := TRUE; +END_PROGRAM + + + (* using in program parameter *) +CONFIGURATION config01 + TASK fast(PRIORITY := 4); + PROGRAM foo WITH fast: + bar000(a_1 := TRUE, XXXX := FALSE); +END_CONFIGURATION + + + (* using as a program name *) +CONFIGURATION config02 + TASK fast(PRIORITY := 4); + PROGRAM XXXX WITH fast: + bar000(a_1 := TRUE, XXXX := FALSE); +END_CONFIGURATION + + + (* using as a resource name *) +CONFIGURATION config03 + RESOURCE XXXX on processor_type_1 + TASK fast(PRIORITY := 4); + PROGRAM foo WITH fast: + bar000(a_1 := TRUE, XXXX := FALSE); + END_RESOURCE +END_CONFIGURATION + + + (* using as a task name *) +CONFIGURATION config11 + TASK XXXX(PRIORITY := 4); + PROGRAM foo WITH XXXX: + bar000(a_1 := TRUE, XXXX := FALSE); +END_CONFIGURATION + + +CONFIGURATION config12 + TASK XXXX(SINGLE := 3, PRIORITY := 4); + PROGRAM P1 WITH XXXX: + bar000(a_1 := TRUE, XXXX := FALSE); +END_CONFIGURATION + + +CONFIGURATION config13 + TASK XXXX(INTERVAL := T#1s, PRIORITY := 4); + PROGRAM P1 WITH XXXX: + bar000(a_1 := TRUE, XXXX := FALSE); +END_CONFIGURATION + + +CONFIGURATION config14 + TASK XXXX(SINGLE := 3, INTERVAL := T#1s, PRIORITY := 4); + PROGRAM P1 WITH XXXX: + bar000(a_1 := TRUE, XXXX := FALSE); +END_CONFIGURATION + + + (* using as a variable name *) +CONFIGURATION config21 + VAR_GLOBAL + XXXX : bool; + END_VAR + TASK fast(PRIORITY := 4); + PROGRAM foo WITH fast: + bar000(a_1 := XXXX, b_1 => XXXX, XXXX := XXXX); +END_CONFIGURATION + + + + + + + + + + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_as_variable2.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_as_variable2.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,303 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * variable name/identifier + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* This file is specific for identifiers NOT identical to IL operators. + * See the note following the identifier list + *) +(* +#IL_operators #ANDN #CAL #CALC #CALCN #CD #CLK #CU #IN #JMP #JMPC #JMPCN #LD #LDN #ORN +#IL_operators #PT #PV #R #R1 #RET #RETC #RETCN #S #S1 #ST #STN #XORN + NOTE: R and S are identical to IL operators!! +#SFC_qualifiers D DS L N P #R #S SD SL +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + +(* NOTE: The identifier as a variable test has some special cases. + * Namely, when using IL operators as variable names. + * Even though the syntax of the IL language would not result + * in ambiguities in the above case, our parser does not currently + * allow the use of variables (with names identical to IL + * operators) within IL code. + * + * The following test code must therefore consider two possibilities: + * - if the identifier under test is an IL operator + * - if the identifier under test is not an IL operator + *) + + + +(* A helper FUNCTION BLOCK declaration *) +function_block foo_fb + var_input + a_1, b_1: int; + end_var + var_output + c_1, d_1: int; + end_var + c_1 := 10 + b_1; +end_function_block + + +(* A helper FUNCTION declaration *) +function foo_f1 : int + var_input + a_1, b_1: int; + end_var + var_output + c_1, d_1: int; + end_var + c_1 := 10 + b_1; +end_function + +(* Another helper FUNCTION declaration *) +function foo_f2 : int + var_input + a_1, b_1: foo_fb; + end_var + var_output + c_1, d_1: int; + end_var + c_1 := 10; +end_function + +(* Another helper FUNCTION declaration *) +function bar01 : int + var_input + XXXX, a_1, b_1: int; + end_var + a_1 := 1; +end_function + +(* Another helper FUNCTION_BLOCK declaration *) +function_block bar91 + var + e_1, f_1 : int; + XXXX : foo_fb; + end_var + e_1 := 0; +end_function_block + + + + + + + +(* Using XXXX as a standard variable name in IL *) + +(* NOTE: Currently not supported for identifiers identical to IL operators. + * We therefore have two versions of this file, one with the following code + * commented out (used to test the identifiers that clash with IL operators) + * and a second with the following code included (used to test identifiers + * that do not clash with IL operators, such as PRIORITY, SINGLE, etc...) + *) + + + +function_block bar92 + var + e_1, f_1 : int; + XXXX : bool; + fb : foo_fb; + fb2 : bar91; + end_var + (* IL operators that - acording to the standard - are not keywords *) + LD XXXX + LDN XXXX + ANDN XXXX + ORN XXXX + XORN XXXX + R XXXX + S XXXX + ST XXXX + STN XXXX + + (* IL operators that - acording to the standard - are also keywords *) + AND XXXX + OR XXXX + XOR XXXX + NOT XXXX +end_function_block + + +function_block bar93 + var + e_1, f_1 : int; + XXXX : int; + end_var + + (* IL operators that - acording to the standard - are also keywords *) + ADD XXXX + SUB XXXX + MUL XXXX + DIV XXXX + MOD XXXX + GE XXXX + GT XXXX + LE XXXX + LT XXXX + EQ XXXX + NE XXXX + + (* Calling function with input parameter named XXXX *) + bar01 ( + XXXX := 10 + ) + bar01 ( + a_1 := XXXX + ) + bar01 ( + XXXX := XXXX + ) +end_function_block + + + + +(* a helper function block *) +function_block bar94 + var_input + e_1, f_1 : int; + XXXX : foo_fb; + end_var + e_1 := XXXX.c_1; +end_function_block + + +function_block bar95 + var + e_1, f_1 : int; + XXXX : foo_fb; + fb_1 : bar93; + end_var + CAL XXXX(10) + CAL XXXX (e_1) + CAL XXXX (10, e_1, e_1, f_1) + CAL XXXX ( + a_1 := 10, + b_1 := e_1, + c_1 => e_1, + d_1 => f_1 + ) + CAL XXXX ( + a_1 := 10, + c_1 => e_1 + ) + + CALC XXXX(10) + CALC XXXX (e_1) + CALC XXXX (10, e_1, e_1, f_1) + CALC XXXX ( + a_1 := 10, + b_1 := e_1, + c_1 => e_1, + d_1 => f_1 + ) + CALC XXXX ( + a_1 := 10, + c_1 => e_1 + ) + + CALCN XXXX(10) + CALCN XXXX (e_1) + CALCN XXXX (10, e_1, e_1, f_1) + CALCN XXXX ( + a_1 := 10, + b_1 := e_1, + c_1 => e_1, + d_1 => f_1 + ) + CALCN XXXX ( + a_1 := 10, + c_1 => e_1 + ) + + LD XXXX.a_1 + ST XXXX.b_1 + LD fb_1.XXXX + ST fb_1.XXXX + LD fb_1.XXXX.a_1 + ST fb_1.XXXX.a_1 + + LD XXXX + foo_f2 XXXX, e_1, f_1 + foo_f2 ( + a_1 := XXXX, + b_1 := XXXX, + c_1 => e_1, + d_1 => f_1 + ) + + (* Calling function with input parameter named XXXX *) + bar01 ( + XXXX := 10 + ) + bar01 ( + a_1 := XXXX.a_1 + ) + bar01 ( + XXXX := XXXX.a_1 + ) +end_function_block + + +function_block bar96 + var + e_1, f_1 : int; + XXXX : CTUD; + end_var + CU XXXX + CD XXXX + PV XXXX +end_function_block + + +function_block bar97 + var + e_1, f_1 : int; + XXXX : R_TRIG; + end_var + CLK XXXX +end_function_block + + + +function_block bar98 + var + e_1, f_1 : int; + XXXX : TP; + end_var + IN XXXX + PT XXXX +end_function_block + + + +function_block bar99 + var + e_1, f_1 : int; + XXXX : SR; + end_var + R1 XXXX + S1 XXXX +end_function_block + + + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/identifier_in_sfc.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/identifier_in_sfc.test Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,611 @@ +(* Test whether the keyword XXXX may be used as an identifier for: + * STEP, ACTION and TRANSITION name/identifier + * + * The XXXX names in the following code are merely a placeholder. + * They will be replaced by several identifiers before actual testing + * of the compiler. + *) + +(* The identifiers that will replace the XXXX + * must be placed on a line starting with # + * All identifiers preceded by # are ignored! + * The identifier list must be placed inside an IEC 61131-3 comment. + *) +(* +#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN +#IL_operators LD LDN ORN PT PV R R1 RET RETC RETCN S S1 ST STN XORN +#SFC_qualifiers D DS L N P #R #S SD SL + NOTE: R and S are identical to IL operators!! +#Task_initialisers PRIORITY SINGLE INTERVAL +*) + + + +(* Use of XXXX as a STEP identifier *) + +PROGRAM bar01 + VAR + IX1 AT %IX1 : BOOL; + IX2 AT %IX2 : BOOL; + IX3 AT %IX3 : BOOL; + END_VAR + + INITIAL_STEP XXXX: + END_STEP + + STEP STEP1: + END_STEP + + STEP STEP2: + END_STEP + + TRANSITION FROM XXXX TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + TRANSITION FROM STEP1 TO XXXX + := IX1 = TRUE; + END_TRANSITION + + TRANSITION (PRIORITY := 4) FROM XXXX TO STEP2 + := IX2 = TRUE; + END_TRANSITION + + TRANSITION (PRIORITY := 4) FROM STEP2 TO XXXX + := IX2 = TRUE; + END_TRANSITION + + TRANSITION transition_id1 FROM STEP2 TO XXXX + := IX1 = FALSE AND IX3 = FALSE; + END_TRANSITION + + TRANSITION transition_id2 FROM XXXX TO STEP2 + := IX1 = FALSE AND IX3 = FALSE; + END_TRANSITION + + TRANSITION transition_id3 (PRIORITY := 3) FROM XXXX TO STEP2 + := IX3 = TRUE; + END_TRANSITION + + TRANSITION transition_id4 (PRIORITY := 5) FROM STEP2 TO XXXX + := IX3 = TRUE; + END_TRANSITION + + TRANSITION FROM (XXXX, STEP2) TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + TRANSITION FROM (STEP2, XXXX) TO STEP1 + := IX2 = FALSE; + END_TRANSITION + + TRANSITION FROM STEP1 TO (XXXX, STEP2) + := IX1 = TRUE; + END_TRANSITION + + TRANSITION FROM STEP1 TO (STEP2, XXXX) + := IX2 = TRUE; + END_TRANSITION +END_PROGRAM + + + + +(* Use of XXXX as a TRANSITION identifier *) + +PROGRAM bar02 + VAR + IX1 AT %IX1 : BOOL; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + END_STEP + + TRANSITION XXXX FROM GO TO STEP1 + := IX1 = FALSE AND IX3 = FALSE; + END_TRANSITION +END_PROGRAM + + + + +PROGRAM bar03 + VAR + IX1 AT %IX1 : BOOL; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + END_STEP + + TRANSITION XXXX (PRIORITY := 3) FROM GO TO STEP1 + := IX3 = TRUE; + END_TRANSITION +END_PROGRAM + + + + + +(* Use of XXXX as an ACTION identifier *) + + +PROGRAM bar20 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + STEP STEP1: + XXXX (); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + +PROGRAM bar21 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(N); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + +PROGRAM bar22 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(P); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + + +PROGRAM bar23 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(R); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + + + + +PROGRAM bar24 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(S); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + + + +PROGRAM bar25 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(D, T#1s); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + + + +PROGRAM bar26 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(L, T#1s); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + +PROGRAM bar27 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(DS, T#1s); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + + + +PROGRAM bar28 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(SD, T#1s); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + + + +PROGRAM bar29 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(SL, T#1s); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + + + +PROGRAM bar30 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(L, delta_1); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + + + +PROGRAM bar31 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + XXXX(L, delta_1, IX1, QX1); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION +END_PROGRAM + + + + + + +PROGRAM bar32 + VAR + QX1 : BOOL := 1; + QX2 : BOOL := 0; + QX3 : BOOL; + IX1 : BOOL; + IX2 : BOOL; + IX3 : BOOL; + delta_1 : TIME := T#1s; + END_VAR + + INITIAL_STEP GO: + END_STEP + + STEP STEP1: + INLINE1 (); + XXXX(L, delta_1, IX1, QX1); + INLINE2 (); + END_STEP + + STEP STEP2: + XXXX(L, delta_1, IX1, QX1); + INLINE1 (); + INLINE2 (); + END_STEP + + STEP STEP3: + INLINE1 (); + INLINE2 (); + XXXX(L, delta_1, IX1, QX1); + END_STEP + + TRANSITION FROM GO TO STEP1 + := IX1 = FALSE; + END_TRANSITION + + ACTION XXXX: + QX1 := TRUE; + QX2 := TRUE; + END_ACTION + + ACTION INLINE1: + IX1 := TRUE; + END_ACTION + + ACTION INLINE2: + IX1 := TRUE; + END_ACTION +END_PROGRAM + + + + + + + + + + +(* Checking whether the use of XXXX will confuse any other + * normal and correct IL or ST code. + *) +{#include "basic_code.test" } + diff -r ff5c92df0c78 -r f9e001952488 tests/syntax/identifier/runtests --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/syntax/identifier/runtests Sat Feb 09 08:57:14 2008 +0100 @@ -0,0 +1,29 @@ +#!/bin/bash + +# assume no error to start with... +error=0 + +for ff in `ls *.test` +do + for id in `cat $ff | grep "^#" | sed "s/#[^ ]*//g"` + do + sed s/XXXX/$id/g $ff > $ff"_"$id.iec + if `../../../iec2iec $ff"_"$id.iec -I ../../../lib > $ff"_"$id.out 2>$ff"_"$id.err` + # TODO before deciding test is success [OK] + # - test whether xxx.out has size <> 0 + # - test whether xxx.err has size == 0 + # - (?) test whether xxx.out2 is identical to xxx.out + # - (?) test whether xxx.err2 has size == 0 + # - perhaps produce a [WARN] instead of [ERROR] in cases of (?) + then echo "[ O K ] " $ff "->" $id + else echo "[ERROR] " $ff "->" $id; error=1 + fi +# ../../../iec2iec $ff"_"$id.out -I ../../../lib > $ff"_"$id.out2 2>$ff"_"$id.err2 + done +done + +echo +if `test $error = 1` + then echo "FAILURE -> At least one of the tests failed!" + else echo "SUCCESS -> All tests passed!" +fi