- Functions for building (untyped) AST elements
- Unwrap aux constructors
- Destruct type annotated patterns and expressions
- Utilites for working with kinded_ids
- Utility functions for constructing types
- Sail builtin types
- Simplifcation of numeric expressions and constraints
- Set and Map modules for various AST elements
- Functions for building numeric expressions
- Functions for building numeric constraints
- Functions for building type arguments
- Functions for working with type quantifiers
- Functions to map over annotations in sub-expressions
- Printing utilities
- Functions for getting identifiers from toplevel definitions
- Functions for manipulating identifiers
- Misc functions
- Manipulating locations
- Substitutions
package libsail
Module Libsail.Ast_utilSource
Utilities and helper functions for operating on Sail ASTs
lvar is the type of variables - they can either be registers, local mutable or immutable variables constructors or unbound identifiers.
The empty annotation. Should be used carefully because it can result in unhelpful error messgaes. However a common pattern is generating code with no_annot, then adding location information with the various locate_ functions in this module.
gen_loc l takes a location l and generates a location which means 'generated/derived from location l'. This is useful for debugging errors that occur in generated code.
Functions for building (untyped) AST elements
Unwrap aux constructors
Destruct type annotated patterns and expressions
untyp_pat (P_aux (P_typ (typ, pat)), _) returns Some (pat, typ) or None if the pattern does not match.
Same as untyp_pat, but for E_cast nodes
Utilites for working with kinded_ids
Utility functions for constructing types
Sail builtin types
Simplifcation of numeric expressions and constraints
These functions simplify nexps and n_constraints using various basic rules. In general they will guarantee to reduce constant numeric expressions like 2 + 5 into 7, although they will not simplify 2^constant, as that often leads to unreadable error messages containing huge numbers.
If a constraint is a conjunction, return a list of all the top-level conjuncts
Same as constraint_conj but for disjunctions
Set and Map modules for various AST elements
Functions for building numeric expressions
Functions for building numeric constraints
Functions for building type arguments
Functions for working with type quantifiers
Functions to map over annotations in sub-expressions
val map_scattered_annot :
('a Ast.annot -> 'b Ast.annot) ->
'a Ast.scattered_def ->
'b Ast.scattered_defExtract locations from terms
Printing utilities
Note: For debugging and error messages only - not guaranteed to produce parseable Sail, or even print all language constructs!
Functions for getting identifiers from toplevel definitions
Functions for manipulating identifiers
Misc functions
Manipulating locations
locate takes an expression and recursively sets the location in every subexpression using a function that takes the orginal location as an argument. Expressions build using mk_exp and similar do not have locations, so they can then be annotated as e.g. locate (gen_loc l) (mk_exp ...) where l is the location from which the code is being generated.
Make a unique location by giving it a Parse_ast.Unique wrapper with a generated number.
val find_annot_ast :
(Lexing.position * Lexing.position) option ->
'a Ast_defs.ast ->
(Ast.l * 'a) optionTry to find the annotation closest to the provided (simplified) location. Note that this function makes no guarantees about finding the closest annotation or even finding an annotation at all. This is used by the Emacs mode to provide type-at-cursor functionality and we don't mind if it's a bit fuzzy in that context.
Substitutions
The function X_subst substitutes a type argument into something of type X. The type of the type argument determines which kind of type variables will be replaced
Attach comments produced by the lexer into their nearest nodes in the abstract syntax tree
- Functions for building (untyped) AST elements
- Unwrap aux constructors
- Destruct type annotated patterns and expressions
- Utilites for working with kinded_ids
- Utility functions for constructing types
- Sail builtin types
- Simplifcation of numeric expressions and constraints
- Set and Map modules for various AST elements
- Functions for building numeric expressions
- Functions for building numeric constraints
- Functions for building type arguments
- Functions for working with type quantifiers
- Functions to map over annotations in sub-expressions
- Printing utilities
- Functions for getting identifiers from toplevel definitions
- Functions for manipulating identifiers
- Misc functions
- Manipulating locations
- Substitutions