Releases: ReFreezed/DumbLuaParser
Releases · ReFreezed/DumbLuaParser
Version 2.3
Changes since 2.2
- Added utility functions: findDeclaredNames(), findGlobalReferences(), findShadows().
- Added token functions: updateToken(), cloneToken().
simplify()
handles some more cases.- Fixed
newToken("string")
always raising an error.
Version 2.2
Version 2.1
Changes
- Added functions:
parseExpression()
,valueToAst()
,validateTree()
,isExpression()
,newNodeFast()
. - Added AST node fields:
AstNode.pretty
,AstNode.prefix
,AstNode.suffix
. tokenize()
: Added option to keep whitespace tokens (which is a new token type).toLua()
: AddednodeCallback
argument.toLua()
: Outputting less parentheses around some binary expressions.toLua()
: Fixed invalid output of immediately invoked function expressions and similar expressions.toLua()
: Fixed"."
not always being always being considered when inserting spaces (e.g. forx .. ...
).- TableField.key is now optional if
TableField.generatedKey
is true. - Fixed
_ENV
getting minified in Lua 5.2+. - Fixed parsing error for chunks ending in return statements without values.
Version 2.0
This version is not compatible with earlier versions!
Changes
Major Changes
- Added support for Lua 5.4 and LuaJIT.
- Added functions:
simplify()
,optimize()
,minify()
. - Tokens are now represented by individual tables. Token streams are now simple arrays of tokens.
- Changed
AstIdentifier.declaration
to point to the declared identifier instead of the parent declaration/function/for
loop. - Changed
AstLabel.name
andAstGoto.name
to be strings instead of identifiers. - Removed
AstFunction.vararg
. (Any vararg parameter is now at the end ofAstFunction.parameters
.) - Parsing and tokenizing functions no longer print anything on error - they only return the message (which now includes more information).
toLua()
no longer prints anything on error - instead it returns the message.
Added
- Added support for binary number notation
0b1101001
(from LuaJIT). - Added special parsing rules for
n/0
. - Added AST functions:
cloneNode()
,cloneTree()
,traverseTreeReverse()
,getChild()
,setChild()
,addChild()
,removeChild()
. - Added token functions:
concatTokens()
,newToken()
. - Added function
formatMessage()
. - Added AST node fields:
AstVararg.declaration
,AstGoto.label
,AstIdentifier.attribute
. - Added more common fields to AST nodes.
- Added argument
leavesFirst
totraverseTree()
. - Added argument
attributeName
tonewNode("identifier")
. - Added argument
updateTopNodePosition
toupdateReferences()
. - Added parser settings:
printIds
,printLocations
,indentation
,constantNameReplacementStringMaxLength
. - Added parser constants:
INT_SIZE
,MAX_INT
,MIN_INT
. - Added internal fallback parser for string values so features added in later Lua versions are supported in all versions.
- LuaJIT: Support numeral suffixes
LL
,ULL
andi
.
Changed
break
statements are allowed in the middle of blocks (according to Lua 5.2).-0
is no longer normalized to0
in Lua 5.2 and earlier (except bysimplify()
) to match Lua's behavior.newNode("label")
andnewNode("goto")
now require alabelName
argument.- Renamed
parse(path)
function variant toparseFile()
. - The path argument for
parse(luaString)
function variant is now optional. - Renamed
tokenizeString()
totokenize()
(to follow the same naming scheme asparse()
andparseFile()
). toLua()
: Improved string literal output.toLua()
: Integers gets outputted as integers (as opposed to floats with scientific notation) in more cases.- Updated "malformed number" error detection.
- Parsing: Improved location information for blocks and functions.
- Whitespace is no longer trimmed from comment tokens.
- Improved error messages.
Removed
- Removed functions:
newTokenStream()
(use{}
instead),insertToken()
(usetable.insert()
instead),removeToken()
(usetable.remove()
instead).
Fixed
- Fixed
toLua()
outputting expressions like- -x
as--x
. - Fixed print functions printing unprintable/"bad" characters in strings.
- Fixed the location in a syntax error message.
- Fixed questionable handling of newlines in single-line comment tokens.
Repository
- Added examples.lua.
Version 1.2.1
Changes:
- Fixed lookups and calls that shouldn't parse, like
"":sub()
.
Version 1.2
Changes:
- Added
parser.updateReferences()
. - Changed arguments for
parser.traverseTree()
and the callback. - Fixed parsing of consecutive unary operations.