tests/syntax/identifier/identifier_as_functionblock.test
author laurent
Wed, 13 Jul 2011 13:57:29 +0200
changeset 346 620fd98a021d
parent 108 f9e001952488
permissions -rwxr-xr-x
Adding BYTE operators visit functions in inlinefcall
108
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
     1
(* Test whether the keyword XXXX may be used as an identifier for:
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
     2
 * FUNCTION_BLOCK declaration
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
     3
 *
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
     4
 * The XXXX names in the following code are merely a placeholder.
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
     5
 * They will be replaced by several identifiers before actual testing
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
     6
 * of the compiler.
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
     7
 *)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
     8
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
     9
(* The identifiers that will replace the XXXX
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    10
 * must be placed on a line starting with #
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    11
 * All identifiers preceded by # are ignored!
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    12
 * The identifier list must be placed inside an IEC 61131-3 comment.
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    13
 *)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    14
(*
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    15
#IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN 
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    16
#IL_operators PT PV R R1 RET RETC RETCN S S1 ST STN XORN
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    17
     NOTE: R and S are identical to IL operators!!
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    18
#SFC_qualifiers D DS L N P #R #S SD SL   
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    19
#Task_initialisers PRIORITY SINGLE INTERVAL
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    20
*)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    21
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    22
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    23
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    24
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    25
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    26
(* The FUNCTION BLOCK declaration *)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    27
function_block XXXX
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    28
 var_input
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    29
  a_1, b_1: int;
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    30
 end_var
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    31
 var_output
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    32
  c_1, d_1: int;
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    33
 end_var
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    34
  c_1 := 10 + b_1;
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    35
end_function_block
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    36
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    37
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    38
(* Calling of the function block from within ST code *)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    39
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    40
function_block foo
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    41
 var
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    42
  e_1, f_1 : int;
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    43
  fb : XXXX;
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    44
 end_var
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    45
  fb(10, 20);
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    46
  fb (10, 20, e_1, f_1);
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    47
  fb (a_1 := 10, b_1:=20, c_1=>e_1, d_1=>f_1);
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    48
  fb(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>f_1);
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    49
  fb (c_1=>e_1, a_1:=20, d_1=>f_1);
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    50
  f_1 := fb.c_1;
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    51
  fb.a_1 := e_1;
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    52
end_function_block
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    53
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    54
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    55
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    56
(* Calling of the function block from within IL code *)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    57
function_block bar
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    58
 var
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    59
  e_1, f_1 : int;
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    60
  fb : XXXX;
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    61
 end_var
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    62
  CAL fb
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    63
  LD fb.a_1
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    64
  ST fb.b_1
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    65
  CAL fb (10)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    66
  CAL fb(30, 20, e_1, f_1)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    67
  CAL fb (
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    68
    a_1 := 10,
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    69
    c_1 => f_1
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    70
   )
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    71
  CAL fb(
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    72
    a_1 := 10,
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    73
    c_1 => f_1
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    74
   )
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    75
end_function_block
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    76
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    77
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    78
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    79
(* Checking whether the use of XXXX will confuse any other
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    80
 * normal and correct IL or ST code.
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    81
 *)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    82
{#include "basic_code.test" }
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    83
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    84
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    85
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    86
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    87
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    88
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    89
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    90
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    91
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    92
(*
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    93
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    94
CONFIGURATION
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    95
......
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    96
using these XXXX identifiers within a configuration
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    97
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    98
especially a task initialisation, as Priority, single and interval may clash here.
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
    99
(they shouldn't, but if the parser has an error, they will....)
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
   100
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
   101
END_CONFIGURATION
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
   102
f9e001952488 Regression tests. Test correct parsing of identifiers.
mario
parents:
diff changeset
   103
*)