Asllib.ASTAn Abstract Syntax Tree for ASL.
type position = Lexing.positiontype binop = | ANDBitvector bitwise and
*)| BANDBoolean and
*)| BEQBoolean equivalence
*)| BORBoolean or
*)| DIVInteger division
*)| DIVRMInexact integer division, with rounding towards negative infinity.
*)| EORBitvector bitwise exclusive or
*)| EQ_OPEquality on two base values of same type
*)| GTGreater than for int or reals
*)| GEQGreater or equal for int or reals
*)| IMPLBoolean implication
*)| LTLess than for int or reals
*)| LEQLess or equal for int or reals
*)| MODRemainder of integer division
*)| MINUSSubstraction for int or reals or bitvectors
*)| MULMultiplication for int or reals or bitvectors
*)| NEQNon equality on two base values of same type
*)| ORBitvector bitwise or
*)| PLUSAddition for int or reals or bitvectors
*)| POWExponentiation for ints
*)| RDIVDivision for reals
*)| SHLShift left for ints
*)| SHRShift right for ints
*)| BV_CONCATBit vector concatenation
*)Operations on base value of arity two.
Literals are the values written straight into ASL specifications. There is only literal constructors for a few concepts that could be encapsulated into an ASL value.
type literal = | L_Int of Z.t| L_Bool of bool| L_Real of Q.t| L_BitVector of Bitvector.t| L_String of string| L_Label of stringAn enumeration label, given by its name.
*)Main value type, parametric on its base values
type subprogram_type = | ST_ProcedureA procedure is a subprogram without return type, called from a statement.
*)| ST_FunctionA function is a subprogram with a return type, called from an expression.
*)| ST_GetterA getter is a special function called with a syntax similar to slices.
*)| ST_EmptyGetterAn empty getter is a special function called with a syntax similar to a variable. This is relevant only for V0.
*)| ST_SetterA setter is a special procedure called with a syntax similar to slice assignment.
*)| ST_EmptySetterAn empty setter is a special procedure called with a syntax similar to an assignment to a variable. This is relevant only for V0.
*)type expr_desc = | E_Literal of literal| E_Var of identifier| E_ATC of expr * tyAsserted type conversion
*)| E_Binop of binop * expr * expr| E_Unop of unop * expr| E_Call of call| E_Slice of expr * slice list| E_Cond of expr * expr * expr| E_GetArray of expr * exprE_GetArray base index Represents an access to an array given by the expression base at index index. When this node appears in the untyped AST, the index may either be integer-typed or enumeration-typed. When this node appears in the typed AST, the index can only be integer-typed.
| E_GetEnumArray of expr * exprAccess an array with an enumeration index. This constructor is only part of the typed AST.
*)| E_GetField of expr * identifier| E_GetFields of expr * identifier list| E_GetItem of expr * int| E_Record of ty * (identifier * expr) listRepresents a record or an exception construction expression.
*)| E_Tuple of expr list| E_Array of {}Initial value for an array of size length and of content value at each array cell.
This expression constructor is only part of the typed AST, i.e. it is only built by the type-checker, not any parser.
*)| E_EnumArray of {enum : identifier;labels : identifier list;value : expr;}Initial value for an array where the index is the enumeration enum, which declares the list of labels labels, and the content of each cell is given by value. enum is only used for pretty-printing.
This expression constructor is only part of the typed AST, i.e. it is only built by the type-checker, not any parser.
*)| E_Arbitrary of ty| E_Pattern of expr * patternExpressions. Parametric on the type of literals.
and pattern = pattern_desc annotatedand slice = | Slice_Single of exprSlice_Single i is the slice of length 1 at position i.
| Slice_Range of expr * exprSlice_Range (j, i) denotes the slice from i to j - 1.
| Slice_Length of expr * exprSlice_Length (i, n) denotes the slice starting at i of length n.
| Slice_Star of expr * exprSlice_Start (factor, length) denotes the slice starting at factor * length of length n.
Slices define lists of indices into arrays and bitvectors.
All positions mentioned above are inclusive.
and type_desc = | T_Int of constraint_kind| T_Bits of expr * bitfield list| T_Real| T_String| T_Bool| T_Enum of identifier list| T_Tuple of ty list| T_Array of array_index * ty| T_Record of field list| T_Exception of field list| T_Named of identifierA type variable.
*)Type descriptors.
and constraint_kind = | UnConstrainedThe normal, unconstrained, integer type.
*)| WellConstrained of int_constraint listAn integer type constrained from ASL syntax: it is the union of each constraint in the list.
*)| PendingConstrainedAn integer type whose constraint will be inferred during type-checking.
*)| Parameterized of uid * identifierA parameterized integer, the default type for parameters of function at compile time, with a unique identifier and the variable bearing its name.
*)The constraint_kind constrains an integer type to a certain subset.
and bitfield = | BitField_Simple of identifier * slice listA name and its corresponding slice
*)| BitField_Nested of identifier * slice list * bitfield listA name, its corresponding slice and some nested bitfields.
*)| BitField_Type of identifier * slice list * tyA name, its corresponding slice and the type of the bitfield.
*)Represent static slices on a given bitvector type.
and array_index = | ArrayLength_Expr of exprAn integer expression giving the length of the array.
*)| ArrayLength_Enum of identifier * identifier listAn enumeration name and its list of labels.
*)The type of indexes for an array.
and field = identifier * tyA field of a record-like structure.
and typed_identifier = identifier * tyAn identifier declared with its type.
type lexpr_desc = | LE_Discard| LE_Var of identifier| LE_Slice of lexpr * slice list| LE_SetArray of lexpr * exprLE_SetArray base index represents a write to an array given by the expression base at index index. When this node appears in the untyped AST, the index may either be integer-typed or enumeration-typed. When this node appears in the typed AST, the index can only be integer-typed.
| LE_SetEnumArray of lexpr * exprRepresents a write to an array with an enumeration index. This constructor is only part of the typed AST.
*)| LE_SetField of lexpr * identifier| LE_SetFields of lexpr * identifier list * (int * int) listLE_SetFields (le, fields, _) unpacks the various fields. Third argument is a type annotation.
*)| LE_Destructuring of lexpr listType of left-hand side of assignments.
and lexpr = lexpr_desc annotatedtype local_decl_item = | LDI_Var of identifierLDI_Var x is the variable declaration of the variable x, used for example in:
let x = 42;
.
*)| LDI_Tuple of identifier listLDI_Tuple names is the tuple declarations of names, for example:
let (x, y, z) = (1, 2, 3);
We expect the list to contain at least 2 items.
*)A left-hand side of a declaration statement. In the following example of a declaration statement, (2, 3, 4): (integer, integer, integer {0..32}) is the local declaration item:
let (x, -, z): (integer, integer, integer {0..32}) = (2, 3, 4);type stmt_desc = | S_Pass| S_Seq of stmt * stmt| S_Decl of local_decl_keyword * local_decl_item * ty option * expr option| S_Assign of lexpr * expr| S_Call of call| S_Return of expr option| S_Cond of expr * stmt * stmt| S_Assert of expr| S_For of {index_name : identifier;start_e : expr;dir : for_direction;end_e : expr;body : stmt;limit : expr option;}| S_While of expr * expr option * stmt| S_Repeat of stmt * expr * expr option| S_Throw of (expr * ty option) optionThe ty option is a type annotation added by the type-checker to be matched later with the catch guards. It is always None for the untyped AST and never None for the typed AST. The outer option is used to represent the implicit throw, such as throw;.
| S_Try of stmt * catcher list * stmt optionThe stmt option is the optional otherwise guard.
*)| S_Print of {args : expr list;newline : bool;debug : bool;}A call to print, as an explicit node as it does not require type-checking.
newline indicates if the print statement should add an extra new line after printing all the arguments. debug indicates if the print statement has been made using the ASLRef specific function __debug.
| S_UnreachableThe unreachable statement, as an explicit node as it has a specific control-flow behaviour.
*)| S_Pragma of identifier * expr listA pragma statement, as an explicit node to be used by tools which need AST level hints.
*)and case_alt = case_alt_desc annotatedand catcher = identifier option * ty * stmtThe optional name of the matched exception, the guard type and the statement to be executed if the guard matches.
type subprogram_body = | SB_ASL of stmtA normal body of a subprogram
*)| SB_Primitive of boolWhether or not this primitive is side-effecting
*)Represents the different types of subprogram bodies.
type func = {name : identifier;parameters : (identifier * ty option) list;args : typed_identifier list;body : subprogram_body;return_type : ty option;subprogram_type : subprogram_type;recurse_limit : expr option;builtin : bool;Builtin functions are treated specially when checking parameters at call sites - see Typing.insert_stdlib_param.
}Function types in the AST. For the moment, they represent getters, setters, functions, procedures and primitives.
Declaration keyword for global storage elements.
type global_decl = {keyword : global_decl_keyword;name : identifier;ty : ty option;initial_value : expr option;}Global declaration type
type decl_desc = | D_Func of func| D_GlobalStorage of global_decl| D_TypeDecl of identifier * ty * (identifier * field list) option| D_Pragma of identifier * expr listA global pragma, as an explicit node to be used by tools which need AST level hints.
*)Declarations, ie. top level statement in a asl file.
type t = decl listMain AST type.