Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Absyn = struct
- type expr = {
- kind: expr_kind;
- tags: aug_tag list;
- }
- and stmt = {
- kind: stmt_kind;
- tags: aug_tag list;
- }
- and expr_kind =
- | Primary of primary_factor
- | Unary of { factor: primary_factor; op: unary_op; }
- | Subscript of { factor: primary_factor; op: subscript_op; }
- | Binary of { left_factor: expr; right_factor: expr; op: binary_op; }
- | Ternary of { cond: expr; if_true: expr; if_false: expr; }
- | Assignment of { lvalue: expr; rvalue: expr; op: assign_op; }
- | StmtExpr of stmt
- and stmt_kind =
- | Expr of expr option
- | VarDecl of { attr: var_attr option; storage: storage_cls; tydecl: type_decl; declarators: declarator list option; }
- | For of { init: stmt option; cond: expr list option; iter: stmt option; body: stmt; }
- | DoWhile of { body: stmt; cond: expr; }
- | While of { cond: expr; body: stmt; }
- | If of { if_clause: if_clause; elsif_clauses: if_clause list option; else_clause: stmt option; }
- | Switch of { main_discrim: const_expr; case_clauses: (const_expr * stmt) list; default_clause: stmt option; }
- | InlineAsm of { asm: string; inputs: asm_cons list option; outputs: asm_cons list option; clobbers: string list option; }
- | NestedFunc of { proto: func_proto; name: string; body: stmt; }
- | ControlFlow of control_flow_stmt
- | Compound of compound_stmt
- | Labeled of label * stmt list
- and literal =
- ConstLiteral of const_lit | CompoundLiteral of compound_lit
- and const_lit =
- | IntConst of int * int_suffix option
- | FloatConst of float * float_suffix option
- | CharConst of char * charset_prefix option
- | StrConst of string * charset_prefix option
- | EnumConst of enum_const
- and int_suffix =
- Long | LongLong | Unsigned | UnsignedLong | UnsignedLongLong
- and float_suffix =
- Double | LongDouble
- and charset_prefix =
- Local | U8 | U16 | U32
- and compound_lit =
- | ArrayCompound of init_type * init_item list
- | StructCompound of init_type * init_item list
- | UnionCompound of init_type * init_item list
- and init_item =
- | RegularInit of expr
- | DesignatedInit of designated_init * expr
- and designated_init =
- | ConstExpr of const_expr
- | Ident of string
- and init_type = type_decl
- and enum_const =
- { name: string; value: const_expr option; }
- and const_expr =
- | ConstFactor of literal
- | ConstRange of const_expr * const_expr
- | UnaryConstExpr of { factor: literal; op: unary_op; }
- | BinaryConstExpr of { left_factor: literal; right_factor: literal; op: binary_op; }
- and primary_factor =
- Identifier of string | NestedExpr of expr | Literal of literal
- and prefix_unary_op =
- | Negate
- | LogicalNegate
- | BitwiseNot
- | AddressOf
- | AddressOfLabel
- | Dereference
- | PreIncrement
- | PreDecrement
- | Sizeof
- | Typeof
- and postfix_unary_op =
- | PostIncrement
- | PostDecrement
- and unary_op =
- | PrefixOp of prefix_unary_op
- | PostfixOp of postfix_unary_op
- and subscript_op =
- | Index of expr
- | DotMember of expr
- | ArrowMember of expr
- | FunctionCall of expr list
- and binary_op =
- | Add
- | Subtract
- | Multiply
- | Divide
- | Modulo
- | BitwiseAnd
- | Bitwise7Or
- | BitwiseXor
- | ShiftLeft
- | ShiftRight
- | LogicalAnd
- | LogicalOr
- | Equal
- | NotEqual
- | LessThan
- | LessThanOrEqual
- | GreaterThan
- | GreaterThanOrEqual
- and assign_op =
- | Assignment
- | AddAssign
- | SubtractAssign
- | MultiplyAssign
- | DivideAssign
- | ModuloAssign
- | AndAssign
- | OrAssign
- | XorAssign
- | ShiftLeftAssign
- | ShiftRightAssign
- and type_decl =
- { attr: type_attr option; qual: type_qual list; value: type_value; }
- and type_qual =
- Const | Volatile
- and type_value =
- | IntegeralType of type_int
- | AtomicType of type_int
- | RationalType of type_float
- | PointerType of type_pointer
- | ArrayType of type_array
- | EnumType of type_enum
- | StructType of type_struct
- | UnionType of type_union
- | FuncType of type_func
- | ComplexType of type_complex
- | VoidType
- and type_int =
- { signage: int_signage option; word: int_word; }
- and int_word =
- | Char
- | Short
- | Int
- | Long
- | LongLong
- | UChar
- | UShort
- | UInt
- | ULong
- | ULongLong
- and int_signage =
- Signed | Unsgiend
- and type_float =
- | Float
- | Double
- | LongDouble
- and type_pointer =
- { base: type_decl; depth: int; qual: pointer_qual; }
- and pointer_qual =
- Const | Volatile | Restrict
- and type_array = {
- arr_type: type_decl;
- arr_size: int option;
- }
- and type_struct = {
- struct_tag: string option;
- struct_fields: field_item list;
- }
- and type_union = {
- union_name: string option;
- union_fields: field_item list;
- }
- and field_item = {
- name: string;
- typ: type_decl;
- }
- and type_enum = {
- enum_name: string option;
- enum_values: enum_const list;
- }
- and type_complex =
- | ComplexFloat
- | ComplexDouble
- | ComplexLongDouble
- and type_func = {
- func_return_type: type_decl;
- func_params: (string option * type_decl) list;
- func_is_variadic: bool;
- }
- and storage_cls =
- Extern | Auto | Register | Static
- and declarator =
- | Assigned of expr * expr
- | Unassigned of expr
- and if_clause =
- { cond: expr; body: stmt; }
- and asm_cons =
- { reg: string; value: expr option; }
- and control_flow_stmt =
- | Continue
- | Break
- | Goto of label
- | Return of expr option
- and label = string
- and compound_stmt = stmt list
- and toplvl_stmt =
- | TypeDef of { tydecl: type_decl; alias: expr; }
- | FuncDef of { proto: func_proto; name: string; body: stmt; }
- | GlobDecl of toplvl_decl
- and toplvl_storage =
- Extern | Auto | Static
- and func_proto =
- { attr: func_attr option; typ: type_func; storage: toplvl_storage; inline: bool; }
- and toplvl_decl =
- | FunDecl of func_proto
- | StructDecl of type_struct
- | UnionDecl of type_union
- | EnumDecl of type_union
- and trans_unit = toplvl_stmt list
- and func_attr =
- | Noreturn
- | Format of string * int * int
- | Pure
- | Const
- | Deprecated
- | Used
- | Unused
- | Weak
- | Alias of string
- | Visibility of string
- | No_instrument_function
- | Constructor
- | Destructor
- | Nonnull of int list
- | Malloc
- | Section of string
- | Nothrow
- | Always_inline
- | Noinline
- and var_attr =
- | Deprecated
- | Unused
- | Weak
- | Aligned of int option
- | Packed
- | Section of string
- | Used
- | Cleanup of string
- | Transparent_union
- and type_attr =
- | Packed
- | Aligned of int option
- | Deprecated
- and aug_tag =
- | TypeTag of type_info
- | CategoryTag of value_category_info
- | ControlFlowTag of control_flow_info
- | DataFlowTag of data_flow_info
- | SSATag of ssa_info
- | RegAllocTag of reg_alloc_info
- | LocationTag of location_info
- | OptimizationInfo of optimization_info
- | DiagnosticTag of diagnostic_info
- | DependencyTag of dependency_info
- | MemoryAccessTag of memory_access_info
- | InterproceduralInfo of interprocedural_info
- | ScopeTag of scope_info
- | LinkageTag of linkage_info
- and value_category_info =
- | LocatorVal
- | ReadVal
- and type_info = {
- mutable_type: bool;
- type_size: int;
- type_align: int;
- }
- and control_flow_info = {
- entering_blocks: string list;
- exiting_blocks: string list;
- }
- and data_flow_info = {
- defs: (string * location_info) list;
- uses: (string * location_info) list;
- live_in: string list;
- live_out: string list;
- }
- and ssa_info = {
- version: int option;
- }
- and reg_alloc_info = {
- assigned_register: string option;
- }
- and location_info = {
- file: input_source;
- line_no: int;
- line_token_no: int;
- line_char_no: int;
- total_token_no: int;
- total_char_no: int;
- }
- and input_source = STDIN | File of string
- and optimization_info = {
- loop_unrolling_factor: int option;
- should_inline: bool;
- vectorization_hint: bool;
- }
- and diagnostic_info = {
- severity: diagnostic_severity;
- message: string;
- suggestion: string option;
- }
- and diagnostic_severity = Error | Warning | Info
- and dependency_info = {
- depends_on: string list;
- used_by: string list;
- }
- and memory_access_info = {
- access_pattern: memory_access_pattern;
- stride: int option;
- }
- and memory_access_pattern = Sequential | Random | Strided
- and interprocedural_info = {
- call_graph_node: string list;
- has_side_effects: bool;
- }
- and scope_info = {
- level: scope_level;
- defined_in: scope_level;
- }
- and scope_level =
- | GlobalScope
- | FunctionScope of string
- | BlockScope of string
- and linkage_info =
- | External
- | Internal
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement