package ast_generic

  1. Overview
  2. Docs

Module AST_generic_helpersSource

Sourceval str_of_ident : AST_generic.ident -> string
Sourceexception NotAnExpr
Sourceval expr_to_class_parent : AST_generic.expr -> AST_generic.class_parent
Sourceval name_of_ids_with_opt_typeargs : (AST_generic.ident * AST_generic.type_arguments option) list -> AST_generic.name
Sourceval add_id_opt_type_args_to_name : AST_generic.name -> (AST_generic.ident * AST_generic.type_arguments option) -> AST_generic.name
Sourceval add_type_args_opt_to_name : AST_generic.name -> AST_generic.type_arguments option -> AST_generic.name
Sourceval name_of_dot_access : AST_generic.expr -> AST_generic.name option
Sourceval dotted_ident_of_name : AST_generic.name -> AST_generic.dotted_ident
Sourceval parameter_to_catch_exn_opt : AST_generic.parameter -> AST_generic.catch_exn option
Sourceval opt_to_label_ident : AST_generic.ident option -> AST_generic.label_ident
Sourceval has_keyword_attr : AST_generic.keyword_attribute -> AST_generic.attribute list -> bool
Sourceval abstract_for_comparison_any : AST_generic.any -> AST_generic.any

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

Sourceval is_associative_operator : AST_generic.operator -> bool

Test whether an operator is suitable for associative-matching.

Sourceval 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).

Sourceval 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)

OCaml

Innovation. Community. Security.