-
Notifications
You must be signed in to change notification settings - Fork 8
/
README
151 lines (101 loc) · 4.89 KB
/
README
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
146
147
148
149
150
=NAME
LuaFish 0.7.2 (2010-09-21)
=DESCRIPTION
This distribution provides various Lua modules for parsing Lua 5.1
source code, manipulating abstract syntax trees (AST), and serializing
ASTs back to Lua code, implemented via Lpeg.
There is also some experimental support for applying LISP-ish style
macros, doing static type checking, and compiling Lua to C.
=STATUS
WARNING!
The parsing, AST manipulation, and serialization is fairly robust
but could still have errors, and the interface is subject to change.
The AST format should be brought in sync with the Metalua AST
(minus lineinfo which likely will be changed/moved in Metalua).
The macros, static type checking, and Lua->C compiler are
incomplete or broken in various areas and should be considered
experimental. LuaInspect [6], which is newer and more actively
maintained, is suggested instead.
Please report and bugs or bug fixes to the wiki page or to github.
=TODO
- LuaFish should move closer to the Metalua AST
- Number numbers in errors are much needed.
=DEPENDENCIES
This require Lua Lpeg [2] version >= 0.9.
=INSTALLATION
Just add the "lib" directory to your LUA_PATH.
To run the examples, add the examples directory to Lua_PATH too.
=MODULES
This distribution comes with a number of modules. You might
only need some of these modules.
* luafish.parser
parses Lua source code into an abstract syntax tree (AST).
* luafish.serializer
converts an abstract syntax tree back into Lua source code.
* luafish.macro
basic macro support, including basic static type checking
support
* luafish.lua2c
Compiles Lua to C. a prototype that is very-very experimental
and makes many assumptions.
=EXAMPLES
* type_usage.lua - illustrates static type checking in Lua via macros.
* type_usage2.lua - illustrates static type checking, improved format.
* module_usage.lua - illustrates static module import and
checking method names at compile time
* module_usage2.lua - another macro style for modules.
Running:
The examples use macros and must be run specially do that the macros
get processed. An example invoking type_usage2 is below:
export LUA_PATH='lib/?.lua;examples/?.lua;?.lua'
lua bin/luafish.lua examples/type_usage2.lua
To display the AST of a file,
lua bin/luafish.lua -a examples/type_usage2.lua
=TESTS
The test suite is tall.lua.
Running:
export LUA_PATH='../lib/?.lua;?.lua'
lua test/tall.lua
=AUTHOR/COPYRIGHT
David Manura. 2007-2010.
The Lua Peg Parser is licensed under the terms of the MIT license
reproduced below. This means that Lua is free software and can be
used for both academic and commercial purposes at absolutely no cost.
For details and rationale, see http://www.lua.org/license.html .
=====================================================================
Copyright (C) 2007-2010 David Manura.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
======================================================================
=SEE ALSO
[1] Metalua ( http://luaforge.net/projects/metalua/ ) is similar
in application to this project but uses "gg" rather than LPeg for
its parser. Metalua compiles to bytecode, while this project compiles
down to Lua source code only. Metalua has existed longer and
is currently more mature. The two projects provide somewhat
different approaches.
[2] Lpeg ( http://www.inf.puc-rio.br/~roberto/lpeg.html ) - A parsing
expression grammar (PEG) pattern matching library for Lua.
It is used by this project.
[3] Cheese ( http://luaforge.net/projects/cheese/ ) - Another, earlier,
parsing expression grammar (PEG) pattern matching library for Lua.
Implemented in Pure Lua. Includes a Lua parser.
[4] LuaParse ( http://luaforge.net/projects/luaparse/ ) - another
Lua parser, written in pure Lua.
[5] LuaGrammar ( http://lua-users.org/wiki/LuaGrammar ) - other
resources on parsing/lexing Lua's grammar.
[6] LuaInspect ( http://lua-users.org/wiki/LuaInspect ) - source code analysis.