package ast_generic

  1. Overview
  2. Docs
val str_of_ident : AST_generic.ident -> string
exception NotAnExpr
val expr_to_pattern : AST_generic.expr -> AST_generic.pattern
val pattern_to_expr : AST_generic.pattern -> AST_generic.expr
val argument_to_expr : AST_generic.argument -> AST_generic.expr
val expr_to_type : AST_generic.expr -> AST_generic.type_
val expr_to_class_parent : AST_generic.expr -> AST_generic.class_parent
val name_of_ids_with_opt_typeargs : (AST_generic.ident * AST_generic.type_arguments option) list -> AST_generic.name
val add_id_opt_type_args_to_name : AST_generic.name -> (AST_generic.ident * AST_generic.type_arguments option) -> AST_generic.name
val add_type_args_opt_to_name : AST_generic.name -> AST_generic.type_arguments option -> AST_generic.name
val add_suffix_to_name : AST_generic.ident -> AST_generic.name -> AST_generic.name
val name_of_dot_access : AST_generic.expr -> AST_generic.name option
val dotted_ident_of_name : AST_generic.name -> AST_generic.dotted_ident
val parameter_to_catch_exn_opt : AST_generic.parameter -> AST_generic.catch_exn option
val opt_to_label_ident : AST_generic.ident option -> AST_generic.label_ident
val has_keyword_attr : AST_generic.keyword_attribute -> AST_generic.attribute list -> bool
val abstract_for_comparison_any : AST_generic.any -> AST_generic.any

Abstract away position and svalue for comparison * with polymorphic operators.

val is_associative_operator : AST_generic.operator -> bool

Test whether an operator is suitable for associative-matching.

val ac_matching_nf : AST_generic.operator -> AST_generic.argument list -> AST_generic.expr list option

ac_matching_nf op args converts the operands args of an * AC-operator op to a normal form (NF) better suited for AC-matching. * Essentially, we flatten out all op-operations. Note that this is not * a canonical form (i.e., it is not a unique representation). * E.g. * ac_matching_nf And a; Call(Op And, [b; c]) = Some a; b; c * The function returns None if op is not an AC-operator. It also * returns None if the operands have an unexpected shape (see code), * in which case we just log an error and skip AC-matching (rather * than crashing).

val undo_ac_matching_nf : Parse_info.t -> AST_generic.operator -> AST_generic.expr list -> AST_generic.expr option

undo_ac_matching_nf tok op args_nf folds args_nf using op * (in a sense, it "undoes" ac_matching_nf). Here tok is the token of * the operand op in the source file. Note that this does not remember * the original grouping of the operands! * E.g. * undo_ac_matching_nf tok And a; b; c = Call(Op And, Call(Op And, [a; b]); c)