LTCN or "Lua Table Constructor Notation" is a Lua library for parsing
and deserializing Lua table syntax via an LPeg grammar. It's intended
to parse a safe subset of the Lua language and to replace many common
use cases of the
load function for reading data and configuration
- Parses any Lua table constructor that consists of string, number or boolean keys and string, number, boolean or table values.
- Handles unescaping of escape sequences in string literals.
- Discards single-line comments and long comments.
- Permits a single
returnkeyword before the outermost opening brace, to enable drop-in replacement of the
- Provides useful error messages for syntax errors, including line and column numbers.
There's no versioned release yet, but for now the SCM rock can be installed with:
luarocks --server=http://luarocks.org/dev install ltcn
Features Not Implemented
Lua 5.2+ features
The following are features that were added to Lua after version 5.1 and are deliberately not supported to simplify cross-version compatibility:
- Hexadecimal floating point literals (e.g.
- Hexadecimal escape sequences in strings (e.g.
- Whitespace escape sequences in strings (e.g.
- Unicode escape sequences in strings (e.g.
Beyond the scope of LTCN
The following are syntactical constructs of Lua that could theoretically be supported, but are considered beyond the scope of the project:
- Tables as keys (not useful without considerable extra functionality).
- Tables that require more than a simple constructor to initialize (e.g. those with self references, shared references etc.).
- Expression evaluation.
- Metatables, functions, conditionals, etc. (just use the Lua
loadfunction for this).