From 897b7f709e778f19d4e248856762df30c1f322bc Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sun, 9 Jun 2024 13:49:34 +0200 Subject: [PATCH] Support LuaJIT as a separate syntax option --- .github/workflows/ci.yml | 7 +++++++ .github/workflows/release.yml | 2 +- Cargo.toml | 1 + src/lib.rs | 4 ++++ src/verify_ast.rs | 6 +++--- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f98a42b4..9f8a9e18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,6 +52,13 @@ jobs: - name: Test (Lua 5.4) run: cargo test --features lua54 + test_luajit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Test (LuaJIT) + run: cargo test --features luajit + test_wasm: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc453585..cf4dcb09 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,7 +67,7 @@ jobs: sudo apt install ${{ matrix.linker }} - name: Build Binary (All features) - run: cargo build --verbose --locked --release --features lua52,lua53,lua54,luau --target ${{ matrix.cargo-target }} + run: cargo build --verbose --locked --release --features lua52,lua53,lua54,luau,luajit --target ${{ matrix.cargo-target }} env: CARGO_TARGET_DIR: output diff --git a/Cargo.toml b/Cargo.toml index 25bf8e2b..9e469d5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ luau = ["full_moon/roblox"] lua52 = ["full_moon/lua52"] lua53 = ["lua52", "full_moon/lua53"] lua54 = ["lua53", "full_moon/lua54"] +luajit = ["full_moon/luajit"] editorconfig = ["ec4rs"] [dependencies] diff --git a/src/lib.rs b/src/lib.rs index c6df9b07..e8af63ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,6 +31,8 @@ pub enum LuaVersion { Lua54, #[cfg(feature = "luau")] Luau, + #[cfg(feature = "luajit")] + LuaJIT, } impl From for full_moon::LuaVersion { @@ -46,6 +48,8 @@ impl From for full_moon::LuaVersion { LuaVersion::Lua54 => full_moon::LuaVersion::lua54(), #[cfg(feature = "luau")] LuaVersion::Luau => full_moon::LuaVersion::luau(), + #[cfg(feature = "luajit")] + LuaVersion::LuaJIT => full_moon::LuaVersion::luajit(), } } } diff --git a/src/verify_ast.rs b/src/verify_ast.rs index 3c8af158..5e761ae8 100644 --- a/src/verify_ast.rs +++ b/src/verify_ast.rs @@ -307,14 +307,14 @@ mod tests { } #[test] - #[cfg(feature = "lua52")] + #[cfg(feature = "luajit")] fn test_equivalent_luajit_numbers() { use full_moon::LuaVersion; - let input_ast = full_moon::parse_fallible("local x = 2 ^ 63LL", LuaVersion::lua52()) + let input_ast = full_moon::parse_fallible("local x = 2 ^ 63LL", LuaVersion::luajit()) .into_result() .unwrap(); - let output_ast = full_moon::parse_fallible("local x = 2 ^ 63", LuaVersion::lua52()) + let output_ast = full_moon::parse_fallible("local x = 2 ^ 63", LuaVersion::luajit()) .into_result() .unwrap();