Advertisement
Guest User

Untitled

a guest
Mar 16th, 2024
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 3.63 KB | None | 0 0
  1. type c_fragment
  2.  
  3. and pp_directive =
  4.   {
  5.     name : string;
  6.     arg : string option;
  7.   }
  8.  
  9. and obj_macro =
  10.   {
  11.     name : string;
  12.     defn : string;
  13.   }
  14.  
  15. and func_macro =
  16.   {
  17.     name : string;
  18.     params : string list;
  19.     defn : c_fragment list;
  20.   }
  21.  
  22. and func_decl =
  23.   {
  24.     static : bool;
  25.     inline : bool;
  26.     name : string;
  27.     return_type : string;
  28.     params : string list;
  29.   }
  30.  
  31. and func_call =
  32.   {
  33.     name : string;
  34.     args : string list;
  35.     term : bool;
  36.   }
  37.  
  38. and func_defn =
  39.   {
  40.     return_type : string;
  41.     name : string;
  42.     params : string list;
  43.     defn : c_fragment list;
  44.   }
  45.  
  46. and unary_expr =
  47.   {
  48.     op : string;
  49.     postfix : bool;
  50.     prim : c_fragment list;
  51.   }
  52.  
  53. and binary_expr =
  54.   {
  55.     op : string;
  56.     lhs : c_fragment list;
  57.     rhs : c_fragment list;
  58.   }
  59.  
  60. and ternary_expr =
  61.   {
  62.     expr1 : c_fragment list;
  63.     expr2 : c_fragment list option;
  64.     expt3 : c_fragment list option;
  65.   }
  66.  
  67. and for_stmt =
  68.   {
  69.     var_init : c_fragment list option;
  70.     cond_expr : c_fragment list option;
  71.     step_stmt : c_fragment list option;
  72.     body : c_fragment list option;
  73.   }
  74.  
  75. and while_stmt =
  76.   {
  77.     cond : c_fragment;
  78.     body : c_fragment list;
  79.   }
  80.  
  81. and if_stmt =
  82.   {
  83.     cond : c_fragment;
  84.     body : c_fragment list;
  85.   }
  86.  
  87. and else_stmt =
  88.   {
  89.     cond : c_fragment option;
  90.     body : c_fragment list;
  91.   }
  92.  
  93. and do_while_stmt =
  94.   {
  95.     body : c_fragment;
  96.     cond : c_fragment;
  97.   }
  98.  
  99.  
  100. and case_stmt =
  101.   {
  102.     const_subject : string;
  103.     body : c_fragment list;
  104.   }
  105.  
  106. and switch_stmt =
  107.   {
  108.     subject : string;
  109.     cases : case_stmt list;
  110.   }
  111.  
  112. and var_init =
  113.   {
  114.     var_type : string;
  115.     var_name : string;
  116.     init_expr : c_fragment;
  117.   }
  118.  
  119. and array_init =
  120.   {
  121.     array_type : string;
  122.     array_name : string;
  123.     num_memb : int option;
  124.     init_list : c_fragment list;
  125.   }
  126.  
  127. and designated_init =
  128.   {
  129.     array_type : string;
  130.     array_name : string;
  131.     num_memb : int option;
  132.     designates : (string * c_fragment) list;
  133.   }
  134.  
  135. and literal =
  136.   | IntegerLit of int
  137.   | FloatLit of float
  138.   | StringLit of string
  139.   | CharLit of char
  140.   | BoolLit of bool
  141.   | NullLit
  142.   | MacroConst of string
  143.   | EnumConst of string
  144.  
  145. and identifier =
  146.   | IndexedIdent of string * int
  147.   | UnindexedIdent of string * int
  148.   | ReferencedIdent of string
  149.   | DereferencedIdent of string
  150.  
  151. and compound_literal =
  152.   {
  153.     type_name : string;
  154.     init_fields : (string * c_fragment) list;
  155.   }
  156.  
  157. and assign_stmt =
  158.   {
  159.     lhs : string;
  160.     rhs : c_fragment;
  161.   }
  162.  
  163. and struct_decl =
  164.   {
  165.     name : string option;
  166.     fields : (string * string) list;
  167.     alias : string option;
  168.   }
  169.  
  170.  
  171. and enum_decl =
  172.   {
  173.     name : string option;
  174.     values : (string * int option) list;
  175.     alias : string option;
  176.   }
  177.  
  178.  
  179. and typedef_decl =
  180.   {
  181.     alias : string;
  182.     typedef_type : string;
  183.   }
  184.  
  185.  
  186. type c_fragment =
  187.   | PPDirective of pp_directive
  188.   | ObjMacro of obj_macro
  189.   | FuncMacro of func_macro
  190.   | FuncDecl of func_decl
  191.   | FuncDefn of func_defn
  192.   | FuncCall of func_call
  193.   | UnaryExpr of unary_expr
  194.   | BinaryExpr of binary_expr
  195.   | TernaryExpr of ternary_expr
  196.   | ForStmt of for_stmt
  197.   | WhileStmt of while_stmt
  198.   | IfStmt of if_stmt
  199.   | ElseStmt of else_stmt
  200.   | DoWhileStmt of do_while_stmt
  201.   | SwitchStmt of switch_stmt
  202.   | AssignStmt of assign_stmt
  203.   | VarInit of var_init
  204.   | ArrayInit of array_init
  205.   | DesignatedInit of designated_init
  206.   | SimpleLiteral of literal
  207.   | CompoundLiteral of compound_literal
  208.   | StructDecl of struct_decl
  209.   | EnumDecl of enum_decl
  210.   | TypedefDecl of typedef_decl
  211.   | Identifier of identifier
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement