Module IECCheckerCore.Syntax

module TI = Tok_info
exception InternalError of string
module TimeValue : sig ... end

Representation of time interval

type operator =
  1. | NEG
  2. | NOT
  3. | POW
  4. | MUL
  5. | DIV
  6. | MOD
  7. | AND
    (*

    & AND

    *)
  8. | ADD
    (*
    *)
  9. | SUB
    (*
    *)
  10. | OR
    (*

    OR

    *)
  11. | XOR
    (*

    XOR

    *)
  12. | GT
    (*

    >

    *)
  13. | LT
    (*

    <

    *)
  14. | GE
    (*

    >=

    *)
  15. | LE
    (*

    <=

    *)
  16. | EQ
    (*

    =

    *)
  17. | NEQ
    (*

    <>

    *)
  18. | ASSIGN
    (*

    :=

    *)
  19. | ASSIGN_REF
    (*

    ?=

    *)
  20. | SENDTO
    (*

    =>

    *)
  21. | DEREF
    (*

    ^

    *)

Operators of the ST language

val operator_to_yojson : operator -> Yojson.Safe.t
val pp_operator : Ppx_deriving_runtime.Format.formatter -> operator -> Ppx_deriving_runtime.unit
val show_operator : operator -> Ppx_deriving_runtime.string
type access_specifier =
  1. | ASPublic
  2. | ASProtected
  3. | ASPrivate
  4. | ASInternal
val access_specifier_to_yojson : access_specifier -> Yojson.Safe.t
val pp_access_specifier : Ppx_deriving_runtime.Format.formatter -> access_specifier -> Ppx_deriving_runtime.unit
val show_access_specifier : access_specifier -> Ppx_deriving_runtime.string
type class_specifier =
  1. | CFinal
  2. | CAbstract
val class_specifier_to_yojson : class_specifier -> Yojson.Safe.t
val pp_class_specifier : Ppx_deriving_runtime.Format.formatter -> class_specifier -> Ppx_deriving_runtime.unit
val show_class_specifier : class_specifier -> Ppx_deriving_runtime.string
module type ID = sig ... end

Description of use -- nondefining occurrence of an identifier.

module SymVar : sig ... end

Identifier of symbolically represented variable

module DirVar : sig ... end

Identifier of directly represented variable

module FunctionBlock : sig ... end

Function Block identifier

module Function : sig ... end

Function identifier

module MethodPrototype : sig ... end

Method prototype

module VarUse : sig ... end

"Use" occurrence of the variable

type iec_data_type =
  1. | TyElementary of elementary_ty
  2. | TyGeneric of generic_ty
  3. | TyDerived of derived_ty
and elementary_ty =
  1. | NIL
  2. | STRING of int
    (*

    length

    *)
  3. | WSTRING of int
    (*

    length

    *)
  4. | CHAR of int
    (*

    length

    *)
  5. | WCHAR of int
    (*

    length

    *)
  6. | TIME
  7. | LTIME
  8. | SINT
  9. | INT
  10. | DINT
  11. | LINT
  12. | USINT
  13. | UINT
  14. | UDINT
  15. | ULINT
  16. | REAL
  17. | LREAL
  18. | DATE
  19. | LDATE
  20. | TIME_OF_DAY
  21. | TOD
  22. | LTOD
  23. | DATE_AND_TIME
  24. | LDATE_AND_TIME
  25. | DT
  26. | LDT
  27. | BOOL
  28. | BYTE
  29. | WORD
  30. | DWORD
  31. | LWORD
and generic_ty =
  1. | ANY
  2. | ANY_DERIVED
  3. | ANY_ELEMENTARY
  4. | ANY_MAGNITUDE
  5. | ANY_NUM
  6. | ANY_REAL
  7. | ANY_INT
  8. | ANY_BIT
  9. | ANY_STRING
  10. | ANY_DATE
and derived_ty =
  1. | DTyUseSingleElement of single_element_ty_spec
  2. | DTyUseStructType of string
  3. | DTyUseStringType of elementary_ty

"Use" occurence of the derived type.

and derived_ty_decl = string * derived_ty_decl_spec

Declaration of the derived type (defined with TYPE .. END_TYPE signature).

and derived_ty_decl_spec =
  1. | DTyDeclSingleElement of single_element_ty_spec * expr option
    (*

    initialization expression

    *)
  2. | DTyDeclSubrange of subrange_ty_spec * int
    (*

    initial value

    *)
  3. | DTyDeclEnumType of elementary_ty option * enum_element_spec list * enum_element_spec option
    (*

    default element

    *)
  4. | DTyDeclArrayType of arr_subrange list * iec_data_type * arr_inval option
    (*

    initial value

    *)
  5. | DTyDeclRefType of int * iec_data_type * ref_value option
    (*

    initial value

    *)
  6. | DTyDeclStructType of bool * struct_elem_spec list
    (*

    elements

    *)

Specification used in declaration of the derived type. It could be used with variables declaration in POU as well as to declare new types.

and single_element_ty_spec =
  1. | DTySpecElementary of elementary_ty
  2. | DTySpecSimple of string
    (*

    derived ty name

    *)
  3. | DTySpecEnum of string
  4. | DTySpecGeneric of generic_ty

Single element type specification (it works like typedef in C)

and subrange_ty_spec = elementary_ty * int * int

Subrange type specification

and enum_element_spec = {
  1. enum_type_name : string option;
    (*

    name of enum which this element belongs to

    *)
  2. elem_name : string;
    (*

    name of the element

    *)
  3. initial_value : constant option;
    (*

    initial value

    *)
}

Enum element specification

and arr_subrange = {
  1. arr_lower : int;
    (*

    lower bound

    *)
  2. arr_upper : int;
    (*

    upper bound

    *)
}

Subranges of array dimensions (e.g. 1..2, 1..3 means list with two subranges).

and arr_inval = constant list

Initial value of array elements. Values like 1,2(3),4 will be converted to 1,3,3,4 in the parser.

and struct_elem_spec = {
  1. struct_elem_name : string;
  2. struct_elem_loc : DirVar.t option;
  3. struct_elem_ty : single_element_ty_spec;
  4. struct_elem_init_value : struct_elem_init_value_spec option;
    (*

    initial values

    *)
}

Struct element specification

and struct_elem_init_value_spec =
  1. | StructElemInvalConstant of constant
  2. | StructElemInvalEnum of enum_element_spec
  3. | StructElemInvalStruct of string

Initial value of a struct element

and ref_value =
  1. | RefNull
  2. | RefSymVar of SymVar.t
  3. | RefFBInstance of string
    (*

    instance name

    *)
and constant =
  1. | CInteger of TI.t * int
  2. | CBool of TI.t * bool
  3. | CReal of TI.t * float
  4. | CString of TI.t * string
  5. | CPointer of TI.t * ref_value
  6. | CTimeValue of TI.t * TimeValue.t
  7. | CRange of TI.t * int * int
  8. | CEnumValue of TI.t * string
and statement =
  1. | StmExpr of TI.t * expr
  2. | StmElsif of TI.t * statement * statement list
  3. | StmIf of TI.t * statement * statement list * statement list * statement list
  4. | StmCase of TI.t * statement * case_selection list * statement list
  5. | StmFor of TI.t * for_control * statement list
  6. | StmWhile of TI.t * statement * statement list
  7. | StmRepeat of TI.t * statement list * statement
  8. | StmExit of TI.t
  9. | StmContinue of TI.t
  10. | StmReturn of TI.t
  11. | StmFuncCall of TI.t * Function.t * func_param_assign list
and expr =
  1. | ExprVariable of TI.t * VarUse.t
  2. | ExprConstant of TI.t * constant
  3. | ExprBin of TI.t * expr * operator * expr
  4. | ExprUn of TI.t * operator * expr
  5. | ExprFuncCall of TI.t * statement
and case_selection = {
  1. case : statement list;
  2. body : statement list;
}
and for_control = {
  1. assign : statement;
    (*

    control variable assignment

    *)
  2. range_end : expr;
    (*

    range end value

    *)
  3. range_step : expr;
    (*

    step

    *)
}
and func_param_assign = {
  1. name : string option;
    (*

    function param name

    *)
  2. stmt : statement;
    (*

    assignment or sendto statement

    *)
  3. inverted : bool;
    (*

    has inversion in output assignment

    *)
}
val iec_data_type_to_yojson : iec_data_type -> Yojson.Safe.t
val elementary_ty_to_yojson : elementary_ty -> Yojson.Safe.t
val generic_ty_to_yojson : generic_ty -> Yojson.Safe.t
val derived_ty_to_yojson : derived_ty -> Yojson.Safe.t
val derived_ty_decl_spec_to_yojson : derived_ty_decl_spec -> Yojson.Safe.t
val single_element_ty_spec_to_yojson : single_element_ty_spec -> Yojson.Safe.t
val subrange_ty_spec_to_yojson : subrange_ty_spec -> Yojson.Safe.t
val enum_element_spec_to_yojson : enum_element_spec -> Yojson.Safe.t
val arr_subrange_to_yojson : arr_subrange -> Yojson.Safe.t
val arr_inval_to_yojson : arr_inval -> Yojson.Safe.t
val struct_elem_spec_to_yojson : struct_elem_spec -> Yojson.Safe.t
val struct_elem_init_value_spec_to_yojson : struct_elem_init_value_spec -> Yojson.Safe.t
val ref_value_to_yojson : ref_value -> Yojson.Safe.t
val constant_to_yojson : constant -> Yojson.Safe.t
val statement_to_yojson : statement -> Yojson.Safe.t
val expr_to_yojson : expr -> Yojson.Safe.t
val case_selection_to_yojson : case_selection -> Yojson.Safe.t
val for_control_to_yojson : for_control -> Yojson.Safe.t
val func_param_assign_to_yojson : func_param_assign -> Yojson.Safe.t
val pp_iec_data_type : Ppx_deriving_runtime.Format.formatter -> iec_data_type -> Ppx_deriving_runtime.unit
val show_iec_data_type : iec_data_type -> Ppx_deriving_runtime.string
val pp_elementary_ty : Ppx_deriving_runtime.Format.formatter -> elementary_ty -> Ppx_deriving_runtime.unit
val show_elementary_ty : elementary_ty -> Ppx_deriving_runtime.string
val pp_generic_ty : Ppx_deriving_runtime.Format.formatter -> generic_ty -> Ppx_deriving_runtime.unit
val show_generic_ty : generic_ty -> Ppx_deriving_runtime.string
val pp_derived_ty : Ppx_deriving_runtime.Format.formatter -> derived_ty -> Ppx_deriving_runtime.unit
val show_derived_ty : derived_ty -> Ppx_deriving_runtime.string
val pp_derived_ty_decl : Ppx_deriving_runtime.Format.formatter -> derived_ty_decl -> Ppx_deriving_runtime.unit
val show_derived_ty_decl : derived_ty_decl -> Ppx_deriving_runtime.string
val pp_derived_ty_decl_spec : Ppx_deriving_runtime.Format.formatter -> derived_ty_decl_spec -> Ppx_deriving_runtime.unit
val show_derived_ty_decl_spec : derived_ty_decl_spec -> Ppx_deriving_runtime.string
val pp_single_element_ty_spec : Ppx_deriving_runtime.Format.formatter -> single_element_ty_spec -> Ppx_deriving_runtime.unit
val show_single_element_ty_spec : single_element_ty_spec -> Ppx_deriving_runtime.string
val pp_subrange_ty_spec : Ppx_deriving_runtime.Format.formatter -> subrange_ty_spec -> Ppx_deriving_runtime.unit
val show_subrange_ty_spec : subrange_ty_spec -> Ppx_deriving_runtime.string
val pp_enum_element_spec : Ppx_deriving_runtime.Format.formatter -> enum_element_spec -> Ppx_deriving_runtime.unit
val show_enum_element_spec : enum_element_spec -> Ppx_deriving_runtime.string
val pp_arr_subrange : Ppx_deriving_runtime.Format.formatter -> arr_subrange -> Ppx_deriving_runtime.unit
val show_arr_subrange : arr_subrange -> Ppx_deriving_runtime.string
val pp_arr_inval : Ppx_deriving_runtime.Format.formatter -> arr_inval -> Ppx_deriving_runtime.unit
val show_arr_inval : arr_inval -> Ppx_deriving_runtime.string
val pp_struct_elem_spec : Ppx_deriving_runtime.Format.formatter -> struct_elem_spec -> Ppx_deriving_runtime.unit
val show_struct_elem_spec : struct_elem_spec -> Ppx_deriving_runtime.string
val pp_struct_elem_init_value_spec : Ppx_deriving_runtime.Format.formatter -> struct_elem_init_value_spec -> Ppx_deriving_runtime.unit
val show_struct_elem_init_value_spec : struct_elem_init_value_spec -> Ppx_deriving_runtime.string
val pp_ref_value : Ppx_deriving_runtime.Format.formatter -> ref_value -> Ppx_deriving_runtime.unit
val show_ref_value : ref_value -> Ppx_deriving_runtime.string
val pp_constant : Ppx_deriving_runtime.Format.formatter -> constant -> Ppx_deriving_runtime.unit
val show_constant : constant -> Ppx_deriving_runtime.string
val pp_statement : Ppx_deriving_runtime.Format.formatter -> statement -> Ppx_deriving_runtime.unit
val show_statement : statement -> Ppx_deriving_runtime.string
val pp_expr : Ppx_deriving_runtime.Format.formatter -> expr -> Ppx_deriving_runtime.unit
val show_expr : expr -> Ppx_deriving_runtime.string
val pp_case_selection : Ppx_deriving_runtime.Format.formatter -> case_selection -> Ppx_deriving_runtime.unit
val show_case_selection : case_selection -> Ppx_deriving_runtime.string
val pp_for_control : Ppx_deriving_runtime.Format.formatter -> for_control -> Ppx_deriving_runtime.unit
val show_for_control : for_control -> Ppx_deriving_runtime.string
val pp_func_param_assign : Ppx_deriving_runtime.Format.formatter -> func_param_assign -> Ppx_deriving_runtime.unit
val show_func_param_assign : func_param_assign -> Ppx_deriving_runtime.string
val stmt_get_ti : statement -> TI.t
val stmt_get_id : statement -> int
val stmt_to_string : statement -> string
val expr_get_ti : expr -> TI.t
val expr_get_id : expr -> int
val c_is_zero : constant -> bool

Return true if constant value is zero, false otherwise

val c_get_str_value : constant -> string

Return string representation for value of a given constant

val c_get_ti : constant -> TI.t

Return token info of a given constant

val c_add : constant -> constant -> constant

Add value to existing constant.

val c_from_expr : expr -> constant option

Convert given expr to const.

val c_from_expr_exn : expr -> constant

Convert given expr to const. Raise an InternalError exception if given expr is not constant.

val ety_is_integer : elementary_ty -> bool
val ety_is_string : elementary_ty -> bool
module Task : sig ... end

Task configuration. See: 6.8.2 Tasks

module ProgramConfig : sig ... end
module VarDecl : sig ... end

Declaration of the IEC variable

type function_decl = {
  1. id : Function.t;
  2. return_ty : iec_data_type;
  3. variables : VarDecl.t list;
  4. statements : statement list;
}

Function declaration

val function_decl_to_yojson : function_decl -> Yojson.Safe.t
type fb_decl = {
  1. id : FunctionBlock.t;
  2. variables : VarDecl.t list;
  3. statements : statement list;
}

Function block declaration

val fb_decl_to_yojson : fb_decl -> Yojson.Safe.t
type program_decl = {
  1. is_retain : bool;
  2. name : string;
  3. variables : VarDecl.t list;
    (*

    Variables declared in this program

    *)
  4. statements : statement list;
}
val program_decl_to_yojson : program_decl -> Yojson.Safe.t
type class_decl = {
  1. specifier : class_specifier option;
  2. class_name : string;
  3. parent_name : string option;
    (*

    Name of the parent class.

    *)
  4. interfaces : string list;
    (*

    Names of the implemented interfaces.

    *)
  5. variables : VarDecl.t list;
    (*

    Variables declared in this class.

    *)
  6. methods : method_decl list;
}
and interface_decl = {
  1. interface_name : string;
  2. parents : string list;
    (*

    Names of the parent interfaces.

    *)
  3. method_prototypes : MethodPrototype.t list;
    (*

    Prototypes of the methods provided by this interface.

    *)
}
and method_decl = {
  1. prototype : MethodPrototype.t;
  2. statements : statement list;
  3. aspec : access_specifier;
    (*

    Access specifier.

    *)
  4. cspec : class_specifier option;
    (*

    Class specifier: ABSTRACT or FINAL.

    *)
  5. override : bool;
    (*

    True if the method is marked with OVERRIDE keyword.

    *)
}
val class_decl_to_yojson : class_decl -> Yojson.Safe.t
val interface_decl_to_yojson : interface_decl -> Yojson.Safe.t
val method_decl_to_yojson : method_decl -> Yojson.Safe.t
type resource_decl = {
  1. name : string option;
    (*

    Resource name. Can be is skipped in case of single resource

    *)
  2. tasks : Task.t list;
  3. variables : VarDecl.t list;
    (*

    Global variables

    *)
  4. programs : ProgramConfig.t list;
    (*

    Configuration of program instances.

    *)
}
val resource_decl_to_yojson : resource_decl -> Yojson.Safe.t
type configuration_decl = {
  1. name : string;
  2. resources : resource_decl list;
  3. variables : VarDecl.t list;
    (*

    Global variables and access lists

    *)
  4. access_paths : string list;
}

Configuration element. See: 2.7 Configuration elements

val configuration_decl_to_yojson : configuration_decl -> Yojson.Safe.t
type iec_library_element =
  1. | IECFunction of int * function_decl
  2. | IECFunctionBlock of int * fb_decl
  3. | IECProgram of int * program_decl
  4. | IECClass of int * class_decl
  5. | IECInterface of int * interface_decl
  6. | IECConfiguration of int * configuration_decl
  7. | IECType of int * derived_ty_decl
val iec_library_element_to_yojson : iec_library_element -> Yojson.Safe.t
val mk_pou : [< `Function of function_decl | `FunctionBlock of fb_decl | `Program of program_decl | `Class of class_decl | `Interface of interface_decl | `Configuration of configuration_decl | `Type of derived_ty_decl ] -> iec_library_element
val get_pou_id : iec_library_element -> int

get_pou_id Get unique identifier of the given library element.

val get_pou_vars_decl : iec_library_element -> VarDecl.t list

get_pou_vars_decl Return variables declared for the given POU.

val derived_ty_decl_to_yojson : derived_ty_decl -> Yojson.Safe.t