From 38057fa26a4722fdfc65e3f2157e0ec05aae23b6 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Fri, 20 Jan 2023 09:57:11 -0300 Subject: [PATCH 1/2] remove entries and make `ConstantDefinition` self contained --- src/parser/internal/definition/constant.rs | 14 +- src/tree/definition/constant.rs | 12 +- tests/samples/0028/code.ara | 3 +- tests/samples/0028/tree.txt | 60 +- tests/samples/0029/error.txt | 9 + tests/samples/0029/tree.txt | 60 - tests/samples/0043/error.txt | 9 + tests/samples/0043/tree.txt | 60 - tests/samples/0059/tree.txt | 27 +- tests/samples/0060/tree.txt | 70 +- tests/samples/0076/tree.txt | 70 +- tests/samples/0085/tree.txt | 1783 ++++++++++---------- tests/samples/0089/tree.txt | 35 +- tests/samples/0093/tree.txt | 35 +- tests/samples/0107/tree.txt | 71 +- 15 files changed, 1079 insertions(+), 1239 deletions(-) create mode 100644 tests/samples/0029/error.txt delete mode 100644 tests/samples/0029/tree.txt create mode 100644 tests/samples/0043/error.txt delete mode 100644 tests/samples/0043/tree.txt diff --git a/src/parser/internal/definition/constant.rs b/src/parser/internal/definition/constant.rs index 819e5d0..7d378d0 100644 --- a/src/parser/internal/definition/constant.rs +++ b/src/parser/internal/definition/constant.rs @@ -13,17 +13,9 @@ pub fn constant_definition(state: &mut State) -> ParseResult Ok(ConstantDefinition { comments: state.iterator.comments(), r#const: utils::skip_keyword(state, TokenKind::Const)?, - entries: utils::at_least_one_comma_separated( - state, - &|state| { - Ok(ConstantDefinitionEntry { - name: identifier::constant_identifier(state)?, - equals: utils::skip(state, TokenKind::Equals)?, - value: expression::create(state)?, - }) - }, - TokenKind::SemiColon, - )?, + name: identifier::constant_identifier(state)?, + equals: utils::skip(state, TokenKind::Equals)?, + value: expression::create(state)?, semicolon: utils::skip_semicolon(state)?, }) } diff --git a/src/tree/definition/constant.rs b/src/tree/definition/constant.rs index de88994..1dde5e6 100644 --- a/src/tree/definition/constant.rs +++ b/src/tree/definition/constant.rs @@ -24,7 +24,9 @@ pub struct ConstantDefinitionEntry { pub struct ConstantDefinition { pub comments: CommentGroup, pub r#const: Keyword, - pub entries: CommaSeparated, + pub name: Identifier, + pub equals: usize, + pub value: Expression, pub semicolon: usize, } @@ -71,13 +73,7 @@ impl Node for ConstantDefinition { } fn children(&self) -> Vec<&dyn Node> { - let mut children: Vec<&dyn Node> = vec![&self.r#const]; - - for entry in &self.entries.inner { - children.push(entry); - } - - children + vec![&self.r#const, &self.name, &self.value] } fn get_description(&self) -> String { diff --git a/tests/samples/0028/code.ara b/tests/samples/0028/code.ara index 7f32c76..c69793c 100644 --- a/tests/samples/0028/code.ara +++ b/tests/samples/0028/code.ara @@ -1 +1,2 @@ -const FOO = 1; \ No newline at end of file +const FOO = 1; +const BAR = FOO; diff --git a/tests/samples/0028/tree.txt b/tests/samples/0028/tree.txt index 657cecd..39f5d16 100644 --- a/tests/samples/0028/tree.txt +++ b/tests/samples/0028/tree.txt @@ -9,32 +9,48 @@ DefinitionTree { value: "const", position: 0, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 6, - value: "FOO", + name: Identifier { + position: 6, + value: "FOO", + }, + equals: 10, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 10, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 12, - }, - ), - ), + value: "1", + position: 12, }, - ], - commas: [], - }, + ), + ), semicolon: 13, }, ), + Constant( + ConstantDefinition { + comments: CommentGroup { + comments: [], + }, + const: Keyword { + value: "const", + position: 16, + }, + name: Identifier { + position: 22, + value: "BAR", + }, + equals: 26, + value: Identifier( + Identifier { + position: 28, + value: "FOO", + }, + ), + semicolon: 31, + }, + ), ], - eof: 14, + eof: 33, } \ No newline at end of file diff --git a/tests/samples/0029/error.txt b/tests/samples/0029/error.txt new file mode 100644 index 0000000..a148fb1 --- /dev/null +++ b/tests/samples/0029/error.txt @@ -0,0 +1,9 @@ +error[P0013]: unexpected token `,`, expected `;` + --> 0029/code.ara:1:14 + | +1 | const FOO = 1, BAR = 2; + | ^ + +error: failed to parse "0029/code.ara" due to the above issue(s) + = summary: 1 error(s) + diff --git a/tests/samples/0029/tree.txt b/tests/samples/0029/tree.txt deleted file mode 100644 index 9aa2ef3..0000000 --- a/tests/samples/0029/tree.txt +++ /dev/null @@ -1,60 +0,0 @@ -DefinitionTree { - definitions: [ - Constant( - ConstantDefinition { - comments: CommentGroup { - comments: [], - }, - const: Keyword { - value: "const", - position: 0, - }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 6, - value: "FOO", - }, - equals: 10, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 12, - }, - ), - ), - }, - ConstantDefinitionEntry { - name: Identifier { - position: 15, - value: "BAR", - }, - equals: 19, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2", - position: 21, - }, - ), - ), - }, - ], - commas: [ - 13, - ], - }, - semicolon: 22, - }, - ), - ], - eof: 23, -} \ No newline at end of file diff --git a/tests/samples/0043/error.txt b/tests/samples/0043/error.txt new file mode 100644 index 0000000..a685690 --- /dev/null +++ b/tests/samples/0043/error.txt @@ -0,0 +1,9 @@ +error[P0013]: unexpected token `,`, expected `;` + --> 0043/code.ara:1:14 + | +1 | const A = 3, + | ^ + +error: failed to parse "0043/code.ara" due to the above issue(s) + = summary: 1 error(s) + diff --git a/tests/samples/0043/tree.txt b/tests/samples/0043/tree.txt deleted file mode 100644 index 746d391..0000000 --- a/tests/samples/0043/tree.txt +++ /dev/null @@ -1,60 +0,0 @@ -DefinitionTree { - definitions: [ - Constant( - ConstantDefinition { - comments: CommentGroup { - comments: [], - }, - const: Keyword { - value: "const", - position: 0, - }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 8, - value: "A", - }, - equals: 10, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "3", - position: 12, - }, - ), - ), - }, - ConstantDefinitionEntry { - name: Identifier { - position: 23, - value: "B", - }, - equals: 25, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "3", - position: 27, - }, - ), - ), - }, - ], - commas: [ - 13, - ], - }, - semicolon: 28, - }, - ), - ], - eof: 30, -} \ No newline at end of file diff --git a/tests/samples/0059/tree.txt b/tests/samples/0059/tree.txt index 870168d..5b74da8 100644 --- a/tests/samples/0059/tree.txt +++ b/tests/samples/0059/tree.txt @@ -9,24 +9,17 @@ DefinitionTree { value: "const", position: 0, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 6, - value: "a", - }, - equals: 8, - value: Identifier( - Identifier { - position: 10, - value: "\null", - }, - ), - }, - ], - commas: [], + name: Identifier { + position: 6, + value: "a", }, + equals: 8, + value: Identifier( + Identifier { + position: 10, + value: "\null", + }, + ), semicolon: 15, }, ), diff --git a/tests/samples/0060/tree.txt b/tests/samples/0060/tree.txt index 81e6878..6cbc46c 100644 --- a/tests/samples/0060/tree.txt +++ b/tests/samples/0060/tree.txt @@ -466,29 +466,22 @@ DefinitionTree { value: "const", position: 316, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 322, - value: "from", + name: Identifier { + position: 322, + value: "from", + }, + equals: 327, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 327, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "243", - position: 329, - }, - ), - ), + value: "243", + position: 329, }, - ], - commas: [], - }, + ), + ), semicolon: 332, }, ), @@ -501,29 +494,22 @@ DefinitionTree { value: "const", position: 334, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 340, - value: "enum", + name: Identifier { + position: 340, + value: "enum", + }, + equals: 345, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 345, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "243", - position: 347, - }, - ), - ), + value: "243", + position: 347, }, - ], - commas: [], - }, + ), + ), semicolon: 350, }, ), diff --git a/tests/samples/0076/tree.txt b/tests/samples/0076/tree.txt index a4df6fd..9e726eb 100644 --- a/tests/samples/0076/tree.txt +++ b/tests/samples/0076/tree.txt @@ -21,29 +21,22 @@ DefinitionTree { value: "const", position: 18, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 24, - value: "where", + name: Identifier { + position: 24, + value: "where", + }, + equals: 30, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 30, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 32, - }, - ), - ), + value: "1", + position: 32, }, - ], - commas: [], - }, + ), + ), semicolon: 33, }, ), @@ -689,29 +682,22 @@ DefinitionTree { value: "const", position: 434, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 440, - value: "type", + name: Identifier { + position: 440, + value: "type", + }, + equals: 445, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 445, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 447, - }, - ), - ), + value: "1", + position: 447, }, - ], - commas: [], - }, + ), + ), semicolon: 448, }, ), diff --git a/tests/samples/0085/tree.txt b/tests/samples/0085/tree.txt index 7d20a06..aa05471 100644 --- a/tests/samples/0085/tree.txt +++ b/tests/samples/0085/tree.txt @@ -9,1080 +9,1073 @@ DefinitionTree { value: "const", position: 0, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 6, - value: "FOO", - }, - equals: 10, - value: Vec( - VecExpression { - comments: CommentGroup { - comments: [], - }, - vec: Keyword { - value: "vec", - position: 12, - }, - left_bracket: 15, - elements: CommaSeparated { - inner: [ - VecElementExpression { - value: Identifier( - Identifier { - position: 21, - value: "Qux", - }, - ), + name: Identifier { + position: 6, + value: "FOO", + }, + equals: 10, + value: Vec( + VecExpression { + comments: CommentGroup { + comments: [], + }, + vec: Keyword { + value: "vec", + position: 12, + }, + left_bracket: 15, + elements: CommaSeparated { + inner: [ + VecElementExpression { + value: Identifier( + Identifier { + position: 21, + value: "Qux", + }, + ), + }, + VecElementExpression { + value: ClassOperation( + ConstantFetch { + comments: CommentGroup { + comments: [], + }, + class: Identifier( + Identifier { + position: 30, + value: "Foo", + }, + ), + double_colon: 33, + constant: Identifier { + position: 35, + value: "Bar", + }, + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Addition { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ClassOperation( - ConstantFetch { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - class: Identifier( - Identifier { - position: 30, - value: "Foo", - }, - ), - double_colon: 33, - constant: Identifier { - position: 35, - value: "Bar", - }, + value: "1", + position: 44, }, ), - }, - VecElementExpression { - value: ArithmeticOperation( - Addition { + ), + plus: 46, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 44, - }, - ), - ), - plus: 46, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2", - position: 48, - }, - ), - ), + value: "2", + position: 48, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Subtraction { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ArithmeticOperation( - Subtraction { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "3", - position: 55, - }, - ), - ), - minus: 57, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "4", - position: 59, - }, - ), - ), + value: "3", + position: 55, }, ), - }, - VecElementExpression { - value: ArithmeticOperation( - Multiplication { + ), + minus: 57, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "5", - position: 66, - }, - ), - ), - asterisk: 68, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "6", - position: 70, - }, - ), - ), + value: "4", + position: 59, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Multiplication { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ArithmeticOperation( - Division { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "7", - position: 77, - }, - ), - ), - slash: 79, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "8", - position: 81, - }, - ), - ), + value: "5", + position: 66, }, ), - }, - VecElementExpression { - value: ArithmeticOperation( - Modulo { + ), + asterisk: 68, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "9", - position: 88, - }, - ), - ), - percent: 90, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "10", - position: 92, - }, - ), - ), + value: "6", + position: 70, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Division { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ArithmeticOperation( - Exponentiation { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "11", - position: 100, - }, - ), - ), - pow: 103, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "12", - position: 106, - }, - ), - ), + value: "7", + position: 77, }, ), - }, - VecElementExpression { - value: BitwiseOperation( - LeftShift { + ), + slash: 79, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "13", - position: 114, - }, - ), - ), - left_shift: 117, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "14", - position: 120, - }, - ), - ), + value: "8", + position: 81, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Modulo { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: BitwiseOperation( - RightShift { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "15", - position: 128, - }, - ), - ), - right_shift: 131, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "16", - position: 134, - }, - ), - ), + value: "9", + position: 88, }, ), - }, - VecElementExpression { - value: BitwiseOperation( - And { + ), + percent: 90, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "17", - position: 142, - }, - ), - ), - and: 145, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "18", - position: 147, - }, - ), - ), + value: "10", + position: 92, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Exponentiation { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: BitwiseOperation( - Or { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "19", - position: 155, - }, - ), - ), - or: 158, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "20", - position: 160, - }, - ), - ), + value: "11", + position: 100, }, ), - }, - VecElementExpression { - value: BitwiseOperation( - Xor { + ), + pow: 103, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "21", - position: 168, - }, - ), - ), - xor: 171, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "22", - position: 173, - }, - ), - ), + value: "12", + position: 106, }, ), - }, - VecElementExpression { - value: LogicalOperation( - And { - comments: CommentGroup { + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + LeftShift { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "23", - position: 181, - }, - ), - ), - double_ampersand: 184, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "24", - position: 187, - }, - ), - ), + value: "13", + position: 114, }, ), - }, - VecElementExpression { - value: LogicalOperation( - Or { + ), + left_shift: 117, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "25", - position: 195, - }, - ), - ), - double_pipe: 198, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "26", - position: 201, - }, - ), - ), + value: "14", + position: 120, }, ), + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + RightShift { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: CoalesceOperation( - Coalesce { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "27", - position: 209, - }, - ), - ), - double_question: 212, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "28", - position: 215, - }, - ), - ), + value: "15", + position: 128, }, ), - }, - VecElementExpression { - value: ComparisonOperation( - Spaceship { + ), + right_shift: 131, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "29", - position: 223, - }, - ), - ), - spaceship: 226, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "30", - position: 230, - }, - ), - ), + value: "16", + position: 134, }, ), + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + And { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ComparisonOperation( - Identical { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "31", - position: 238, - }, - ), - ), - triple_equals: 241, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "32", - position: 245, - }, - ), - ), + value: "17", + position: 142, }, ), - }, - VecElementExpression { - value: ComparisonOperation( - NotIdentical { + ), + and: 145, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "33", - position: 253, - }, - ), - ), - bang_double_equals: 256, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "34", - position: 260, - }, - ), - ), + value: "18", + position: 147, }, ), + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + Or { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ComparisonOperation( - Equal { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "35", - position: 268, - }, - ), - ), - double_equals: 271, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "36", - position: 274, - }, - ), - ), + value: "19", + position: 155, }, ), - }, - VecElementExpression { - value: ComparisonOperation( - NotEqual { + ), + or: 158, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "37", - position: 282, - }, - ), - ), - bang_equals: 285, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "38", - position: 288, - }, - ), - ), + value: "20", + position: 160, }, ), + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + Xor { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ComparisonOperation( - LessThanOrEqual { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "39", - position: 296, - }, - ), - ), - less_than_equals: 299, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "40", - position: 302, - }, - ), - ), + value: "21", + position: 168, }, ), - }, - VecElementExpression { - value: ComparisonOperation( - GreaterThanOrEqual { + ), + xor: 171, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "41", - position: 310, - }, - ), - ), - greater_than_equals: 313, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "42", - position: 316, - }, - ), - ), + value: "22", + position: 173, }, ), + ), + }, + ), + }, + VecElementExpression { + value: LogicalOperation( + And { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ComparisonOperation( - LessThan { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "43", - position: 324, - }, - ), - ), - less_than: 327, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "44", - position: 329, - }, - ), - ), + value: "23", + position: 181, }, ), - }, - VecElementExpression { - value: ComparisonOperation( - GreaterThan { + ), + double_ampersand: 184, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "45", - position: 337, - }, - ), - ), - greater_than: 340, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "46", - position: 342, - }, - ), - ), + value: "24", + position: 187, }, ), + ), + }, + ), + }, + VecElementExpression { + value: LogicalOperation( + Or { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: StringOperation( - Concat { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""a"", - position: 350, - }, - ), - ), - dot: 354, - right: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""b"", - position: 356, - }, - ), - ), + value: "25", + position: 195, }, ), + ), + double_pipe: 198, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "26", + position: 201, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: CoalesceOperation( + Coalesce { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: LogicalOperation( - Not { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - bang: 365, - right: Identifier( - Identifier { - position: 366, - value: "Biz", - }, - ), + value: "27", + position: 209, }, ), + ), + double_question: 212, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "28", + position: 215, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + Spaceship { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: BitwiseOperation( - Not { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - not: 375, - right: Identifier( - Identifier { - position: 376, - value: "Baz", - }, - ), + value: "29", + position: 223, + }, + ), + ), + spaceship: 226, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "30", + position: 230, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + Identical { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ArithmeticOperation( - Positive { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - plus: 385, - right: Identifier( - Identifier { - position: 386, - value: "Qux", - }, - ), + value: "31", + position: 238, }, ), + ), + triple_equals: 241, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "32", + position: 245, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + NotIdentical { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ArithmeticOperation( - Negative { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - minus: 395, - right: Identifier( - Identifier { - position: 396, - value: "Foo", - }, - ), + value: "33", + position: 253, + }, + ), + ), + bang_double_equals: 256, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "34", + position: 260, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + Equal { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: Tuple( - TupleExpression { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left_parenthesis: 405, - elements: CommaSeparated { - inner: [ - Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 406, - }, - ), - ), - Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2", - position: 409, - }, - ), - ), - Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "3", - position: 412, - }, - ), - ), - ], - commas: [ - 407, - 410, - ], + value: "35", + position: 268, + }, + ), + ), + double_equals: 271, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - right_parenthesis: 413, + value: "36", + position: 274, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + NotEqual { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: Dict( - DictExpression { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - dict: Keyword { - value: "dict", - position: 420, + value: "37", + position: 282, + }, + ), + ), + bang_equals: 285, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - left_bracket: 424, - elements: CommaSeparated { - inner: [ - DictElementExpression { - key: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 434, - }, - ), - ), - double_arrow: 436, - value: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""a"", - position: 439, - }, - ), - ), + value: "38", + position: 288, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + LessThanOrEqual { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "39", + position: 296, + }, + ), + ), + less_than_equals: 299, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "40", + position: 302, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + GreaterThanOrEqual { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "41", + position: 310, + }, + ), + ), + greater_than_equals: 313, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "42", + position: 316, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + LessThan { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "43", + position: 324, + }, + ), + ), + less_than: 327, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "44", + position: 329, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + GreaterThan { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "45", + position: 337, + }, + ), + ), + greater_than: 340, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "46", + position: 342, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: StringOperation( + Concat { + comments: CommentGroup { + comments: [], + }, + left: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""a"", + position: 350, + }, + ), + ), + dot: 354, + right: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""b"", + position: 356, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: LogicalOperation( + Not { + comments: CommentGroup { + comments: [], + }, + bang: 365, + right: Identifier( + Identifier { + position: 366, + value: "Biz", + }, + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + Not { + comments: CommentGroup { + comments: [], + }, + not: 375, + right: Identifier( + Identifier { + position: 376, + value: "Baz", + }, + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Positive { + comments: CommentGroup { + comments: [], + }, + plus: 385, + right: Identifier( + Identifier { + position: 386, + value: "Qux", + }, + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Negative { + comments: CommentGroup { + comments: [], + }, + minus: 395, + right: Identifier( + Identifier { + position: 396, + value: "Foo", + }, + ), + }, + ), + }, + VecElementExpression { + value: Tuple( + TupleExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 405, + elements: CommaSeparated { + inner: [ + Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - DictElementExpression { - key: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2", - position: 452, - }, - ), - ), - double_arrow: 454, - value: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""b"", - position: 457, - }, - ), - ), + value: "1", + position: 406, + }, + ), + ), + Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - DictElementExpression { - key: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "3", - position: 470, - }, - ), - ), - double_arrow: 472, - value: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""c"", - position: 475, - }, - ), - ), + value: "2", + position: 409, + }, + ), + ), + Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - ], - commas: [ - 442, - 460, - 478, - ], - }, - right_bracket: 484, + value: "3", + position: 412, + }, + ), + ), + ], + commas: [ + 407, + 410, + ], + }, + right_parenthesis: 413, + }, + ), + }, + VecElementExpression { + value: Dict( + DictExpression { + comments: CommentGroup { + comments: [], + }, + dict: Keyword { + value: "dict", + position: 420, + }, + left_bracket: 424, + elements: CommaSeparated { + inner: [ + DictElementExpression { + key: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "1", + position: 434, + }, + ), + ), + double_arrow: 436, + value: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""a"", + position: 439, + }, + ), + ), }, - ), + DictElementExpression { + key: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "2", + position: 452, + }, + ), + ), + double_arrow: 454, + value: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""b"", + position: 457, + }, + ), + ), + }, + DictElementExpression { + key: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "3", + position: 470, + }, + ), + ), + double_arrow: 472, + value: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""c"", + position: 475, + }, + ), + ), + }, + ], + commas: [ + 442, + 460, + 478, + ], }, - ], - commas: [ - 24, - 38, - 49, - 60, - 71, - 82, - 94, - 108, - 122, - 136, - 149, - 162, - 175, - 189, - 203, - 217, - 232, - 247, - 262, - 276, - 290, - 304, - 318, - 331, - 344, - 359, - 369, - 379, - 389, - 399, - 414, - 485, - ], - }, - right_bracket: 487, + right_bracket: 484, + }, + ), }, - ), + ], + commas: [ + 24, + 38, + 49, + 60, + 71, + 82, + 94, + 108, + 122, + 136, + 149, + 162, + 175, + 189, + 203, + 217, + 232, + 247, + 262, + 276, + 290, + 304, + 318, + 331, + 344, + 359, + 369, + 379, + 389, + 399, + 414, + 485, + ], }, - ], - commas: [], - }, + right_bracket: 487, + }, + ), semicolon: 488, }, ), diff --git a/tests/samples/0089/tree.txt b/tests/samples/0089/tree.txt index e336c11..e6ad6c7 100644 --- a/tests/samples/0089/tree.txt +++ b/tests/samples/0089/tree.txt @@ -21,29 +21,22 @@ DefinitionTree { value: "const", position: 15, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 21, - value: "in", + name: Identifier { + position: 21, + value: "in", + }, + equals: 24, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 24, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 26, - }, - ), - ), + value: "1", + position: 26, }, - ], - commas: [], - }, + ), + ), semicolon: 27, }, ), diff --git a/tests/samples/0093/tree.txt b/tests/samples/0093/tree.txt index 4f3835a..42a71de 100644 --- a/tests/samples/0093/tree.txt +++ b/tests/samples/0093/tree.txt @@ -21,29 +21,22 @@ DefinitionTree { value: "const", position: 18, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 24, - value: "using", + name: Identifier { + position: 24, + value: "using", + }, + equals: 30, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 30, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 32, - }, - ), - ), + value: "1", + position: 32, }, - ], - commas: [], - }, + ), + ), semicolon: 33, }, ), diff --git a/tests/samples/0107/tree.txt b/tests/samples/0107/tree.txt index 4265292..26aa87e 100644 --- a/tests/samples/0107/tree.txt +++ b/tests/samples/0107/tree.txt @@ -9,47 +9,40 @@ DefinitionTree { value: "const", position: 0, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 6, - value: "ONE", + name: Identifier { + position: 6, + value: "ONE", + }, + equals: 10, + value: ClassOperation( + Initialization { + comments: CommentGroup { + comments: [], + }, + new: Keyword { + value: "new", + position: 12, + }, + class: Identifier( + Identifier { + position: 16, + value: "Foo", }, - equals: 10, - value: ClassOperation( - Initialization { - comments: CommentGroup { - comments: [], - }, - new: Keyword { - value: "new", - position: 12, - }, - class: Identifier( - Identifier { - position: 16, - value: "Foo", - }, - ), - generics: None, - arguments: ArgumentListExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 19, - arguments: CommaSeparated { - inner: [], - commas: [], - }, - right_parenthesis: 20, - }, - }, - ), + ), + generics: None, + arguments: ArgumentListExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 19, + arguments: CommaSeparated { + inner: [], + commas: [], + }, + right_parenthesis: 20, }, - ], - commas: [], - }, + }, + ), semicolon: 21, }, ), From ff5f655f8e81a32fa75d9e053b6df6506bc01f60 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Fri, 20 Jan 2023 10:14:51 -0300 Subject: [PATCH 2/2] remove entries and make `ClassishConstantDefinition` self contained --- src/parser/internal/definition/constant.rs | 15 +- src/tree/definition/constant.rs | 37 +- tests/samples/0043/code.ara | 13 +- tests/samples/0043/error.txt | 8 +- tests/samples/0055/tree.txt | 35 +- tests/samples/0057/code.ara | 2 +- tests/samples/0057/tree.txt | 244 ++- tests/samples/0060/tree.txt | 210 +-- tests/samples/0076/tree.txt | 70 +- tests/samples/0085/tree.txt | 1783 ++++++++++---------- tests/samples/0089/tree.txt | 35 +- tests/samples/0093/tree.txt | 35 +- tests/samples/0107/tree.txt | 99 +- 13 files changed, 1210 insertions(+), 1376 deletions(-) diff --git a/src/parser/internal/definition/constant.rs b/src/parser/internal/definition/constant.rs index 7d378d0..c7f9fd1 100644 --- a/src/parser/internal/definition/constant.rs +++ b/src/parser/internal/definition/constant.rs @@ -6,7 +6,6 @@ use crate::parser::result::ParseResult; use crate::parser::state::State; use crate::tree::definition::constant::ClassishConstantDefinition; use crate::tree::definition::constant::ConstantDefinition; -use crate::tree::definition::constant::ConstantDefinitionEntry; use crate::tree::definition::modifier::ModifierGroupDefinition; pub fn constant_definition(state: &mut State) -> ParseResult { @@ -29,17 +28,9 @@ pub fn classish_constant_definition( attributes: state.get_attributes(), modifiers, r#const: utils::skip_keyword(state, TokenKind::Const)?, - entries: utils::at_least_one_comma_separated( - state, - &|state| { - Ok(ConstantDefinitionEntry { - name: identifier::constant_identifier(state)?, - equals: utils::skip(state, TokenKind::Equals)?, - value: expression::create(state)?, - }) - }, - TokenKind::SemiColon, - )?, + name: identifier::constant_identifier(state)?, + equals: utils::skip(state, TokenKind::Equals)?, + value: expression::create(state)?, semicolon: utils::skip_semicolon(state)?, }) } diff --git a/src/tree/definition/constant.rs b/src/tree/definition/constant.rs index 1dde5e6..505f48c 100644 --- a/src/tree/definition/constant.rs +++ b/src/tree/definition/constant.rs @@ -8,17 +8,8 @@ use crate::tree::definition::modifier::ModifierGroupDefinition; use crate::tree::expression::Expression; use crate::tree::identifier::Identifier; use crate::tree::token::Keyword; -use crate::tree::utils::CommaSeparated; use crate::tree::Node; -#[derive(Debug, PartialEq, Eq, Clone, Hash, Deserialize, Serialize, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub struct ConstantDefinitionEntry { - pub name: Identifier, - pub equals: usize, - pub value: Expression, -} - #[derive(Debug, PartialEq, Eq, Clone, Hash, Deserialize, Serialize, JsonSchema)] #[serde(rename_all = "snake_case")] pub struct ConstantDefinition { @@ -37,28 +28,12 @@ pub struct ClassishConstantDefinition { pub attributes: Vec, pub modifiers: ModifierGroupDefinition, pub r#const: Keyword, - pub entries: CommaSeparated, + pub name: Identifier, + pub equals: usize, + pub value: Expression, pub semicolon: usize, } -impl Node for ConstantDefinitionEntry { - fn initial_position(&self) -> usize { - self.name.initial_position() - } - - fn final_position(&self) -> usize { - self.value.final_position() - } - - fn children(&self) -> Vec<&dyn Node> { - vec![&self.name, &self.value] - } - - fn get_description(&self) -> String { - "constant entry definition".to_string() - } -} - impl Node for ConstantDefinition { fn comments(&self) -> Option<&CommentGroup> { Some(&self.comments) @@ -106,10 +81,8 @@ impl Node for ClassishConstantDefinition { children.push(&self.modifiers); children.push(&self.r#const); - - for entry in &self.entries.inner { - children.push(entry); - } + children.push(&self.name); + children.push(&self.value); children } diff --git a/tests/samples/0043/code.ara b/tests/samples/0043/code.ara index 7529e2c..4abeb59 100644 --- a/tests/samples/0043/code.ara +++ b/tests/samples/0043/code.ara @@ -1,2 +1,11 @@ -const A = 3, - B = 3; +interface A extends B, C { + #[R] + const F = 344; + + #[R] + public const O = 344; + + #[R] + #[P] + final public const R = 344, P = 214; +} diff --git a/tests/samples/0043/error.txt b/tests/samples/0043/error.txt index a685690..5d47197 100644 --- a/tests/samples/0043/error.txt +++ b/tests/samples/0043/error.txt @@ -1,8 +1,8 @@ error[P0013]: unexpected token `,`, expected `;` - --> 0043/code.ara:1:14 - | -1 | const A = 3, - | ^ + --> 0043/code.ara:10:31 + | +10 | final public const R = 344, P = 214; + | ^ error: failed to parse "0043/code.ara" due to the above issue(s) = summary: 1 error(s) diff --git a/tests/samples/0055/tree.txt b/tests/samples/0055/tree.txt index e3b319e..bf2c290 100644 --- a/tests/samples/0055/tree.txt +++ b/tests/samples/0055/tree.txt @@ -38,29 +38,22 @@ DefinitionTree { value: "const", position: 16, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 22, - value: "foo", + name: Identifier { + position: 22, + value: "foo", + }, + equals: 26, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 26, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 28, - }, - ), - ), + value: "1", + position: 28, }, - ], - commas: [], - }, + ), + ), semicolon: 29, }, ), diff --git a/tests/samples/0057/code.ara b/tests/samples/0057/code.ara index c37ba09..12fa2fe 100644 --- a/tests/samples/0057/code.ara +++ b/tests/samples/0057/code.ara @@ -9,7 +9,7 @@ interface A extends B, C { #[R] #[P] - final public const R = 344, P = 214; + final public const R = 344; #[R] #[P] diff --git a/tests/samples/0057/tree.txt b/tests/samples/0057/tree.txt index b78c016..b206320 100644 --- a/tests/samples/0057/tree.txt +++ b/tests/samples/0057/tree.txt @@ -129,29 +129,22 @@ DefinitionTree { value: "const", position: 56, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 62, - value: "F", + name: Identifier { + position: 62, + value: "F", + }, + equals: 64, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 64, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "344", - position: 66, - }, - ), - ), + value: "344", + position: 66, }, - ], - commas: [], - }, + ), + ), semicolon: 69, }, ), @@ -193,29 +186,22 @@ DefinitionTree { value: "const", position: 92, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 98, - value: "O", + name: Identifier { + position: 98, + value: "O", + }, + equals: 100, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 100, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "344", - position: 102, - }, - ), - ), + value: "344", + position: 102, }, - ], - commas: [], - }, + ), + ), semicolon: 105, }, ), @@ -279,50 +265,23 @@ DefinitionTree { value: "const", position: 143, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 149, - value: "R", - }, - equals: 151, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "344", - position: 153, - }, - ), - ), - }, - ConstantDefinitionEntry { - name: Identifier { - position: 158, - value: "P", + name: Identifier { + position: 149, + value: "R", + }, + equals: 151, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 160, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "214", - position: 162, - }, - ), - ), + value: "344", + position: 153, }, - ], - commas: [ - 156, - ], - }, - semicolon: 165, + ), + ), + semicolon: 156, }, ), Constant( @@ -332,12 +291,12 @@ DefinitionTree { }, attributes: [ AttributeGroupDefinition { - hash_left_bracket: 172, + hash_left_bracket: 163, members: CommaSeparated { inner: [ AttributeDefinition { name: Identifier { - position: 174, + position: 165, value: "R", }, arguments: None, @@ -345,15 +304,15 @@ DefinitionTree { ], commas: [], }, - right_bracket: 175, + right_bracket: 166, }, AttributeGroupDefinition { - hash_left_bracket: 181, + hash_left_bracket: 172, members: CommaSeparated { inner: [ AttributeDefinition { name: Identifier { - position: 183, + position: 174, value: "P", }, arguments: None, @@ -361,48 +320,41 @@ DefinitionTree { ], commas: [], }, - right_bracket: 184, + right_bracket: 175, }, ], modifiers: ModifierGroupDefinition { - position: 196, + position: 187, modifiers: [ Final( Keyword { value: "final", - position: 190, + position: 181, }, ), ], }, const: Keyword { value: "const", - position: 196, - }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 202, - value: "M", + position: 187, + }, + name: Identifier { + position: 193, + value: "M", + }, + equals: 195, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 204, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "34", - position: 206, - }, - ), - ), + value: "34", + position: 197, }, - ], - commas: [], - }, - semicolon: 208, + ), + ), + semicolon: 199, }, ), Method( @@ -412,12 +364,12 @@ DefinitionTree { }, attributes: [ AttributeGroupDefinition { - hash_left_bracket: 215, + hash_left_bracket: 206, members: CommaSeparated { inner: [ AttributeDefinition { name: Identifier { - position: 217, + position: 208, value: "M", }, arguments: None, @@ -425,26 +377,26 @@ DefinitionTree { ], commas: [], }, - right_bracket: 218, + right_bracket: 209, }, ], modifiers: ModifierGroupDefinition { - position: 231, + position: 222, modifiers: [ Public( Keyword { value: "public", - position: 224, + position: 215, }, ), ], }, function: Keyword { value: "function", - position: 231, + position: 222, }, name: Identifier { - position: 240, + position: 231, value: "bar", }, templates: None, @@ -452,24 +404,24 @@ DefinitionTree { comments: CommentGroup { comments: [], }, - left_parenthesis: 243, + left_parenthesis: 234, parameters: CommaSeparated { inner: [], commas: [], }, - right_parenthesis: 244, + right_parenthesis: 235, }, return_type: FunctionLikeReturnTypeDefinition { - colon: 245, + colon: 236, type_definition: Void( Keyword { value: "void", - position: 247, + position: 238, }, ), }, constraints: None, - semicolon: 251, + semicolon: 242, }, ), Method( @@ -479,12 +431,12 @@ DefinitionTree { }, attributes: [ AttributeGroupDefinition { - hash_left_bracket: 258, + hash_left_bracket: 249, members: CommaSeparated { inner: [ AttributeDefinition { name: Identifier { - position: 260, + position: 251, value: "Q", }, arguments: None, @@ -492,15 +444,15 @@ DefinitionTree { ], commas: [], }, - right_bracket: 261, + right_bracket: 252, }, AttributeGroupDefinition { - hash_left_bracket: 267, + hash_left_bracket: 258, members: CommaSeparated { inner: [ AttributeDefinition { name: Identifier { - position: 269, + position: 260, value: "S", }, arguments: None, @@ -508,32 +460,32 @@ DefinitionTree { ], commas: [], }, - right_bracket: 270, + right_bracket: 261, }, ], modifiers: ModifierGroupDefinition { - position: 290, + position: 281, modifiers: [ Public( Keyword { value: "public", - position: 276, + position: 267, }, ), Static( Keyword { value: "static", - position: 283, + position: 274, }, ), ], }, function: Keyword { value: "function", - position: 290, + position: 281, }, name: Identifier { - position: 299, + position: 290, value: "baz", }, templates: None, @@ -541,31 +493,31 @@ DefinitionTree { comments: CommentGroup { comments: [], }, - left_parenthesis: 302, + left_parenthesis: 293, parameters: CommaSeparated { inner: [], commas: [], }, - right_parenthesis: 303, + right_parenthesis: 294, }, return_type: FunctionLikeReturnTypeDefinition { - colon: 304, + colon: 295, type_definition: Void( Keyword { value: "void", - position: 306, + position: 297, }, ), }, constraints: None, - semicolon: 310, + semicolon: 301, }, ), ], - right_brace: 312, + right_brace: 303, }, }, ), ], - eof: 314, + eof: 305, } \ No newline at end of file diff --git a/tests/samples/0060/tree.txt b/tests/samples/0060/tree.txt index 6cbc46c..98f2b75 100644 --- a/tests/samples/0060/tree.txt +++ b/tests/samples/0060/tree.txt @@ -226,29 +226,22 @@ DefinitionTree { value: "const", position: 171, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 177, - value: "static", + name: Identifier { + position: 177, + value: "static", + }, + equals: 184, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 184, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2413", - position: 186, - }, - ), - ), + value: "2413", + position: 186, }, - ], - commas: [], - }, + ), + ), semicolon: 190, }, ), @@ -266,29 +259,22 @@ DefinitionTree { value: "const", position: 196, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 202, - value: "self", + name: Identifier { + position: 202, + value: "self", + }, + equals: 207, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 207, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2432", - position: 209, - }, - ), - ), + value: "2432", + position: 209, }, - ], - commas: [], - }, + ), + ), semicolon: 213, }, ), @@ -306,29 +292,22 @@ DefinitionTree { value: "const", position: 219, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 225, - value: "return", + name: Identifier { + position: 225, + value: "return", + }, + equals: 232, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 232, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2433", - position: 234, - }, - ), - ), + value: "2433", + position: 234, }, - ], - commas: [], - }, + ), + ), semicolon: 238, }, ), @@ -346,29 +325,22 @@ DefinitionTree { value: "const", position: 244, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 250, - value: "parent", + name: Identifier { + position: 250, + value: "parent", + }, + equals: 257, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 257, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2543", - position: 259, - }, - ), - ), + value: "2543", + position: 259, }, - ], - commas: [], - }, + ), + ), semicolon: 263, }, ), @@ -386,29 +358,22 @@ DefinitionTree { value: "const", position: 269, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 275, - value: "enum", + name: Identifier { + position: 275, + value: "enum", + }, + equals: 280, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 280, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "24133", - position: 282, - }, - ), - ), + value: "24133", + position: 282, }, - ], - commas: [], - }, + ), + ), semicolon: 287, }, ), @@ -426,29 +391,22 @@ DefinitionTree { value: "const", position: 293, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 299, - value: "from", + name: Identifier { + position: 299, + value: "from", + }, + equals: 304, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 304, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "25443", - position: 306, - }, - ), - ), + value: "25443", + position: 306, }, - ], - commas: [], - }, + ), + ), semicolon: 311, }, ), diff --git a/tests/samples/0076/tree.txt b/tests/samples/0076/tree.txt index 9e726eb..9bac23d 100644 --- a/tests/samples/0076/tree.txt +++ b/tests/samples/0076/tree.txt @@ -108,29 +108,22 @@ DefinitionTree { value: "const", position: 79, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 85, - value: "where", + name: Identifier { + position: 85, + value: "where", + }, + equals: 91, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 91, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 93, - }, - ), - ), + value: "1", + position: 93, }, - ], - commas: [], - }, + ), + ), semicolon: 94, }, ), @@ -769,29 +762,22 @@ DefinitionTree { value: "const", position: 492, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 498, - value: "type", + name: Identifier { + position: 498, + value: "type", + }, + equals: 503, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 503, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 505, - }, - ), - ), + value: "1", + position: 505, }, - ], - commas: [], - }, + ), + ), semicolon: 506, }, ), diff --git a/tests/samples/0085/tree.txt b/tests/samples/0085/tree.txt index aa05471..d813056 100644 --- a/tests/samples/0085/tree.txt +++ b/tests/samples/0085/tree.txt @@ -3217,1080 +3217,1073 @@ DefinitionTree { value: "const", position: 1533, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 1539, - value: "FOO", - }, - equals: 1543, - value: Vec( - VecExpression { - comments: CommentGroup { - comments: [], - }, - vec: Keyword { - value: "vec", - position: 1545, - }, - left_bracket: 1548, - elements: CommaSeparated { - inner: [ - VecElementExpression { - value: Identifier( - Identifier { - position: 1558, - value: "Qux", - }, - ), + name: Identifier { + position: 1539, + value: "FOO", + }, + equals: 1543, + value: Vec( + VecExpression { + comments: CommentGroup { + comments: [], + }, + vec: Keyword { + value: "vec", + position: 1545, + }, + left_bracket: 1548, + elements: CommaSeparated { + inner: [ + VecElementExpression { + value: Identifier( + Identifier { + position: 1558, + value: "Qux", + }, + ), + }, + VecElementExpression { + value: ClassOperation( + ConstantFetch { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ClassOperation( - ConstantFetch { + class: Identifier( + Identifier { + position: 1571, + value: "Foo", + }, + ), + double_colon: 1574, + constant: Identifier { + position: 1576, + value: "Bar", + }, + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Addition { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - class: Identifier( - Identifier { - position: 1571, - value: "Foo", - }, - ), - double_colon: 1574, - constant: Identifier { - position: 1576, - value: "Bar", + value: "1", + position: 1589, + }, + ), + ), + plus: 1591, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, + value: "2", + position: 1593, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Subtraction { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ArithmeticOperation( - Addition { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 1589, - }, - ), - ), - plus: 1591, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2", - position: 1593, - }, - ), - ), + value: "3", + position: 1604, }, ), - }, - VecElementExpression { - value: ArithmeticOperation( - Subtraction { + ), + minus: 1606, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "3", - position: 1604, - }, - ), - ), - minus: 1606, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "4", - position: 1608, - }, - ), - ), + value: "4", + position: 1608, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Multiplication { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ArithmeticOperation( - Multiplication { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "5", - position: 1619, - }, - ), - ), - asterisk: 1621, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "6", - position: 1623, - }, - ), - ), + value: "5", + position: 1619, }, ), - }, - VecElementExpression { - value: ArithmeticOperation( - Division { + ), + asterisk: 1621, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "7", - position: 1634, - }, - ), - ), - slash: 1636, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "8", - position: 1638, - }, - ), - ), + value: "6", + position: 1623, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Division { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ArithmeticOperation( - Modulo { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "9", - position: 1649, - }, - ), - ), - percent: 1651, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "10", - position: 1653, - }, - ), - ), + value: "7", + position: 1634, }, ), - }, - VecElementExpression { - value: ArithmeticOperation( - Exponentiation { + ), + slash: 1636, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "11", - position: 1665, - }, - ), - ), - pow: 1668, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "12", - position: 1671, - }, - ), - ), + value: "8", + position: 1638, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Modulo { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: BitwiseOperation( - LeftShift { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "13", - position: 1683, - }, - ), - ), - left_shift: 1686, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "14", - position: 1689, - }, - ), - ), + value: "9", + position: 1649, }, ), - }, - VecElementExpression { - value: BitwiseOperation( - RightShift { + ), + percent: 1651, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "15", - position: 1701, - }, - ), - ), - right_shift: 1704, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "16", - position: 1707, - }, - ), - ), + value: "10", + position: 1653, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Exponentiation { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: BitwiseOperation( - And { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "17", - position: 1719, - }, - ), - ), - and: 1722, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "18", - position: 1724, - }, - ), - ), + value: "11", + position: 1665, }, ), - }, - VecElementExpression { - value: BitwiseOperation( - Or { + ), + pow: 1668, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "19", - position: 1736, - }, - ), - ), - or: 1739, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "20", - position: 1741, - }, - ), - ), + value: "12", + position: 1671, }, ), + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + LeftShift { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: BitwiseOperation( - Xor { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "21", - position: 1753, - }, - ), - ), - xor: 1756, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "22", - position: 1758, - }, - ), - ), + value: "13", + position: 1683, }, ), - }, - VecElementExpression { - value: LogicalOperation( - And { + ), + left_shift: 1686, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "23", - position: 1770, - }, - ), - ), - double_ampersand: 1773, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "24", - position: 1776, - }, - ), - ), + value: "14", + position: 1689, }, ), + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + RightShift { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: LogicalOperation( - Or { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "25", - position: 1788, - }, - ), - ), - double_pipe: 1791, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "26", - position: 1794, - }, - ), - ), + value: "15", + position: 1701, }, ), - }, - VecElementExpression { - value: CoalesceOperation( - Coalesce { + ), + right_shift: 1704, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "27", - position: 1806, - }, - ), - ), - double_question: 1809, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "28", - position: 1812, - }, - ), - ), + value: "16", + position: 1707, }, ), + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + And { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ComparisonOperation( - Spaceship { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "29", - position: 1824, - }, - ), - ), - spaceship: 1827, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "30", - position: 1831, - }, - ), - ), + value: "17", + position: 1719, }, ), - }, - VecElementExpression { - value: ComparisonOperation( - Identical { + ), + and: 1722, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "31", - position: 1843, - }, - ), - ), - triple_equals: 1846, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "32", - position: 1850, - }, - ), - ), + value: "18", + position: 1724, }, ), + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + Or { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ComparisonOperation( - NotIdentical { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "33", - position: 1862, - }, - ), - ), - bang_double_equals: 1865, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "34", - position: 1869, - }, - ), - ), + value: "19", + position: 1736, }, ), - }, - VecElementExpression { - value: ComparisonOperation( - Equal { + ), + or: 1739, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "35", - position: 1881, - }, - ), - ), - double_equals: 1884, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "36", - position: 1887, - }, - ), - ), + value: "20", + position: 1741, }, ), + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + Xor { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ComparisonOperation( - NotEqual { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "37", - position: 1899, - }, - ), - ), - bang_equals: 1902, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "38", - position: 1905, - }, - ), - ), + value: "21", + position: 1753, }, ), - }, - VecElementExpression { - value: ComparisonOperation( - LessThanOrEqual { + ), + xor: 1756, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "39", - position: 1917, - }, - ), - ), - less_than_equals: 1920, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "40", - position: 1923, - }, - ), - ), + value: "22", + position: 1758, }, ), + ), + }, + ), + }, + VecElementExpression { + value: LogicalOperation( + And { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ComparisonOperation( - GreaterThanOrEqual { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "41", - position: 1935, - }, - ), - ), - greater_than_equals: 1938, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "42", - position: 1941, - }, - ), - ), + value: "23", + position: 1770, }, ), - }, - VecElementExpression { - value: ComparisonOperation( - LessThan { + ), + double_ampersand: 1773, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "43", - position: 1953, - }, - ), - ), - less_than: 1956, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "44", - position: 1958, - }, - ), - ), + value: "24", + position: 1776, }, ), + ), + }, + ), + }, + VecElementExpression { + value: LogicalOperation( + Or { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ComparisonOperation( - GreaterThan { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "45", - position: 1970, - }, - ), - ), - greater_than: 1973, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "46", - position: 1975, - }, - ), - ), + value: "25", + position: 1788, }, ), - }, - VecElementExpression { - value: StringOperation( - Concat { + ), + double_pipe: 1791, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""a"", - position: 1987, - }, - ), - ), - dot: 1991, - right: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""b"", - position: 1993, - }, - ), - ), + value: "26", + position: 1794, }, ), + ), + }, + ), + }, + VecElementExpression { + value: CoalesceOperation( + Coalesce { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: LogicalOperation( - Not { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - bang: 2006, - right: Identifier( - Identifier { - position: 2007, - value: "Biz", - }, - ), + value: "27", + position: 1806, }, ), - }, - VecElementExpression { - value: BitwiseOperation( - Not { + ), + double_question: 1809, + right: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - not: 2020, - right: Identifier( - Identifier { - position: 2021, - value: "Baz", - }, - ), + value: "28", + position: 1812, }, ), - }, - VecElementExpression { - value: ArithmeticOperation( - Positive { - comments: CommentGroup { + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + Spaceship { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { comments: [], }, - plus: 2034, - right: Identifier( - Identifier { - position: 2035, - value: "Qux", - }, - ), + value: "29", + position: 1824, + }, + ), + ), + spaceship: 1827, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "30", + position: 1831, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + Identical { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: ArithmeticOperation( - Negative { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - minus: 2048, - right: Identifier( - Identifier { - position: 2049, - value: "Foo", - }, - ), + value: "31", + position: 1843, + }, + ), + ), + triple_equals: 1846, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "32", + position: 1850, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + NotIdentical { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: Tuple( - TupleExpression { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - left_parenthesis: 2062, - elements: CommaSeparated { - inner: [ - Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 2063, - }, - ), - ), - Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2", - position: 2066, - }, - ), - ), - Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "3", - position: 2069, - }, - ), - ), - ], - commas: [ - 2064, - 2067, - ], + value: "33", + position: 1862, + }, + ), + ), + bang_double_equals: 1865, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - right_parenthesis: 2070, + value: "34", + position: 1869, }, ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + Equal { + comments: CommentGroup { + comments: [], }, - VecElementExpression { - value: Dict( - DictExpression { + left: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - dict: Keyword { - value: "dict", - position: 2081, + value: "35", + position: 1881, + }, + ), + ), + double_equals: 1884, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - left_bracket: 2085, - elements: CommaSeparated { - inner: [ - DictElementExpression { - key: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 2099, - }, - ), - ), - double_arrow: 2101, - value: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""a"", - position: 2104, - }, - ), - ), + value: "36", + position: 1887, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + NotEqual { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "37", + position: 1899, + }, + ), + ), + bang_equals: 1902, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "38", + position: 1905, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + LessThanOrEqual { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "39", + position: 1917, + }, + ), + ), + less_than_equals: 1920, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "40", + position: 1923, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + GreaterThanOrEqual { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "41", + position: 1935, + }, + ), + ), + greater_than_equals: 1938, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "42", + position: 1941, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + LessThan { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "43", + position: 1953, + }, + ), + ), + less_than: 1956, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "44", + position: 1958, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: ComparisonOperation( + GreaterThan { + comments: CommentGroup { + comments: [], + }, + left: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "45", + position: 1970, + }, + ), + ), + greater_than: 1973, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "46", + position: 1975, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: StringOperation( + Concat { + comments: CommentGroup { + comments: [], + }, + left: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""a"", + position: 1987, + }, + ), + ), + dot: 1991, + right: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""b"", + position: 1993, + }, + ), + ), + }, + ), + }, + VecElementExpression { + value: LogicalOperation( + Not { + comments: CommentGroup { + comments: [], + }, + bang: 2006, + right: Identifier( + Identifier { + position: 2007, + value: "Biz", + }, + ), + }, + ), + }, + VecElementExpression { + value: BitwiseOperation( + Not { + comments: CommentGroup { + comments: [], + }, + not: 2020, + right: Identifier( + Identifier { + position: 2021, + value: "Baz", + }, + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Positive { + comments: CommentGroup { + comments: [], + }, + plus: 2034, + right: Identifier( + Identifier { + position: 2035, + value: "Qux", + }, + ), + }, + ), + }, + VecElementExpression { + value: ArithmeticOperation( + Negative { + comments: CommentGroup { + comments: [], + }, + minus: 2048, + right: Identifier( + Identifier { + position: 2049, + value: "Foo", + }, + ), + }, + ), + }, + VecElementExpression { + value: Tuple( + TupleExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 2062, + elements: CommaSeparated { + inner: [ + Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - DictElementExpression { - key: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2", - position: 2121, - }, - ), - ), - double_arrow: 2123, - value: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""b"", - position: 2126, - }, - ), - ), + value: "1", + position: 2063, + }, + ), + ), + Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - DictElementExpression { - key: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "3", - position: 2143, - }, - ), - ), - double_arrow: 2145, - value: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], - }, - value: ""c"", - position: 2148, - }, - ), - ), + value: "2", + position: 2066, + }, + ), + ), + Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - ], - commas: [ - 2107, - 2129, - 2151, - ], - }, - right_bracket: 2161, + value: "3", + position: 2069, + }, + ), + ), + ], + commas: [ + 2064, + 2067, + ], + }, + right_parenthesis: 2070, + }, + ), + }, + VecElementExpression { + value: Dict( + DictExpression { + comments: CommentGroup { + comments: [], + }, + dict: Keyword { + value: "dict", + position: 2081, + }, + left_bracket: 2085, + elements: CommaSeparated { + inner: [ + DictElementExpression { + key: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "1", + position: 2099, + }, + ), + ), + double_arrow: 2101, + value: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""a"", + position: 2104, + }, + ), + ), }, - ), + DictElementExpression { + key: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "2", + position: 2121, + }, + ), + ), + double_arrow: 2123, + value: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""b"", + position: 2126, + }, + ), + ), + }, + DictElementExpression { + key: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "3", + position: 2143, + }, + ), + ), + double_arrow: 2145, + value: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: ""c"", + position: 2148, + }, + ), + ), + }, + ], + commas: [ + 2107, + 2129, + 2151, + ], }, - ], - commas: [ - 1561, - 1579, - 1594, - 1609, - 1624, - 1639, - 1655, - 1673, - 1691, - 1709, - 1726, - 1743, - 1760, - 1778, - 1796, - 1814, - 1833, - 1852, - 1871, - 1889, - 1907, - 1925, - 1943, - 1960, - 1977, - 1996, - 2010, - 2024, - 2038, - 2052, - 2071, - 2162, - ], - }, - right_bracket: 2168, + right_bracket: 2161, + }, + ), }, - ), + ], + commas: [ + 1561, + 1579, + 1594, + 1609, + 1624, + 1639, + 1655, + 1673, + 1691, + 1709, + 1726, + 1743, + 1760, + 1778, + 1796, + 1814, + 1833, + 1852, + 1871, + 1889, + 1907, + 1925, + 1943, + 1960, + 1977, + 1996, + 2010, + 2024, + 2038, + 2052, + 2071, + 2162, + ], }, - ], - commas: [], - }, + right_bracket: 2168, + }, + ), semicolon: 2169, }, ), diff --git a/tests/samples/0089/tree.txt b/tests/samples/0089/tree.txt index e6ad6c7..b693b7a 100644 --- a/tests/samples/0089/tree.txt +++ b/tests/samples/0089/tree.txt @@ -108,29 +108,22 @@ DefinitionTree { value: "const", position: 67, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 73, - value: "in", + name: Identifier { + position: 73, + value: "in", + }, + equals: 76, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 76, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 78, - }, - ), - ), + value: "1", + position: 78, }, - ], - commas: [], - }, + ), + ), semicolon: 79, }, ), diff --git a/tests/samples/0093/tree.txt b/tests/samples/0093/tree.txt index 42a71de..e0e60a9 100644 --- a/tests/samples/0093/tree.txt +++ b/tests/samples/0093/tree.txt @@ -108,29 +108,22 @@ DefinitionTree { value: "const", position: 79, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 85, - value: "using", + name: Identifier { + position: 85, + value: "using", + }, + equals: 91, + value: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], }, - equals: 91, - value: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 93, - }, - ), - ), + value: "1", + position: 93, }, - ], - commas: [], - }, + ), + ), semicolon: 94, }, ), diff --git a/tests/samples/0107/tree.txt b/tests/samples/0107/tree.txt index 26aa87e..9d4cd8f 100644 --- a/tests/samples/0107/tree.txt +++ b/tests/samples/0107/tree.txt @@ -84,65 +84,58 @@ DefinitionTree { value: "CONST", position: 40, }, - entries: CommaSeparated { - inner: [ - ConstantDefinitionEntry { - name: Identifier { - position: 46, - value: "FOO", + name: Identifier { + position: 46, + value: "FOO", + }, + equals: 50, + value: ArrowFunction( + ArrowFunctionExpression { + comments: CommentGroup { + comments: [], + }, + attributes: [], + static: None, + fn: Keyword { + value: "fn", + position: 52, + }, + parameters: FunctionLikeParameterListDefinition { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 54, + parameters: CommaSeparated { + inner: [], + commas: [], }, - equals: 50, - value: ArrowFunction( - ArrowFunctionExpression { + right_parenthesis: 55, + }, + return_type: FunctionLikeReturnTypeDefinition { + colon: 56, + type_definition: SignedInteger( + Default( + Keyword { + value: "int", + position: 58, + }, + ), + ), + }, + double_arrow: 62, + body: Literal( + Integer( + LiteralInteger { comments: CommentGroup { comments: [], }, - attributes: [], - static: None, - fn: Keyword { - value: "fn", - position: 52, - }, - parameters: FunctionLikeParameterListDefinition { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 54, - parameters: CommaSeparated { - inner: [], - commas: [], - }, - right_parenthesis: 55, - }, - return_type: FunctionLikeReturnTypeDefinition { - colon: 56, - type_definition: SignedInteger( - Default( - Keyword { - value: "int", - position: 58, - }, - ), - ), - }, - double_arrow: 62, - body: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 65, - }, - ), - ), + value: "1", + position: 65, }, ), - }, - ], - commas: [], - }, + ), + }, + ), semicolon: 66, }, ),