Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type expression
- type compound_statement
- type accessor
- type scope_type
- type regexp_flags =
- | Global
- | IgnoreCase
- | Multiline
- | Unicode
- | Sticky
- | DotAll
- | HasIndices
- type simple_literal =
- | String of string
- | Float of float
- | Integer of int
- | BigInt of string
- | Boolean of bool
- | Null
- | Undefined
- type regexp_literal = {
- pattern : string;
- flags : regexp_flags list;
- }
- type literal =
- | Simple of simple_literal
- | RegExp of regexp_literal
- | Object of object_literal
- | Array of array_literal
- | Lambda of lambda_literal
- | Template of template_literal
- and object_literal_entry =
- | Property of string * expression
- | SpreadProperty of expression
- and object_literal = object_literal_entry list
- and array_literal = {
- num_items : int;
- items : expression list;
- }
- and lambda_params =
- | NamedParams of accessor list
- | RestParam of string
- and template_literal_quasi =
- | Text of string list
- | EmbExpr of expression list
- and template_literal =
- template_literal_quasi list
- and lambda_literal = {
- params : lambda_params;
- body : compound_statement;
- }
- type built_in_variable =
- | Self
- | This
- type built_in_function =
- | Eval
- | Exec
- | IsNaN
- | ParseFloat
- | ParseInt
- | DecodeURI
- | DecodeURIComponent
- | EncodeURI
- | EncodeURIComponent
- type identifier =
- | VariableName of string
- | ConstructorName of string
- | FunctionName of string
- | ParameterName of string
- | ClassName of string
- | PrototypeName of string
- | BuiltInVariable of built_in_variable
- | BuiltInFunction of built_in_function
- type subscript =
- | Invoke of expression list
- | Index of expression list
- type access = {
- name: identifier;
- subscript : subscript option;
- }
- type accessor = access list
- type primary_expression =
- | Literal of literal
- | Accessor of accessor
- | NestedExpr of expression
- type unary_expression =
- | Primary of primary_expression
- | Plus of primary_expression
- | Minus of primary_expression
- | Incr of primary_expression
- | Decr of primary_expression
- | Not of expression
- | OnesCompl of expression
- | TwosCompl of expression
- | Typeof of expression
- | Void of expression
- | Delete of expression
- | Spread of expression
- | Rest of expression
- | Yield of expression
- | New of expression
- type arithmetic_expression =
- | Add of expression * expression
- | Sub of expression * expression
- | Mul of expression * expression
- | Div of expression * expression
- | Mod of expression * expression
- | Pow of expression * expression
- type bitwise_expression =
- | And of expression * expression
- | Or of expression * expression
- | Xor of expression * expression
- | Shl of expression * expression
- | Shr of expression * expression
- | Ror of expression * expression
- type relational_expression =
- | Le of expression * expression
- | Lt of expression * expression
- | Gt of expression * expression
- | Ge of expression * expression
- | Instanceof of expression * expression
- | In of expression * expression
- type equality_expression =
- | Eq of expression * expression
- | Ne of expression * expression
- | StrictEq of expression * expression
- | StrictNe of expression * expression
- | Nullish of expression * expression
- type assignment_expression =
- | ValAssignment of accessor * expression
- | AddAssignment of accessor * expression
- | SubAssignment of accessor * expression
- | DivAssignment of accessor * expression
- | ModAssignment of accessor * expression
- | PowAssignment of accessor * expression
- | ShrAssignment of accessor * expression
- | ShlAssignment of accessor * expression
- | RorAssignment of accessor * expression
- | AndAssignment of accessor * expression
- | OrAssignment of accessor * expression
- type binary_expression =
- | Arithmetic of arithmetic_expression
- | Bitwise of bitwise_expression
- | Relational of relational_expression
- | Equality of equality_expression
- | Assignment of assignment_expression
- type ternary_expression = {
- cond : expression;
- if_true : expression;
- if_false : expression;
- }
- type function_expression = {
- params : accessor list;
- body : compound_statement;
- }
- type arrow_function_expr = {
- params: lambda_params;
- body: expression; (* Can be an expression or a block *)
- }
- type function_argument =
- | Unnamed of expression
- | Named of string * expression
- type function_call = {
- callee : expression;
- arguments : function_argument list;
- }
- type class_expression = {
- name: string option;
- extends: expression option;
- body: class_body list;
- }
- and class_body =
- | Method of string * function_expression
- | Property of string * expression option
- type expression =
- | Literal of literal
- | Identifier of identifier
- | FunctionCall of function_call
- | Unary of unary_expression
- | Binary of binary_expression
- | Ternary of ternary_expression
- | FunctionExpr of function_expression
- | ClassExpr of class_expression
- | ArrowFuncExpr of arrow_function_expr
- type spread_element = expression
- type destructuring_assignment = {
- target: destructuring_target;
- source: expression;
- }
- and destructuring_target =
- | ObjectTarget of (string * string option) list
- | ArrayTarget of string list
- type async_function_expr = {
- params: accessor list; (* Adjusted from string list to accessor list for consistency *)
- body: compound_statement;
- }
- (* Statements *)
- type if_statement = {
- condition: expression;
- then_branch: compound_statement;
- else_branch: compound_statement option;
- }
- type switch_statement = {
- discriminant: expression;
- cases: (expression option * compound_statement) list; (* None for default case *)
- }
- type for_statement = {
- init: expression option;
- condition: expression option;
- update: expression option;
- body: compound_statement;
- }
- type while_statement = {
- condition: expression;
- body: compound_statement;
- }
- type do_while_statement = {
- body: compound_statement;
- condition: expression;
- }
- type try_catch_finally_statement = {
- try_block: compound_statement;
- catch_block: (accessor option * compound_statement) option; (* Catch parameter may be an accessor *)
- finally_block: compound_statement option;
- }
- type control_flow_statement =
- | Break
- | Continue
- | Return of expression option
- | Throw of expression
- type statement =
- | ExpressionStatement of expression
- | CompoundExpressionStatement of expression list
- | IfStatement of if_statement
- | SwitchStatement of switch_statement
- | ForStatement of for_statement
- | WhileStatement of while_statement
- | DoWhileStatement of do_while_statement
- | TryCatchFinallyStatement of try_catch_finally_statement
- | ControlFlowStatement of control_flow_statement
- | VariableDeclarationStatement of variable_declaration
- | FunctionDeclarationStatement of function_declaration
- | ClassDeclarationStatement of class_declaration
- | DestructureAssignment of destructuring_assignment
- | Block of compound_statement
- and compound_statement = statement list
- (* Declarations *)
- and variable_declaration = {
- kind: string; (* "var", "let", "const" *)
- declarations: (accessor * expression option) list;
- }
- and function_declaration = {
- name: string;
- params: accessor list; (* Adjusted from function_param list for consistency *)
- body: compound_statement;
- }
- and class_declaration = {
- name: string;
- extends: expression option;
- body: class_body list;
- }
- type declaration =
- | VariableDeclaration of variable_declaration
- | FunctionDeclaration of function_declaration
- | ClassDeclaration of class_declaration
- type es_scope = {
- scope_type: scope_type;
- declarations: declaration list;
- statements: statement list;
- }
- type scope_type =
- | Global
- | FunctionScope of function_declaration
- | ClassScope of class_declaration
- | BlockScope
- type es_program = es_scope list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement