davidm / lua-parser-loose

loose parsing of Lua code, ignoring syntax errors
Other
14 stars 3 forks source link

DESCRIPTION

lua_parser_loose

Does loose parsing of Lua code. If the code has syntax errors, the parse does not abort; rather, some information (e.g. local and global variable scopes) is still inferred. This may be useful for code interactively typed into a text editor.

Characteristics of this code:

STABILITY

This is fairly well tested, but the code is new and might still have errors. Standard tests are performed in "test/test.lua". More extensive tests are in "test/test_luac.lua", which validates the parser's local/global variable detection against the luac bytecode output listings. test_luac.lua has been performed against the entire LuaDist source code repository (about 2700 .lua files), or at least the Lua files in it having no syntax errors.

EXAMPLES

This includes as an example of expanding Lua 5.2 code to Lua 5.1 code with explicit _ENV variables. Example:

"function f(_ENV, x) print(x, y)" -->
"function _ENV.f(_ENV, x) _ENV.print(x, _ENV.y) end"

See example/env.lua and example/lib/compat_envvar.lua. Also see https://github.com/davidm/lua-compat-env .

DEPENDENCIES/INSTALLATION

Copy lua_parser_loose.lua and lua_lexer_loose.lua into your Lua path. To test, just run "lua test.lua" in the "test" folder.

There are no dependencies.

COPYRIGHT

See COPYRIGHT. (c) 2013 David Manura. MIT License (same as Lua 5.1). 2013-04