Skip to content

Commit 201017b

Browse files
committed
Updated changelog and version.
1 parent 8b81ca7 commit 201017b

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

CHANGELOG.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
Changelog
22
Dumb Lua Parser
33

4+
v2.1 (2021-09-03)
5+
- Added functions: parseExpression(), valueToAst(), validateTree(), isExpression(), newNodeFast().
6+
- Added AST node fields: AstNode.pretty, AstNode.prefix, AstNode.suffix .
7+
- tokenize(): Added option to keep whitespace tokens (which is a new token type).
8+
- toLua(): Added nodeCallback argument.
9+
- toLua(): Outputting less parentheses around some binary expressions.
10+
- toLua(): Fixed invalid output of immediately invoked function expressions and similar expressions.
11+
- toLua(): Fixed "." not always being always being considered when inserting spaces (e.g. for `x .. ...`).
12+
- TableField.key is now optional if TableField.generatedKey is true.
13+
- Fixed "_ENV" getting minified in Lua 5.2+.
14+
- Fixed parsing error for chunks ending in return statements without values.
15+
416
v2.0 (2021-06-19)
517
Major changes:
618
- Added support for Lua 5.4 and LuaJIT.
@@ -17,7 +29,7 @@ Added:
1729
- Added AST functions: cloneNode(), cloneTree(), traverseTreeReverse(), getChild(), setChild(), addChild(), removeChild().
1830
- Added token functions: concatTokens(), newToken().
1931
- Added function formatMessage().
20-
- Added AST node fields: AstVararg.declaration, AstGoto.label, AstIdentifier.attribute.
32+
- Added AST node fields: AstVararg.declaration, AstGoto.label, AstIdentifier.attribute .
2133
- Added more common fields to AST nodes.
2234
- Added argument 'leavesFirst' to traverseTree().
2335
- Added argument 'attributeName' to newNode("identifier").

dumbParser.lua

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
--= Tokenize Lua code or create ASTs (Abstract Syntax Trees)
77
--= and convert the data back to Lua.
88
--=
9-
--= Version: 2.0.1-dev
9+
--= Version: 2.1 (2021-09-03)
1010
--=
1111
--= License: MIT (see the bottom of this file)
1212
--= Website: http://luaparser.refreezed.com/
@@ -216,6 +216,7 @@ toLua()
216216
Convert an AST to Lua, optionally call a function on each node before they are turned into Lua.
217217
Any node in the tree with a .pretty attribute will override the 'prettyOuput' flag for itself and its children.
218218
Nodes can also have a .prefix and/or .suffix attribute with Lua code to output before/after the node (e.g. declaration.names[1].suffix="--[[foo]]").
219+
outputBuffer is an array of Lua code that has been output so far.
219220
Returns nil and a message on error.
220221
221222
printTokens()
@@ -421,7 +422,7 @@ Special number notation rules.
421422
422423
-============================================================]=]
423424

424-
local PARSER_VERSION = "2.0.1-dev"
425+
local PARSER_VERSION = "2.1.0"
425426

426427
local NORMALIZE_MINUS_ZERO, HANDLE_ENV
427428
do
@@ -619,6 +620,11 @@ local function populateCommonNodeFields(token, node)
619620
-- node.container = nil -- Refers to the specific table that the node is in, which could be the parent itself or a field in the parent.
620621
-- node.key = nil -- Refers to the specific field in the container that the node is in (which is either a string or an integer).
621622

623+
-- toLua() uses these fields if present:
624+
-- node.pretty = bool
625+
-- node.prefix = luaString
626+
-- node.suffix = luaString
627+
622628
return node
623629
end
624630

@@ -3040,6 +3046,11 @@ local function cloneNodeAndMaybeChildren(node, cloneChildren)
30403046
errorf("Invalid node type '%s'.", tostring(nodeType))
30413047
end
30423048

3049+
clone.pretty = node.pretty
3050+
clone.prefix = node.prefix
3051+
clone.suffix = node.suffix
3052+
-- Should we set node.token etc. too? @Incomplete
3053+
30433054
return clone
30443055
end
30453056

0 commit comments

Comments
 (0)