-
Notifications
You must be signed in to change notification settings - Fork 141
/
lfe_comp.txt
145 lines (98 loc) · 5.37 KB
/
lfe_comp.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
lfe_comp(3) lfe_comp(3)
NAME
lfe_comp - Lisp Flavoured Erlang (LFE) compiler
SYNOPSIS
This module provides an interface to the standard LFE compiler. The
compiler can handle files which contain multiple modules. It can gen‐
erate either new files which contain the object code, or return bina‐
ries which can be loaded directly.
EXPORTS
file(FileName) -> CompRet
Is the same as file(FileName, [report]).
file(FileName, Options) -> CompRet
where
CompRet = ModRet | BinRet | ErrRet
ModRet = {ok,[ModOk]} | {ok,[ModOk],Warnings}
ModOk = {ok,ModuleName} | {ok,ModuleName,Warnings}
BinRet = {ok,[ModBin]} | {ok,[ModBin],Warnings}
ModBin = {ok,ModuleName,Binary} | {ok,ModuleName,Binary,Warnings}
ErrRet = error | {error,[ModErr],Errors,Warnings}
ModErr = {error,Errors,Warnings}
Compile an LFE file, either writing the generated modules to files or
returning them as binaries. The generated modules are ready to be
loaded into Erlang.
The currently recognised options are:
· binary - Return the binary of the module and do not save it in a
file.
· no_docs, no-docs - Do not parse docstrings and write the "LDoc" chunk
in the binary of the module.
· to_expand, to-expand - Print a listing of the macro expanded LFE code
in the file .expand. No object file is produced. Mainly useful for
debugging and interest.
· to_lint, to-lint - Print a listing of the macro expanded and linted
LFE code in the files .lint. No object files are produced. Mainly
useful for debugging and interest.
· to_erlang, to-erlang - Print a listing of the Erlang AST in the file
.erl. No object files are produced. Mainly useful for debugging and
interest.
· to_core0, to-core0, to_core, to-core - Print a listing of the Core
Erlang code before/after being optimised in the files .core. No ob‐
ject files are produced. Mainly useful for debugging and interest.
· to_kernel, to-kernel - Print a listing of the Kernel Erlang code in
the files .kernel. No object files are produced. Mainly useful for
debugging and interest.
· to_asm, to-asm - Print a listing of the Beam code in the files .S.
No object files are produced. Mainly useful for debugging and inter‐
est.
· {outdir,Dir}, [outdir,Dir] - Save the generated files in director Dir
instead of the current directory.
· {i,Dir}, [i,Dir] - Add dir to the list of directories to be searched
when including a file.
· report - Print the errors and warnings as they occur.
· return - Return an extra return field containing Warnings on success
or the errors and warnings in {error,Errors,Warnings} when there are
errors.
· debug_print, debug-print - Causes the compiler to print a lot of de‐
bug information.
· warnings_as_errors, warnings-as-errors - Causes warnings to be treat‐
ed as errors.
· no_export_macros, no-export-macros - Do not export macros from mod‐
ules.
If the binary option is given then options that produce listing files
will cause the internal formats for that compiler pass to be returned.
Both Warnings and Errors have the following format:
[{FileName,[ErrorInfo]}]
ErrorInfo is described below. When generating Errors and Warnings the
line number is the line of the start of the form in which the error oc‐
curred. The file name has been included here to be compatible with the
Erlang compiler. As yet there is no extra information about included
files.
forms(Forms) -> CompRet
Is the same as forms(Forms, [report]).
forms(Forms, Options) -> CompRet
where
Forms = [sexpr()]
CompRet = BinRet | ErrRet
BinRet = {ok,[ModBin]} | {ok,[ModBin],Warnings}
ModBin = {ok,ModuleName,Binary} | {ok,ModuleName,Binary,Warnings}
ErrRet = error | {error,[ModErr],Errors,Warnings}
ModErr = {error,Errors,Warnings}
Compile the forms as an LFE module returning a binary. This function
takes the same options as lfe_comp:file/1/2. When generating Errors
and Warnings the “line number” is the index of the form in which the
error occurred.
format_error(Error) -> Chars
Uses an ErrorDescriptor and returns a deep list of characters which de‐
scribes the error. This function is usually called implicitly when an
ErrorInfo structure is processed. See below.
ERROR INFORMATION
The ErrorInfo mentioned above is the standard ErrorInfo structure which
is returned from all IO modules. It has the following format:
{ErrorLine,Module,ErrorDescriptor}
A string describing the error is obtained with the following call:
Module:format_error(ErrorDescriptor)
SEE ALSO
lfe_gen(3), lfe_macro(3)
AUTHORS
Robert Virding.
2008-2016 lfe_comp(3)