Add Lua function call syntactic sugar and improve parser robustness #133
+231
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the Lua parser with three major improvements to support more idiomatic Lua 5.3 syntax patterns. All changes include comprehensive unit tests.
Changes
1. Function Call Syntactic Sugar
Implements Lua's syntactic sugar for function calls without parentheses:
func "string"→func("string")func{table}→func({table})Examples:
2. Empty Statement Support
The parser now correctly handles semicolons as empty statements:
;;; print "test" ;;3. Comments in Expressions
The parser now skips comments that appear within expressions:
This enables more idiomatic Lua code with inline documentation.
Implementation Details
Parser modifications:
parse_block_accto skip semicolons at the block levelparse_stmt_innerto avoid infinite recursionparse_prefixfor expression-level commentsparse_infixto recognize string/table tokens after function namesTest coverage:
test/lua/parser/expr_test.exs)test/lua/parser/expr_test.exs)test/lua/parser/statement_test.exs)Testing
All 1120 tests pass, including 17 new parser tests.
The Lua 5.3 test suite's
constructs.luafile now parses successfully (it fails at runtime due to missing the debug module, which is expected).Related
This builds on the work from #132 (load function implementation) and improves parser compatibility with the Lua 5.3 test suite.
🤖 Generated with Claude Code