Copyright © 2010-2013 Richard Carlsson
Authors: Richard Carlsson (carlsson.richard@gmail.com).
default_action() = fun(() -> any())
env() = [{Key::id(), pattern_or_patterns()}]
guard_test() = fun((env()) -> boolean())
guarded_action() = switch_action() | {guard_test(), switch_action()}
guarded_actions() = guarded_action() | [guarded_action()]
id() = atom() | integer()
location() = erl_scan:location()
pattern() = tree() | template()
pattern_or_patterns() = pattern() | [pattern()]
switch_action() = fun((env()) -> any())
switch_clause() = {pattern_or_patterns(), guarded_actions()} | {pattern_or_patterns(), guard_test(), switch_action()} | default_action()
template() = tree() | {id()} | {'*', id()} | {template, atom(), term(), [[template()]]}
template_or_templates() = template() | [template()]
text() = string() | binary() | [string()] | [binary()]
tree() = erl_syntax:syntaxTree()
tree_or_trees() = tree() | [tree()]
| alpha/2 | Alpha converts a pattern (renames variables). |
| compile/1 | Equivalent to compile(Code, []).
|
| compile/2 | Compile a syntax tree or list of syntax trees representing a module into a binary BEAM object. |
| compile_and_load/1 | Equivalent to compile_and_load(Code, []).
|
| compile_and_load/2 | Compile a syntax tree or list of syntax trees representing a module and load the resulting module into memory. |
| match/2 | Match a pattern against a syntax tree (or patterns against syntax trees) returning an environment mapping variable names to subtrees; the environment is always sorted on keys. |
| meta_template/1 | Turn a template into a syntax tree representing the template. |
| print/1 | Pretty-print a syntax tree or template to the standard output. |
| qquote/2 | Parse text and substitute meta-variables. |
| qquote/3 | Parse text and substitute meta-variables. |
| quote/1 | Parse text. |
| quote/2 | Parse text. |
| show/1 | Print the structure of a syntax tree or template to the standard output. |
| subst/2 | Substitute metavariables in a pattern or list of patterns, yielding a syntax tree or list of trees as result. |
| switch/2 | Match against one or more clauses with patterns and optional guards. |
| template/1 | Turn a syntax tree or list of trees into a template or templates. |
| template_vars/1 | Return an ordered list of the metavariables in the template. |
| term/1 | Create a syntax tree for a constant term. |
| tree/1 | Revert a template to a normal syntax tree. |
| tsubst/2 | Like subst/2, but does not convert the result from a template back to a tree. |
| var/1 | Create a variable. |
alpha(Trees::pattern_or_patterns(), Env::[{id(), id()}]) -> template_or_templates()
Alpha converts a pattern (renames variables). Similar to tsubst/1, but only renames variables (including globs).
See also: tsubst/2.
compile(Code) -> any()
Equivalent to compile(Code, []).
compile(Code, Options) -> any()
Compile a syntax tree or list of syntax trees representing a module into a binary BEAM object.
See also: compile/1, compile_and_load/2.
compile_and_load(Code) -> any()
Equivalent to compile_and_load(Code, []).
compile_and_load(Code, Options) -> any()
Compile a syntax tree or list of syntax trees representing a module and load the resulting module into memory.
See also: compile/2, compile_and_load/1.
match(Patterns::pattern_or_patterns(), Trees::tree_or_trees()) -> {ok, env()} | error
Match a pattern against a syntax tree (or patterns against syntax trees) returning an environment mapping variable names to subtrees; the environment is always sorted on keys. Note that multiple occurrences of metavariables in the pattern is not allowed, but is not checked.
See also: switch/2, template/1.
meta_template(Templates::template_or_templates()) -> tree_or_trees()
Turn a template into a syntax tree representing the template.
Meta-variables in the template are turned into normal Erlang variables if
their names (after the metavariable prefix characters) begin with an
uppercase character. E.g., _@Foo in the template becomes the variable
Foo in the meta-template. Furthermore, variables ending with @ are
automatically wrapped in a call to merl:term/1, so e.g. _@Foo@ in the
template becomes `merl:term(Foo) in the meta-template.
print(Ts) -> any()
Pretty-print a syntax tree or template to the standard output. This is a utility function for development and debugging.
qquote(Text::text(), Env::env()) -> tree_or_trees()
Equivalent to qquote(1, Text, Env).
Parse text and substitute meta-variables.
qquote(StartPos::location(), Text::text(), Env::env()) -> tree_or_trees()
Parse text and substitute meta-variables. Takes an initial scanner starting position as first argument.
The macro?Q(Text, Env) expands to merl:qquote(?LINE, Text, Env).
See also: quote/2.
quote(Text::text()) -> tree_or_trees()
Equivalent to quote(1, Text).
Parse text.
quote(StartPos::location(), Text::text()) -> tree_or_trees()
Parse text. Takes an initial scanner starting position as first argument.
The macro?Q(Text) expands to merl:quote(?LINE, Text, Env).
See also: quote/1.
show(Ts) -> any()
Print the structure of a syntax tree or template to the standard output. This is a utility function for development and debugging.
subst(Trees::pattern_or_patterns(), Env::env()) -> tree_or_trees()
Substitute metavariables in a pattern or list of patterns, yielding
a syntax tree or list of trees as result. Both for normal metavariables
and glob metavariables, the substituted value may be a single element or
a list of elements. For example, if a list representing 1, 2, 3 is
substituted for var in either of [foo, _@var, bar] or [foo, _@var,
bar], the result represents [foo, 1, 2, 3, bar].
switch(Trees::tree_or_trees(), Cs::[switch_clause()]) -> any()
Match against one or more clauses with patterns and optional guards.
Note that clauses following a default action will be ignored.See also: match/2.
template(Trees::pattern_or_patterns()) -> template_or_templates()
Turn a syntax tree or list of trees into a template or templates.
Templates can be instantiated or matched against, and reverted back to
normal syntax trees using tree/1. If the input is already a
template, it is not modified further.
See also: match/2, subst/2, tree/1.
template_vars(Template::template_or_templates()) -> [id()]
Return an ordered list of the metavariables in the template.
term(Term::term()) -> tree()
Create a syntax tree for a constant term.
tree(Templates::template_or_templates()) -> tree_or_trees()
Revert a template to a normal syntax tree. Any remaining
metavariables are turned into @-prefixed atoms or 909-prefixed
integers.
See also: template/1.
tsubst(Trees::pattern_or_patterns(), Env::env()) -> template_or_templates()
Like subst/2, but does not convert the result from a template back to a tree. Useful if you want to do multiple separate substitutions.
var(Name::atom()) -> tree()
Create a variable.
Generated by EDoc