package asli

  1. Overview
  2. Docs
type id = string
type typeid = string
type intLit = string
type bitsLit = string
type maskLit = string
type realLit = string
type hexLit = string
type i = int
type l =
  1. | Unknown
  2. | Int of string * l option
  3. | Generated of l
  4. | Range of Stdlib.Lexing.position * Stdlib.Lexing.position

Location tracking

type 'a annot = l * 'a
val pp_lexing_position : Stdlib.Lexing.position -> string
val pp_loc : l -> string
exception Parse_error_locn of l * string

Parsing exceptions (1/2)

type ident =
  1. | Ident of string
  2. | FIdent of string * int

Identifiers used for variable names, function names, etc.

There are two kinds of identifier:

  • Ident is generated by the parser - it is just a string
  • FIdent is generated by the disambiguation part of the typechecker and includes a unique label to distinguish different entities with the same name in the source syntax.
val pprint_ident : ident -> string
val addTag : ident -> int -> ident
val stripTag : ident -> ident
val name_of_FIdent : ident -> string
val addQualifier : string -> ident -> ident
val addPrefix : string -> ident -> ident
val addSuffix : ident -> string -> ident
val genericTyvar : int -> ident
val isGenericTyvar : ident -> bool
module Id : sig ... end

Type Identifiers

module StringSet : sig ... end
val typeIdents : StringSet.t Stdlib.ref
val addTypeIdent : ident -> unit
val isTypeIdent : string -> bool
type binop =
  1. | Binop_Eq
  2. | Binop_NtEq
  3. | Binop_Gt
  4. | Binop_GtEq
  5. | Binop_Lt
  6. | Binop_LtEq
  7. | Binop_Plus
  8. | Binop_Minus
  9. | Binop_Multiply
  10. | Binop_Divide
  11. | Binop_Power
  12. | Binop_Quot
  13. | Binop_Rem
  14. | Binop_Div
  15. | Binop_Mod
  16. | Binop_ShiftL
  17. | Binop_ShiftR
  18. | Binop_BoolAnd
  19. | Binop_BoolOr
  20. | Binop_BoolIff
  21. | Binop_BoolImplies
  22. | Binop_BitOr
  23. | Binop_BitEor
  24. | Binop_BitAnd
  25. | Binop_Append
  26. | Binop_Concat
  27. | Binop_DUMMY
type unop =
  1. | Unop_Negate
  2. | Unop_BoolNot
  3. | Unop_BitsNot
type ixtype =
  1. | Index_Enum of ident
  2. | Index_Range of expr * expr
and ty =
  1. | Type_Constructor of ident
  2. | Type_Bits of expr
  3. | Type_App of ident * expr list
  4. | Type_OfExpr of expr
  5. | Type_Register of intLit * (slice list * ident) list
  6. | Type_Array of ixtype * ty
  7. | Type_Tuple of ty list
and pattern =
  1. | Pat_LitInt of intLit
  2. | Pat_LitHex of hexLit
  3. | Pat_LitBits of bitsLit
  4. | Pat_LitMask of maskLit
  5. | Pat_Const of ident
  6. | Pat_Wildcard
  7. | Pat_Tuple of pattern list
  8. | Pat_Set of pattern list
  9. | Pat_Range of expr * expr
  10. | Pat_Single of expr
and expr =
  1. | Expr_If of expr * expr * e_elsif list * expr
  2. | Expr_Binop of expr * binop * expr
  3. | Expr_Unop of unop * expr
  4. | Expr_Field of expr * ident
  5. | Expr_Fields of expr * ident list
  6. | Expr_Slices of expr * slice list
  7. | Expr_In of expr * pattern
  8. | Expr_Var of ident
  9. | Expr_Parens of expr
  10. | Expr_Tuple of expr list
  11. | Expr_Unknown of ty
  12. | Expr_ImpDef of ty * string option
  13. | Expr_TApply of ident * expr list * expr list
  14. | Expr_Array of expr * expr
  15. | Expr_LitInt of intLit
  16. | Expr_LitHex of hexLit
  17. | Expr_LitReal of realLit
  18. | Expr_LitBits of bitsLit
  19. | Expr_LitMask of maskLit
  20. | Expr_LitString of string
and e_elsif =
  1. | E_Elsif_Cond of expr * expr
and slice =
  1. | Slice_Single of expr
  2. | Slice_HiLo of expr * expr
  3. | Slice_LoWd of expr * expr
type direction =
  1. | Direction_Up
  2. | Direction_Down
type lexpr =
  1. | LExpr_Wildcard
  2. | LExpr_Var of ident
  3. | LExpr_Field of lexpr * ident
  4. | LExpr_Fields of lexpr * ident list
  5. | LExpr_Slices of lexpr * slice list
  6. | LExpr_BitTuple of lexpr list
  7. | LExpr_Tuple of lexpr list
  8. | LExpr_Array of lexpr * expr
  9. | LExpr_Write of ident * expr list * expr list
  10. | LExpr_ReadWrite of ident * ident * expr list * expr list
type stmt =
  1. | Stmt_VarDeclsNoInit of ty * ident list * l
  2. | Stmt_VarDecl of ty * ident * expr * l
  3. | Stmt_ConstDecl of ty * ident * expr * l
  4. | Stmt_Assign of lexpr * expr * l
  5. | Stmt_FunReturn of expr * l
  6. | Stmt_ProcReturn of l
  7. | Stmt_Assert of expr * l
  8. | Stmt_Unpred of l
  9. | Stmt_ConstrainedUnpred of l
  10. | Stmt_ImpDef of ident * l
  11. | Stmt_Undefined of l
  12. | Stmt_ExceptionTaken of l
  13. | Stmt_Dep_Unpred of l
  14. | Stmt_Dep_ImpDef of string * l
  15. | Stmt_Dep_Undefined of l
  16. | Stmt_See of expr * l
  17. | Stmt_Throw of ident * l
  18. | Stmt_DecodeExecute of ident * expr * l
  19. | Stmt_TCall of ident * expr list * expr list * l
  20. | Stmt_If of expr * stmt list * s_elsif list * stmt list * l
  21. | Stmt_Case of expr * alt list * stmt list option * l
  22. | Stmt_For of ident * expr * direction * expr * stmt list * l
  23. | Stmt_While of expr * stmt list * l
  24. | Stmt_Repeat of stmt list * expr * l
  25. | Stmt_Try of stmt list * ident * catcher list * stmt list option * l
and s_elsif =
  1. | S_Elsif_Cond of expr * stmt list
and alt =
  1. | Alt_Alt of pattern list * expr option * stmt list
and catcher =
  1. | Catcher_Guarded of expr * stmt list
type instr_field =
  1. | IField_Field of ident * int * int
type opcode_value =
  1. | Opcode_Bits of bitsLit
  2. | Opcode_Mask of maskLit
type decode_pattern =
  1. | DecoderPattern_Bits of bitsLit
  2. | DecoderPattern_Mask of maskLit
  3. | DecoderPattern_Wildcard of ident
  4. | DecoderPattern_Not of decode_pattern
type decode_slice =
  1. | DecoderSlice_Slice of int * int
  2. | DecoderSlice_FieldName of ident
  3. | DecoderSlice_Concat of ident list
type sformal =
  1. | Formal_In of ty * ident
  2. | Formal_InOut of ty * ident
type encoding =
  1. | Encoding_Block of ident * ident * instr_field list * opcode_value * expr * (int * bitsLit) list * stmt list * l
type decode_case =
  1. | DecoderCase_Case of decode_slice list * decode_alt list * l
and decode_alt =
  1. | DecoderAlt_Alt of decode_pattern list * decode_body
and decode_body =
  1. | DecoderBody_UNPRED of l
  2. | DecoderBody_UNALLOC of l
  3. | DecoderBody_NOP of l
  4. | DecoderBody_Encoding of ident * l
  5. | DecoderBody_Decoder of instr_field list * decode_case * l
type mapfield =
  1. | MapField_Field of ident * pattern
type declaration =
  1. | Decl_BuiltinType of ident * l
  2. | Decl_Forward of ident * l
  3. | Decl_Record of ident * (ty * ident) list * l
  4. | Decl_Typedef of ident * ty * l
  5. | Decl_Enum of ident * ident list * l
  6. | Decl_Var of ty * ident * l
  7. | Decl_Const of ty * ident * expr * l
  8. | Decl_BuiltinFunction of ty * ident * (ty * ident) list * l
  9. | Decl_FunType of ty * ident * (ty * ident) list * l
  10. | Decl_FunDefn of ty * ident * (ty * ident) list * stmt list * l
  11. | Decl_ProcType of ident * (ty * ident) list * l
  12. | Decl_ProcDefn of ident * (ty * ident) list * stmt list * l
  13. | Decl_VarGetterType of ty * ident * l
  14. | Decl_VarGetterDefn of ty * ident * stmt list * l
  15. | Decl_ArrayGetterType of ty * ident * (ty * ident) list * l
  16. | Decl_ArrayGetterDefn of ty * ident * (ty * ident) list * stmt list * l
  17. | Decl_VarSetterType of ident * ty * ident * l
  18. | Decl_VarSetterDefn of ident * ty * ident * stmt list * l
  19. | Decl_ArraySetterType of ident * sformal list * ty * ident * l
  20. | Decl_ArraySetterDefn of ident * sformal list * ty * ident * stmt list * l
  21. | Decl_InstructionDefn of ident * encoding list * stmt list option * bool * stmt list * l
  22. | Decl_DecoderDefn of ident * decode_case * l
  23. | Decl_Operator1 of unop * ident list * l
  24. | Decl_Operator2 of binop * ident list * l
  25. | Decl_NewEventDefn of ident * (ty * ident) list * l
  26. | Decl_EventClause of ident * stmt list * l
  27. | Decl_NewMapDefn of ty * ident * (ty * ident) list * stmt list * l
  28. | Decl_MapClause of ident * mapfield list * expr option * stmt list * l
  29. | Decl_Config of ty * ident * expr * l
type leadingblank =
  1. | LeadingBlank
  2. | LeadingNothing
type factor =
  1. | Factor_BinOp of binop * expr
type impdef_command =
  1. | CLI_Impdef of string * expr
val associativeOperators : binop list
val booleanOperators : binop list
val comparisionOperators : binop list
val miscOperators : binop list
val isAssociative : binop -> bool
val isBoolean : binop -> bool
val isComparision : binop -> bool
val isMisc : binop -> bool
val higherPriorityThan : binop -> binop -> bool option
exception PrecedenceError of l * binop * binop

Parsing exceptions (2/2)

val buildExpr : binop -> expr -> factor list -> l -> expr * factor list
val buildExpression : expr -> factor list -> l -> expr
OCaml

Innovation. Community. Security.