Repository navigation
feat(lexer,stdlib): complete Lua 5.4 lexer escapes, long strings, and stdlib edge semantics - #73
Merged
Merged
Conversation
… stdlib edge semantics Co-authored-by: esrrhs <esrrhs@163.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #73 +/- ##
========================================
Coverage 94.52% 94.52%
========================================
Files 130 130
Lines 32588 32699 +111
========================================
+ Hits 30803 30909 +106
- Misses 1785 1790 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Implements P3 (Lua 5.4 lexer & standard library edge semantics) on top of
master(including PR #69, PR #70, PR #71), without mixing in P4 or P5.Lexer & String Colon Methods
src/util/string_util.cpp(ReplaceEscapeChars): Added Lua 5.3/5.4\u{XXXX}UTF-8 codepoint escapes (0..0x7FFFFFFF, 1–6 byte extended UTF-8, arbitrary leading zeros, and strict{/ hex digit / range /}error checks). Preserved PR feat: add kernel mode and lock host language contract #69's\xHHimplementation and"invalid hexadecimal escape"diagnostic intact; leftIsNumber/IsInteger/Boost::regexuntouched (P5).src/compile/flex/scanner.l,scanner.cpp(regenerated withflex++ 2.6.4),src/compile/my_flexer.cpp:[=[...]=]) with Lua 5.4 immediate leading-newline stripping,\r\n/\n\r/\r→\nnormalization, proper handling of embedded]/]]=sequences (e.g.[=[a[1]]=],[=[a[1]]]=]), andunfinished long stringdiagnostics. Also fixed<MULTI_LINE_COMMENT_STATE>non-matching closer backtracking for--[=[a[1]]=]..5,1.,.5e2,1.e2,0x.8,0x1.,0x.8p2,0x1.p2) while preservingmalformed numberrejection on1..2,0x.,1.e,.5a, etc.--mode=kernel(floating-point literal is forbidden in --mode=kernel, honoring PR feat: add kernel mode and lock host language contract #69's host language contract).src/compile/compile_common.h,semantic_analysis.cpp,c_gen.{h,cpp},src/interp/codegen.{h,cpp}: Deduplicated the 3 copies ofkStringLibraryMethodsinto sharedStringLibraryMethods()and added Lua 5.4 methodspack,unpack,packsize.Standard Library Edge Semantics
src/native/string/native_string.cpp(string.format):bad argument #N to 'format' (no value)(fixing 1-based argument numbering).%swith modifiers rejects embedded\0withstring contains zeros(plain%sstill preserves\0).%qwith modifiers raisesspecifier '%q' cannot have modifiers.test_format_s_bad_arg_table.luacontract (string.format("%s", {})errors).src/native/basic/native_basic.cpp,src/native/table/native_table.{h,cpp}(tonumber,next,BasicPairsIterator):tonumber(e, base)with non-nilbasenow rejects non-stringe(bad argument #1 to 'tonumber' (string expected, got <type>)), stops stripping0x/0Xfor explicitbase=16(tonumber("0x10", 16) == nil), and parses integer-only for explicitbase=10. Kepttest_basic_tonumber_edge.luaintact (out-of-range and fractional bases continue returningnil). Updated two legacy coverage test assertions (test_basic_tonumber_extra.lua,test_basic_pairs_coverage.lua) that previously checked the oldtonumber("0x...", 16)behavior.TableHelper::NextKV(spec → array index →quick_data_/bucket lookup +active_pos) used by bothnextandBasicPairsIterator, eliminating O(N²) rescanning and raisinginvalid key to 'next'for absent or NaN keys innext.src/native/utf8/native_utf8.cpp:laxparameter (Lua truthiness) toutf8.len,utf8.codepoint, andutf8.codes(accepting surrogates0xD800..0xDFFFand 4–6 byte extended UTF-8 up to0x7FFFFFFFwhile still rejecting overlongs and0xFE/0xFF), updatedutf8.codesregistration to variadic, and removed the 40-line stale draft comment. Preservedutf8.charstrict validation pinned bytest_utf8_char_boundary.lua.Verification
-O3 -DNDEBUG, GCC 13.3.0): 0 new compiler warnings (src/has 0 warnings).unit_tests(FAKELUA_HOME=/agent/repos/fakelua, excluding MySQL/Redis integration tests): 1840 / 1840 passed, including 8 new regression test cases covering all P3 features acrossTCC,GCC,INTERP, and--mode=kernel.flua cmd/test.lua: passed (exit 0) across all 3 backends (--jit_type=0,--jit_type=1,--jit_type=2).