Skip to content

Commit

Permalink
Support LuaJIT as a separate syntax option
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyMorganz committed Jun 9, 2024
1 parent fc742ad commit 897b7f7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub enum LuaVersion {
Lua54,
#[cfg(feature = "luau")]
Luau,
#[cfg(feature = "luajit")]
LuaJIT,
}

impl From<LuaVersion> for full_moon::LuaVersion {
Expand All @@ -46,6 +48,8 @@ impl From<LuaVersion> 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(),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/verify_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 897b7f7

Please sign in to comment.