diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4edc582f..c6dfc691 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,10 +35,14 @@ jobs: run: | cd full-moon cargo test --features luajit + - name: Test (CfxLua feature) + run: | + cd full-moon + cargo test --features cfxlua - name: Test (all features) run: | cd full-moon - cargo test --features luau,lua52,lua53,lua54,luajit + cargo test --features luau,lua52,lua53,lua54,luajit,cfxlua - name: Test (no default features) run: | cd full-moon diff --git a/full-moon/Cargo.toml b/full-moon/Cargo.toml index 347f9c98..b0eda3b9 100644 --- a/full-moon/Cargo.toml +++ b/full-moon/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["lua", "parser", "lua51", "lua52", "luau", "cfxlua"] edition = "2021" [package.metadata.docs.rs] -# Build Locally: RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --features luau,lua52,lua53,lua54,luajit --no-deps --open +# Build Locally: RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --features luau,lua52,lua53,lua54,luajit,cfxlua --no-deps --open features = ["luau", "lua52", "lua53", "lua54", "luajit", "cfxlua"] rustdoc-args = ["--cfg", "docsrs"] diff --git a/full-moon/src/ast/mod.rs b/full-moon/src/ast/mod.rs index 8ab50013..39139bbe 100644 --- a/full-moon/src/ast/mod.rs +++ b/full-moon/src/ast/mod.rs @@ -11,13 +11,14 @@ use lua52::*; #[cfg(feature = "lua54")] use lua54::*; +#[cfg(feature = "luau")] +use luau::*; + #[cfg(any(feature = "luau", feature = "cfxlua"))] mod compound; #[cfg(any(feature = "luau", feature = "cfxlua"))] pub use compound::*; -#[cfg(feature = "luau")] -use luau::*; pub use parser_structs::AstResult; use punctuated::{Pair, Punctuated}; use span::ContainedSpan; diff --git a/full-moon/src/ast/parsers.rs b/full-moon/src/ast/parsers.rs index f59ed4a8..4bb02f3e 100644 --- a/full-moon/src/ast/parsers.rs +++ b/full-moon/src/ast/parsers.rs @@ -129,13 +129,13 @@ fn parse_compound_assignment(state: &mut ParserState, var: Var) -> ParserResult< return ParserResult::LexerMoved; }; - return ParserResult::Value(StmtVariant::Stmt(ast::Stmt::CompoundAssignment( + ParserResult::Value(StmtVariant::Stmt(ast::Stmt::CompoundAssignment( ast::CompoundAssignment { lhs: var, compound_operator: ast::CompoundOp::from_token(compound_operator), rhs: expr, }, - ))); + ))) } diff --git a/full-moon/tests/cfxlua_cases/pass/each_iteration/ast.snap.new b/full-moon/tests/cfxlua_cases/pass/each_iteration/ast.snap.new new file mode 100644 index 00000000..61bd34f9 --- /dev/null +++ b/full-moon/tests/cfxlua_cases/pass/each_iteration/ast.snap.new @@ -0,0 +1,646 @@ +--- +source: full-moon/tests/pass_cases.rs +assertion_line: 47 +expression: ast.nodes() +input_file: full-moon/tests/cfxlua_cases/pass/each_iteration +--- +stmts: + - - LocalAssignment: + local_token: + leading_trivia: [] + token: + start_position: + bytes: 0 + line: 1 + character: 1 + end_position: + bytes: 5 + line: 1 + character: 6 + token_type: + type: Symbol + symbol: local + trailing_trivia: + - start_position: + bytes: 5 + line: 1 + character: 6 + end_position: + bytes: 6 + line: 1 + character: 7 + token_type: + type: Whitespace + characters: " " + name_list: + pairs: + - End: + leading_trivia: [] + token: + start_position: + bytes: 6 + line: 1 + character: 7 + end_position: + bytes: 7 + line: 1 + character: 8 + token_type: + type: Identifier + identifier: t + trailing_trivia: + - start_position: + bytes: 7 + line: 1 + character: 8 + end_position: + bytes: 8 + line: 1 + character: 9 + token_type: + type: Whitespace + characters: " " + equal_token: + leading_trivia: [] + token: + start_position: + bytes: 8 + line: 1 + character: 9 + end_position: + bytes: 9 + line: 1 + character: 10 + token_type: + type: Symbol + symbol: "=" + trailing_trivia: + - start_position: + bytes: 9 + line: 1 + character: 10 + end_position: + bytes: 10 + line: 1 + character: 11 + token_type: + type: Whitespace + characters: " " + expr_list: + pairs: + - End: + TableConstructor: + braces: + tokens: + - leading_trivia: [] + token: + start_position: + bytes: 10 + line: 1 + character: 11 + end_position: + bytes: 11 + line: 1 + character: 12 + token_type: + type: Symbol + symbol: "{" + trailing_trivia: + - start_position: + bytes: 11 + line: 1 + character: 12 + end_position: + bytes: 12 + line: 1 + character: 13 + token_type: + type: Whitespace + characters: " " + - leading_trivia: [] + token: + start_position: + bytes: 20 + line: 1 + character: 21 + end_position: + bytes: 21 + line: 1 + character: 22 + token_type: + type: Symbol + symbol: "}" + trailing_trivia: + - start_position: + bytes: 21 + line: 1 + character: 22 + end_position: + bytes: 23 + line: 1 + character: 23 + token_type: + type: Whitespace + characters: "\r\n" + fields: + pairs: + - Punctuated: + - NoKey: + Number: + leading_trivia: [] + token: + start_position: + bytes: 12 + line: 1 + character: 13 + end_position: + bytes: 13 + line: 1 + character: 14 + token_type: + type: Number + text: "1" + trailing_trivia: [] + - leading_trivia: [] + token: + start_position: + bytes: 13 + line: 1 + character: 14 + end_position: + bytes: 14 + line: 1 + character: 15 + token_type: + type: Symbol + symbol: "," + trailing_trivia: + - start_position: + bytes: 14 + line: 1 + character: 15 + end_position: + bytes: 15 + line: 1 + character: 16 + token_type: + type: Whitespace + characters: " " + - Punctuated: + - NoKey: + Number: + leading_trivia: [] + token: + start_position: + bytes: 15 + line: 1 + character: 16 + end_position: + bytes: 16 + line: 1 + character: 17 + token_type: + type: Number + text: "2" + trailing_trivia: [] + - leading_trivia: [] + token: + start_position: + bytes: 16 + line: 1 + character: 17 + end_position: + bytes: 17 + line: 1 + character: 18 + token_type: + type: Symbol + symbol: "," + trailing_trivia: + - start_position: + bytes: 17 + line: 1 + character: 18 + end_position: + bytes: 18 + line: 1 + character: 19 + token_type: + type: Whitespace + characters: " " + - End: + NoKey: + Number: + leading_trivia: [] + token: + start_position: + bytes: 18 + line: 1 + character: 19 + end_position: + bytes: 19 + line: 1 + character: 20 + token_type: + type: Number + text: "3" + trailing_trivia: + - start_position: + bytes: 19 + line: 1 + character: 20 + end_position: + bytes: 20 + line: 1 + character: 21 + token_type: + type: Whitespace + characters: " " + - ~ + - - GenericFor: + for_token: + leading_trivia: [] + token: + start_position: + bytes: 23 + line: 2 + character: 1 + end_position: + bytes: 26 + line: 2 + character: 4 + token_type: + type: Symbol + symbol: for + trailing_trivia: + - start_position: + bytes: 26 + line: 2 + character: 4 + end_position: + bytes: 27 + line: 2 + character: 5 + token_type: + type: Whitespace + characters: " " + names: + pairs: + - Punctuated: + - leading_trivia: [] + token: + start_position: + bytes: 27 + line: 2 + character: 5 + end_position: + bytes: 28 + line: 2 + character: 6 + token_type: + type: Identifier + identifier: k + trailing_trivia: [] + - leading_trivia: [] + token: + start_position: + bytes: 28 + line: 2 + character: 6 + end_position: + bytes: 29 + line: 2 + character: 7 + token_type: + type: Symbol + symbol: "," + trailing_trivia: + - start_position: + bytes: 29 + line: 2 + character: 7 + end_position: + bytes: 30 + line: 2 + character: 8 + token_type: + type: Whitespace + characters: " " + - End: + leading_trivia: [] + token: + start_position: + bytes: 30 + line: 2 + character: 8 + end_position: + bytes: 31 + line: 2 + character: 9 + token_type: + type: Identifier + identifier: v + trailing_trivia: + - start_position: + bytes: 31 + line: 2 + character: 9 + end_position: + bytes: 32 + line: 2 + character: 10 + token_type: + type: Whitespace + characters: " " + in_token: + leading_trivia: [] + token: + start_position: + bytes: 32 + line: 2 + character: 10 + end_position: + bytes: 34 + line: 2 + character: 12 + token_type: + type: Symbol + symbol: in + trailing_trivia: + - start_position: + bytes: 34 + line: 2 + character: 12 + end_position: + bytes: 35 + line: 2 + character: 13 + token_type: + type: Whitespace + characters: " " + expr_list: + pairs: + - End: + FunctionCall: + prefix: + Name: + leading_trivia: [] + token: + start_position: + bytes: 35 + line: 2 + character: 13 + end_position: + bytes: 39 + line: 2 + character: 17 + token_type: + type: Identifier + identifier: each + trailing_trivia: [] + suffixes: + - Call: + AnonymousCall: + Parentheses: + parentheses: + tokens: + - leading_trivia: [] + token: + start_position: + bytes: 39 + line: 2 + character: 17 + end_position: + bytes: 40 + line: 2 + character: 18 + token_type: + type: Symbol + symbol: ( + trailing_trivia: [] + - leading_trivia: [] + token: + start_position: + bytes: 41 + line: 2 + character: 19 + end_position: + bytes: 42 + line: 2 + character: 20 + token_type: + type: Symbol + symbol: ) + trailing_trivia: + - start_position: + bytes: 42 + line: 2 + character: 20 + end_position: + bytes: 43 + line: 2 + character: 21 + token_type: + type: Whitespace + characters: " " + arguments: + pairs: + - End: + Var: + Name: + leading_trivia: [] + token: + start_position: + bytes: 40 + line: 2 + character: 18 + end_position: + bytes: 41 + line: 2 + character: 19 + token_type: + type: Identifier + identifier: t + trailing_trivia: [] + do_token: + leading_trivia: [] + token: + start_position: + bytes: 43 + line: 2 + character: 21 + end_position: + bytes: 45 + line: 2 + character: 23 + token_type: + type: Symbol + symbol: do + trailing_trivia: + - start_position: + bytes: 45 + line: 2 + character: 23 + end_position: + bytes: 46 + line: 2 + character: 24 + token_type: + type: Whitespace + characters: " " + block: + stmts: + - - FunctionCall: + prefix: + Name: + leading_trivia: [] + token: + start_position: + bytes: 46 + line: 2 + character: 24 + end_position: + bytes: 51 + line: 2 + character: 29 + token_type: + type: Identifier + identifier: print + trailing_trivia: [] + suffixes: + - Call: + AnonymousCall: + Parentheses: + parentheses: + tokens: + - leading_trivia: [] + token: + start_position: + bytes: 51 + line: 2 + character: 29 + end_position: + bytes: 52 + line: 2 + character: 30 + token_type: + type: Symbol + symbol: ( + trailing_trivia: [] + - leading_trivia: [] + token: + start_position: + bytes: 56 + line: 2 + character: 34 + end_position: + bytes: 57 + line: 2 + character: 35 + token_type: + type: Symbol + symbol: ) + trailing_trivia: + - start_position: + bytes: 57 + line: 2 + character: 35 + end_position: + bytes: 58 + line: 2 + character: 36 + token_type: + type: Whitespace + characters: " " + arguments: + pairs: + - Punctuated: + - Var: + Name: + leading_trivia: [] + token: + start_position: + bytes: 52 + line: 2 + character: 30 + end_position: + bytes: 53 + line: 2 + character: 31 + token_type: + type: Identifier + identifier: k + trailing_trivia: [] + - leading_trivia: [] + token: + start_position: + bytes: 53 + line: 2 + character: 31 + end_position: + bytes: 54 + line: 2 + character: 32 + token_type: + type: Symbol + symbol: "," + trailing_trivia: + - start_position: + bytes: 54 + line: 2 + character: 32 + end_position: + bytes: 55 + line: 2 + character: 33 + token_type: + type: Whitespace + characters: " " + - End: + Var: + Name: + leading_trivia: [] + token: + start_position: + bytes: 55 + line: 2 + character: 33 + end_position: + bytes: 56 + line: 2 + character: 34 + token_type: + type: Identifier + identifier: v + trailing_trivia: [] + - ~ + end_token: + leading_trivia: [] + token: + start_position: + bytes: 58 + line: 2 + character: 36 + end_position: + bytes: 61 + line: 2 + character: 39 + token_type: + type: Symbol + symbol: end + trailing_trivia: + - start_position: + bytes: 61 + line: 2 + character: 39 + end_position: + bytes: 63 + line: 2 + character: 40 + token_type: + type: Whitespace + characters: "\r\n" + type_specifiers: + - ~ + - ~ + - ~