Current section
Files
Jump to
Current section
Files
doc/man/lfe_macro.3
.\" Automatically generated by Pandoc 2.11.2
.\"
.TH "lfe_macro" "3" "2008-2020" "" ""
.hy
.SH NAME
.PP
lfe_macro - Lisp Flavoured Erlang (LFE) macro expander
.SH SYNOPSIS
.PP
This module provides an interface to the LFE macro expander.
The expander is used by the LFE compile and in the shell but can also be
used by applications explicitly wanting to handle a file.
.SH DATA TYPES
.PP
\f[B]sexpr()\f[R]
.PP
An LFE s-expression, a list structure.
.PP
\f[B]filesexpr() = {Sexpr,Line}\f[R]
.PP
This is the format returned by \f[C]lfe_io:parse_file/1\f[R] and is used
by the compiler to give better error information.
.PP
\f[B]env()\f[R]
.PP
This is an macro and evaluation environment as created by
\f[C]lfe_lib:new_env()\f[R].
.PP
\f[B]mac_state()\f[R]
.PP
This is the internal state used by the macro expander.
.SH EXPORTS
.PP
\f[B]expand_expr(Sexpr, Env) -> {yes,Exp} | no.\f[R]
.PP
\f[B]expand_expr_1(Sexpr, Env) -> {yes,Exp} | no.\f[R]
.PP
where
.IP
.nf
\f[C]
Sexpr = Exp = sexpr()
Env = env()
\f[R]
.fi
.PP
Test if the top s-expression here is a macro call, if so expand it and
return {yes,Expansion}, if not then return no.
\f[C]expand_expr/2\f[R] will expand the top s-expression as much as
possible while \f[C]expand_expr_1/2\f[R] will only try it once.
These functions use the macro definitions in the environment and the
standard pre-defined macros.
.PP
\f[B]expand_expr_all(Sexpr, Env) -> Sexpr.\f[R]
.PP
where
.IP
.nf
\f[C]
Sexpr = sexpr()
Env = env()
\f[R]
.fi
.PP
Expand all macros in Sexpr either using the definitions in Env or just
the default macros.
Note that any eventual new macro definitions will be lost.
.PP
\f[B]expand_form_init(Deep, Keep) -> MacState\f[R]
.PP
where
.IP
.nf
\f[C]
Deep = boolean()
Keep = boolean()
MacState = mac_state()
\f[R]
.fi
.PP
Create an internal macro state.
\f[C]Deep\f[R] determines whether the form is to be expanded internally
at depth and \f[C]Keep\f[R] whether macro definition forms are to be
kept.
.PP
\f[B]expand_fileforms([FileForm], Env, Deep, Keep) -> ExpRet\f[R]
.PP
\f[B]expand_fileforms([FileForm], Env, MacState) -> ExpRet\f[R]
.PP
where
.IP
.nf
\f[C]
FileForm = filesexpr()
Env = env()
Deep = boolean()
Keep = boolean()
MacState = mac_state()
ExpRet = {yes,[FileSexpr],Env,Warnings} |
{error,Errors,Warnings}
\f[R]
.fi
.PP
expand a sequence of file forms.
.PP
\f[B]expand_form(Form, Line, Env, MacState) -> RetState\f[R]
.PP
\f[B]expand_fileform(FileForm, Env, MacState) -> RetState\f[R]
.PP
where
.IP
.nf
\f[C]
Form = sexpr()
FileForm = filesexpr()
Line = integer()
Env = env()
MacState = mac_state()
RetState = {ok,Form,Env,Macstate} |
{error,Errors,Warnings,MacState}
\f[R]
.fi
.PP
Expand a file form using the environment and macro state.
.SH SEE ALSO
.PP
\f[B]lfe_comp(3)\f[R], \f[B]lfe_gen(3)\f[R]
.SH AUTHORS
Robert Virding.