diff --git a/src/parser/internal/statement/control_flow.rs b/src/parser/internal/statement/control_flow.rs index 1f85cb4..0cf6e02 100644 --- a/src/parser/internal/statement/control_flow.rs +++ b/src/parser/internal/statement/control_flow.rs @@ -17,8 +17,8 @@ use crate::tree::utils::CommaSeparated; pub fn if_statement(state: &mut State) -> ParseResult { let comments = state.iterator.comments(); let r#if = utils::skip_keyword(state, TokenKind::If)?; - let condition = expression::create(state)?; + let conditions = utils::comma_separated(state, &expression::create, TokenKind::LeftBrace)?; let statement = block::block_statement(state)?; let mut elseifs: Vec = vec![]; @@ -51,7 +51,7 @@ pub fn if_statement(state: &mut State) -> ParseResult { Ok(IfStatement { comments, r#if, - condition, + conditions, block: statement, elseifs, r#else, diff --git a/src/parser/internal/statement/loop.rs b/src/parser/internal/statement/loop.rs index ac06c90..44d720e 100644 --- a/src/parser/internal/statement/loop.rs +++ b/src/parser/internal/statement/loop.rs @@ -232,7 +232,7 @@ pub fn do_while_statement(state: &mut State) -> ParseResult { r#do: utils::skip_keyword(state, TokenKind::Do)?, block: block::block_statement(state)?, r#while: utils::skip_keyword(state, TokenKind::While)?, - condition: expression::create(state)?, + conditions: utils::comma_separated(state, &expression::create, TokenKind::SemiColon)?, semicolon: utils::skip_semicolon(state)?, }) } @@ -241,7 +241,7 @@ pub fn while_statement(state: &mut State) -> ParseResult { Ok(WhileStatement { comments: state.iterator.comments(), r#while: utils::skip_keyword(state, TokenKind::While)?, - condition: expression::create(state)?, + conditions: utils::comma_separated(state, &expression::create, TokenKind::LeftBrace)?, block: block::block_statement(state)?, }) } diff --git a/src/tree/statement/control_flow.rs b/src/tree/statement/control_flow.rs index fa3b067..922ad81 100644 --- a/src/tree/statement/control_flow.rs +++ b/src/tree/statement/control_flow.rs @@ -15,7 +15,7 @@ use crate::tree::Node; pub struct IfStatement { pub comments: CommentGroup, pub r#if: Keyword, - pub condition: Expression, + pub conditions: CommaSeparated, pub block: BlockStatement, pub elseifs: Vec, pub r#else: Option, @@ -86,7 +86,12 @@ impl Node for IfStatement { } fn children(&self) -> Vec<&dyn Node> { - let mut children: Vec<&dyn Node> = vec![&self.r#if, &self.condition, &self.block]; + let mut children: Vec<&dyn Node> = vec![&self.r#if, &self.block]; + + for condition in &self.conditions.inner { + children.push(condition); + } + for elseif in &self.elseifs { children.push(elseif); } diff --git a/src/tree/statement/loop.rs b/src/tree/statement/loop.rs index 8ddcace..3e7b952 100644 --- a/src/tree/statement/loop.rs +++ b/src/tree/statement/loop.rs @@ -92,7 +92,7 @@ pub struct DoWhileStatement { pub r#do: Keyword, pub block: BlockStatement, pub r#while: Keyword, - pub condition: Expression, + pub conditions: CommaSeparated, pub semicolon: usize, } @@ -101,7 +101,7 @@ pub struct DoWhileStatement { pub struct WhileStatement { pub comments: CommentGroup, pub r#while: Keyword, - pub condition: Expression, + pub conditions: CommaSeparated, pub block: BlockStatement, } @@ -372,7 +372,13 @@ impl Node for DoWhileStatement { } fn children(&self) -> Vec<&dyn Node> { - vec![&self.r#do, &self.block, &self.r#while, &self.condition] + let mut children: Vec<&dyn Node> = vec![&self.r#do, &self.block, &self.r#while]; + + for condition in &self.conditions.inner { + children.push(condition); + } + + children } fn get_description(&self) -> String { @@ -394,7 +400,13 @@ impl Node for WhileStatement { } fn children(&self) -> Vec<&dyn Node> { - vec![&self.r#while, &self.condition, &self.block] + let mut children: Vec<&dyn Node> = vec![&self.r#while, &self.block]; + + for condition in &self.conditions.inner { + children.push(condition); + } + + children } fn get_description(&self) -> String { diff --git a/tests/samples/0015/tree.txt b/tests/samples/0015/tree.txt index 687f57b..68dde8b 100644 --- a/tests/samples/0015/tree.txt +++ b/tests/samples/0015/tree.txt @@ -73,40 +73,45 @@ DefinitionTree { value: "if", position: 32, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 35, - expression: ComparisonOperation( - LessThan { + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { comments: CommentGroup { comments: [], }, - left: Variable( - Variable { - position: 36, - name: "$n", - }, - ), - less_than: 39, - right: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "2", - position: 41, + left_parenthesis: 35, + expression: ComparisonOperation( + LessThan { + comments: CommentGroup { + comments: [], }, - ), + left: Variable( + Variable { + position: 36, + name: "$n", + }, + ), + less_than: 39, + right: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "2", + position: 41, + }, + ), + ), + }, ), + right_parenthesis: 42, }, ), - right_parenthesis: 42, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0016/tree.txt b/tests/samples/0016/tree.txt index fdd253b..a3f0a6e 100644 --- a/tests/samples/0016/tree.txt +++ b/tests/samples/0016/tree.txt @@ -50,21 +50,26 @@ DefinitionTree { value: "if", position: 28, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 30, - expression: Variable( - Variable { - position: 31, - name: "$foo", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 30, + expression: Variable( + Variable { + position: 31, + name: "$foo", + }, + ), + right_parenthesis: 35, }, ), - right_parenthesis: 35, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0017/tree.txt b/tests/samples/0017/tree.txt index 0b1a54c..6d4b35a 100644 --- a/tests/samples/0017/tree.txt +++ b/tests/samples/0017/tree.txt @@ -50,21 +50,26 @@ DefinitionTree { value: "if", position: 28, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 30, - expression: Variable( - Variable { - position: 31, - name: "$foo", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 30, + expression: Variable( + Variable { + position: 31, + name: "$foo", + }, + ), + right_parenthesis: 35, }, ), - right_parenthesis: 35, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0026/tree.txt b/tests/samples/0026/tree.txt index 5b2ba86..0d5f67b 100644 --- a/tests/samples/0026/tree.txt +++ b/tests/samples/0026/tree.txt @@ -62,21 +62,26 @@ DefinitionTree { value: "while", position: 36, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 42, - expression: Variable( - Variable { - position: 43, - name: "$a", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 42, + expression: Variable( + Variable { + position: 43, + name: "$a", + }, + ), + right_parenthesis: 45, }, ), - right_parenthesis: 45, - }, - ), + ], + commas: [], + }, semicolon: 46, }, ), diff --git a/tests/samples/0054/tree.txt b/tests/samples/0054/tree.txt index 34c8b0e..79e798a 100644 --- a/tests/samples/0054/tree.txt +++ b/tests/samples/0054/tree.txt @@ -50,21 +50,26 @@ DefinitionTree { value: "if", position: 28, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 31, - expression: Variable( - Variable { - position: 32, - name: "$foo", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 31, + expression: Variable( + Variable { + position: 32, + name: "$foo", + }, + ), + right_parenthesis: 36, }, ), - right_parenthesis: 36, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -92,21 +97,26 @@ DefinitionTree { value: "if", position: 52, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 55, - expression: Variable( - Variable { - position: 56, - name: "$bar", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 55, + expression: Variable( + Variable { + position: 56, + name: "$bar", + }, + ), + right_parenthesis: 60, }, ), - right_parenthesis: 60, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0070/tree.txt b/tests/samples/0070/tree.txt index 6781a51..4053d63 100644 --- a/tests/samples/0070/tree.txt +++ b/tests/samples/0070/tree.txt @@ -50,12 +50,17 @@ DefinitionTree { value: "if", position: 27, }, - condition: Variable( - Variable { - position: 30, - name: "$a", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 30, + name: "$a", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -77,21 +82,26 @@ DefinitionTree { value: "if", position: 42, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 45, - expression: Variable( - Variable { - position: 46, - name: "$a", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 45, + expression: Variable( + Variable { + position: 46, + name: "$a", + }, + ), + right_parenthesis: 48, }, ), - right_parenthesis: 48, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -113,12 +123,17 @@ DefinitionTree { value: "if", position: 58, }, - condition: Variable( - Variable { - position: 61, - name: "$a", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 61, + name: "$a", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -170,12 +185,17 @@ DefinitionTree { value: "if", position: 91, }, - condition: Variable( - Variable { - position: 94, - name: "$c", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 94, + name: "$c", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -221,21 +241,26 @@ DefinitionTree { value: "if", position: 114, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 117, - expression: Variable( - Variable { - position: 118, - name: "$a", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 117, + expression: Variable( + Variable { + position: 118, + name: "$a", + }, + ), + right_parenthesis: 120, }, ), - right_parenthesis: 120, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -296,21 +321,26 @@ DefinitionTree { value: "if", position: 147, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 150, - expression: Variable( - Variable { - position: 151, - name: "$c", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 150, + expression: Variable( + Variable { + position: 151, + name: "$c", + }, + ), + right_parenthesis: 153, }, ), - right_parenthesis: 153, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -356,12 +386,17 @@ DefinitionTree { value: "if", position: 171, }, - condition: Variable( - Variable { - position: 174, - name: "$a", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 174, + name: "$a", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -403,21 +438,26 @@ DefinitionTree { value: "if", position: 194, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 197, - expression: Variable( - Variable { - position: 198, - name: "$a", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 197, + expression: Variable( + Variable { + position: 198, + name: "$a", + }, + ), + right_parenthesis: 200, }, ), - right_parenthesis: 200, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -459,12 +499,17 @@ DefinitionTree { value: "while", position: 218, }, - condition: Variable( - Variable { - position: 224, - name: "$a", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 224, + name: "$a", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -484,21 +529,26 @@ DefinitionTree { value: "while", position: 236, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 242, - expression: Variable( - Variable { - position: 243, - name: "$a", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 242, + expression: Variable( + Variable { + position: 243, + name: "$a", + }, + ), + right_parenthesis: 245, }, ), - right_parenthesis: 245, - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -530,12 +580,17 @@ DefinitionTree { value: "while", position: 261, }, - condition: Variable( - Variable { - position: 267, - name: "$a", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 267, + name: "$a", + }, + ), + ], + commas: [], + }, semicolon: 269, }, ), @@ -560,21 +615,26 @@ DefinitionTree { value: "while", position: 281, }, - condition: Parenthesized( - ParenthesizedExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 287, - expression: Variable( - Variable { - position: 288, - name: "$a", + conditions: CommaSeparated { + inner: [ + Parenthesized( + ParenthesizedExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 287, + expression: Variable( + Variable { + position: 288, + name: "$a", + }, + ), + right_parenthesis: 290, }, ), - right_parenthesis: 290, - }, - ), + ], + commas: [], + }, semicolon: 291, }, ), diff --git a/tests/samples/0071/tree.txt b/tests/samples/0071/tree.txt index 6d2078a..0b50090 100644 --- a/tests/samples/0071/tree.txt +++ b/tests/samples/0071/tree.txt @@ -531,12 +531,17 @@ DefinitionTree { value: "if", position: 268, }, - condition: Variable( - Variable { - position: 271, - name: "$a", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 271, + name: "$a", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -1452,12 +1457,17 @@ DefinitionTree { value: "if", position: 670, }, - condition: Variable( - Variable { - position: 673, - name: "$a", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 673, + name: "$a", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -1560,12 +1570,17 @@ DefinitionTree { value: "if", position: 718, }, - condition: Variable( - Variable { - position: 721, - name: "$b", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 721, + name: "$b", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0073/tree.txt b/tests/samples/0073/tree.txt index f1a47dc..b83eb16 100644 --- a/tests/samples/0073/tree.txt +++ b/tests/samples/0073/tree.txt @@ -334,43 +334,48 @@ DefinitionTree { value: "if", position: 165, }, - condition: FunctionOperation( - Call { - comments: CommentGroup { - comments: [], - }, - function: Variable( - Variable { - position: 168, - name: "$predicate", - }, - ), - generics: None, - arguments: ArgumentListExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 178, - arguments: CommaSeparated { - inner: [ - Value { - comments: CommentGroup { - comments: [], - }, - value: Variable( - Variable { - position: 179, - name: "$item", + conditions: CommaSeparated { + inner: [ + FunctionOperation( + Call { + comments: CommentGroup { + comments: [], + }, + function: Variable( + Variable { + position: 168, + name: "$predicate", + }, + ), + generics: None, + arguments: ArgumentListExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 178, + arguments: CommaSeparated { + inner: [ + Value { + comments: CommentGroup { + comments: [], + }, + value: Variable( + Variable { + position: 179, + name: "$item", + }, + ), }, - ), + ], + commas: [], }, - ], - commas: [], + right_parenthesis: 184, + }, }, - right_parenthesis: 184, - }, - }, - ), + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -909,75 +914,80 @@ DefinitionTree { value: "if", position: 431, }, - condition: TypeOperation( - Is { - comments: CommentGroup { - comments: [], - }, - left: Variable( - Variable { - position: 434, - name: "$mapper", - }, - ), - is: Keyword { - value: "is", - position: 442, - }, - right: Identifier( - TemplatedIdentifier { - name: Identifier { - position: 445, - value: "SomeOtherType", + conditions: CommaSeparated { + inner: [ + TypeOperation( + Is { + comments: CommentGroup { + comments: [], }, - templates: Some( - TypeTemplateGroupDefinition { - comments: CommentGroup { - comments: [], - }, - less_than: 458, - members: CommaSeparated { - inner: [ - Identifier( - TemplatedIdentifier { - name: Identifier { - position: 459, - value: "_", - }, - templates: None, - }, - ), - Identifier( - TemplatedIdentifier { - name: Identifier { - position: 462, - value: "_", - }, - templates: None, - }, - ), - Identifier( - TemplatedIdentifier { - name: Identifier { - position: 465, - value: "_", - }, - templates: None, - }, - ), - ], - commas: [ - 460, - 463, - ], + left: Variable( + Variable { + position: 434, + name: "$mapper", + }, + ), + is: Keyword { + value: "is", + position: 442, + }, + right: Identifier( + TemplatedIdentifier { + name: Identifier { + position: 445, + value: "SomeOtherType", }, - greater_than: 466, + templates: Some( + TypeTemplateGroupDefinition { + comments: CommentGroup { + comments: [], + }, + less_than: 458, + members: CommaSeparated { + inner: [ + Identifier( + TemplatedIdentifier { + name: Identifier { + position: 459, + value: "_", + }, + templates: None, + }, + ), + Identifier( + TemplatedIdentifier { + name: Identifier { + position: 462, + value: "_", + }, + templates: None, + }, + ), + Identifier( + TemplatedIdentifier { + name: Identifier { + position: 465, + value: "_", + }, + templates: None, + }, + ), + ], + commas: [ + 460, + 463, + ], + }, + greater_than: 466, + }, + ), }, ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0074/tree.txt b/tests/samples/0074/tree.txt index c008e01..4f34b1c 100644 --- a/tests/samples/0074/tree.txt +++ b/tests/samples/0074/tree.txt @@ -121,29 +121,34 @@ DefinitionTree { value: "if", position: 100, }, - condition: TypeOperation( - Is { - comments: CommentGroup { - comments: [], - }, - left: Variable( - Variable { - position: 103, - name: "$value", - }, - ), - is: Keyword { - value: "is", - position: 110, - }, - right: String( - Keyword { - value: "string", - position: 113, + conditions: CommaSeparated { + inner: [ + TypeOperation( + Is { + comments: CommentGroup { + comments: [], + }, + left: Variable( + Variable { + position: 103, + name: "$value", + }, + ), + is: Keyword { + value: "is", + position: 110, + }, + right: String( + Keyword { + value: "string", + position: 113, + }, + ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -185,64 +190,69 @@ DefinitionTree { value: "if", position: 148, }, - condition: LogicalOperation( - Or { - comments: CommentGroup { - comments: [], - }, - left: TypeOperation( - Is { + conditions: CommaSeparated { + inner: [ + LogicalOperation( + Or { comments: CommentGroup { comments: [], }, - left: Variable( - Variable { - position: 151, - name: "$value", - }, - ), - is: Keyword { - value: "is", - position: 158, - }, - right: SignedInteger( - Default( - Keyword { - value: "int", - position: 161, + left: TypeOperation( + Is { + comments: CommentGroup { + comments: [], }, - ), - ), - }, - ), - double_pipe: 165, - right: TypeOperation( - Is { - comments: CommentGroup { - comments: [], - }, - left: Variable( - Variable { - position: 168, - name: "$value", + left: Variable( + Variable { + position: 151, + name: "$value", + }, + ), + is: Keyword { + value: "is", + position: 158, + }, + right: SignedInteger( + Default( + Keyword { + value: "int", + position: 161, + }, + ), + ), }, ), - is: Keyword { - value: "is", - position: 175, - }, - right: FloatingPoint( - Default( - Keyword { - value: "float", - position: 178, + double_pipe: 165, + right: TypeOperation( + Is { + comments: CommentGroup { + comments: [], }, - ), + left: Variable( + Variable { + position: 168, + name: "$value", + }, + ), + is: Keyword { + value: "is", + position: 175, + }, + right: FloatingPoint( + Default( + Keyword { + value: "float", + position: 178, + }, + ), + ), + }, ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -258,31 +268,36 @@ DefinitionTree { value: "if", position: 194, }, - condition: TypeOperation( - Is { - comments: CommentGroup { - comments: [], - }, - left: Variable( - Variable { - position: 197, - name: "$value", - }, - ), - is: Keyword { - value: "is", - position: 204, - }, - right: SignedInteger( - Default( - Keyword { - value: "int", - position: 207, + conditions: CommaSeparated { + inner: [ + TypeOperation( + Is { + comments: CommentGroup { + comments: [], }, - ), + left: Variable( + Variable { + position: 197, + name: "$value", + }, + ), + is: Keyword { + value: "is", + position: 204, + }, + right: SignedInteger( + Default( + Keyword { + value: "int", + position: 207, + }, + ), + ), + }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0075/tree.txt b/tests/samples/0075/tree.txt index a839a6c..c35c57d 100644 --- a/tests/samples/0075/tree.txt +++ b/tests/samples/0075/tree.txt @@ -457,43 +457,48 @@ DefinitionTree { value: "if", position: 289, }, - condition: FunctionOperation( - Call { - comments: CommentGroup { - comments: [], - }, - function: Variable( - Variable { - position: 292, - name: "$func", - }, - ), - generics: None, - arguments: ArgumentListExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 297, - arguments: CommaSeparated { - inner: [ - Value { - comments: CommentGroup { - comments: [], - }, - value: Variable( - Variable { - position: 298, - name: "$item", + conditions: CommaSeparated { + inner: [ + FunctionOperation( + Call { + comments: CommentGroup { + comments: [], + }, + function: Variable( + Variable { + position: 292, + name: "$func", + }, + ), + generics: None, + arguments: ArgumentListExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 297, + arguments: CommaSeparated { + inner: [ + Value { + comments: CommentGroup { + comments: [], + }, + value: Variable( + Variable { + position: 298, + name: "$item", + }, + ), }, - ), + ], + commas: [], }, - ], - commas: [], + right_parenthesis: 303, + }, }, - right_parenthesis: 303, - }, - }, - ), + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0078/tree.txt b/tests/samples/0078/tree.txt index e7b7f79..7d11bf2 100644 --- a/tests/samples/0078/tree.txt +++ b/tests/samples/0078/tree.txt @@ -589,43 +589,48 @@ DefinitionTree { value: "if", position: 281, }, - condition: FunctionOperation( - Call { - comments: CommentGroup { - comments: [], - }, - function: Variable( - Variable { - position: 284, - name: "$filter", - }, - ), - generics: None, - arguments: ArgumentListExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 291, - arguments: CommaSeparated { - inner: [ - Value { - comments: CommentGroup { - comments: [], - }, - value: Variable( - Variable { - position: 292, - name: "$item", + conditions: CommaSeparated { + inner: [ + FunctionOperation( + Call { + comments: CommentGroup { + comments: [], + }, + function: Variable( + Variable { + position: 284, + name: "$filter", + }, + ), + generics: None, + arguments: ArgumentListExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 291, + arguments: CommaSeparated { + inner: [ + Value { + comments: CommentGroup { + comments: [], + }, + value: Variable( + Variable { + position: 292, + name: "$item", + }, + ), }, - ), + ], + commas: [], }, - ], - commas: [], + right_parenthesis: 297, + }, }, - right_parenthesis: 297, - }, - }, - ), + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -1404,43 +1409,48 @@ DefinitionTree { value: "if", position: 730, }, - condition: FunctionOperation( - Call { - comments: CommentGroup { - comments: [], - }, - function: Variable( - Variable { - position: 733, - name: "$filter", - }, - ), - generics: None, - arguments: ArgumentListExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 740, - arguments: CommaSeparated { - inner: [ - Value { - comments: CommentGroup { - comments: [], - }, - value: Variable( - Variable { - position: 741, - name: "$item", + conditions: CommaSeparated { + inner: [ + FunctionOperation( + Call { + comments: CommentGroup { + comments: [], + }, + function: Variable( + Variable { + position: 733, + name: "$filter", + }, + ), + generics: None, + arguments: ArgumentListExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 740, + arguments: CommaSeparated { + inner: [ + Value { + comments: CommentGroup { + comments: [], + }, + value: Variable( + Variable { + position: 741, + name: "$item", + }, + ), }, - ), + ], + commas: [], }, - ], - commas: [], + right_parenthesis: 746, + }, }, - right_parenthesis: 746, - }, - }, - ), + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -2744,43 +2754,48 @@ DefinitionTree { value: "if", position: 1507, }, - condition: FunctionOperation( - Call { - comments: CommentGroup { - comments: [], - }, - function: Variable( - Variable { - position: 1510, - name: "$filter", - }, - ), - generics: None, - arguments: ArgumentListExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 1517, - arguments: CommaSeparated { - inner: [ - Value { - comments: CommentGroup { - comments: [], - }, - value: Variable( - Variable { - position: 1518, - name: "$item", + conditions: CommaSeparated { + inner: [ + FunctionOperation( + Call { + comments: CommentGroup { + comments: [], + }, + function: Variable( + Variable { + position: 1510, + name: "$filter", + }, + ), + generics: None, + arguments: ArgumentListExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 1517, + arguments: CommaSeparated { + inner: [ + Value { + comments: CommentGroup { + comments: [], + }, + value: Variable( + Variable { + position: 1518, + name: "$item", + }, + ), }, - ), + ], + commas: [], }, - ], - commas: [], + right_parenthesis: 1523, + }, }, - right_parenthesis: 1523, - }, - }, - ), + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0082/tree.txt b/tests/samples/0082/tree.txt index b15130a..255f1fc 100644 --- a/tests/samples/0082/tree.txt +++ b/tests/samples/0082/tree.txt @@ -457,43 +457,48 @@ DefinitionTree { value: "if", position: 289, }, - condition: FunctionOperation( - Call { - comments: CommentGroup { - comments: [], - }, - function: Variable( - Variable { - position: 292, - name: "$func", - }, - ), - generics: None, - arguments: ArgumentListExpression { - comments: CommentGroup { - comments: [], - }, - left_parenthesis: 297, - arguments: CommaSeparated { - inner: [ - Value { - comments: CommentGroup { - comments: [], - }, - value: Variable( - Variable { - position: 298, - name: "$item", + conditions: CommaSeparated { + inner: [ + FunctionOperation( + Call { + comments: CommentGroup { + comments: [], + }, + function: Variable( + Variable { + position: 292, + name: "$func", + }, + ), + generics: None, + arguments: ArgumentListExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 297, + arguments: CommaSeparated { + inner: [ + Value { + comments: CommentGroup { + comments: [], + }, + value: Variable( + Variable { + position: 298, + name: "$item", + }, + ), }, - ), + ], + commas: [], }, - ], - commas: [], + right_parenthesis: 303, + }, }, - right_parenthesis: 303, - }, - }, - ), + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0090/tree.txt b/tests/samples/0090/tree.txt index 5e0e7cc..cbe2e36 100644 --- a/tests/samples/0090/tree.txt +++ b/tests/samples/0090/tree.txt @@ -50,29 +50,34 @@ DefinitionTree { value: "if", position: 27, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 30, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 33, - }, - array: Variable( - Variable { - position: 36, - name: "$b", + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { + comments: CommentGroup { + comments: [], + }, + item: Variable( + Variable { + position: 30, + name: "$a", + }, + ), + in: Keyword { + value: "in", + position: 33, + }, + array: Variable( + Variable { + position: 36, + name: "$b", + }, + ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -94,51 +99,56 @@ DefinitionTree { value: "if", position: 53, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 56, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 59, - }, - array: Tuple( - TupleExpression { + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { comments: CommentGroup { comments: [], }, - left_parenthesis: 62, - elements: CommaSeparated { - inner: [ - Variable( - Variable { - position: 63, - name: "$b", - }, - ), - Variable( - Variable { - position: 67, - name: "$c", - }, - ), - ], - commas: [ - 65, - ], + item: Variable( + Variable { + position: 56, + name: "$a", + }, + ), + in: Keyword { + value: "in", + position: 59, }, - right_parenthesis: 69, + array: Tuple( + TupleExpression { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 62, + elements: CommaSeparated { + inner: [ + Variable( + Variable { + position: 63, + name: "$b", + }, + ), + Variable( + Variable { + position: 67, + name: "$c", + }, + ), + ], + commas: [ + 65, + ], + }, + right_parenthesis: 69, + }, + ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -160,59 +170,64 @@ DefinitionTree { value: "if", position: 85, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 88, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 91, - }, - array: Vec( - VecExpression { + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { comments: CommentGroup { comments: [], }, - vec: Keyword { - value: "vec", - position: 94, + item: Variable( + Variable { + position: 88, + name: "$a", + }, + ), + in: Keyword { + value: "in", + position: 91, }, - left_bracket: 97, - elements: CommaSeparated { - inner: [ - VecElementExpression { - value: Variable( - Variable { - position: 98, - name: "$b", - }, - ), + array: Vec( + VecExpression { + comments: CommentGroup { + comments: [], + }, + vec: Keyword { + value: "vec", + position: 94, }, - VecElementExpression { - value: Variable( - Variable { - position: 102, - name: "$b", + left_bracket: 97, + elements: CommaSeparated { + inner: [ + VecElementExpression { + value: Variable( + Variable { + position: 98, + name: "$b", + }, + ), + }, + VecElementExpression { + value: Variable( + Variable { + position: 102, + name: "$b", + }, + ), }, - ), + ], + commas: [ + 100, + ], }, - ], - commas: [ - 100, - ], - }, - right_bracket: 104, + right_bracket: 104, + }, + ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -234,83 +249,88 @@ DefinitionTree { value: "if", position: 120, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 123, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 126, - }, - array: Dict( - DictExpression { + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { comments: CommentGroup { comments: [], }, - dict: Keyword { - value: "dict", - position: 129, + item: Variable( + Variable { + position: 123, + name: "$a", + }, + ), + in: Keyword { + value: "in", + position: 126, }, - left_bracket: 133, - elements: CommaSeparated { - inner: [ - DictElementExpression { - key: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], + array: Dict( + DictExpression { + comments: CommentGroup { + comments: [], + }, + dict: Keyword { + value: "dict", + position: 129, + }, + left_bracket: 133, + elements: CommaSeparated { + inner: [ + DictElementExpression { + key: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: "'a'", + position: 134, + }, + ), + ), + double_arrow: 138, + value: Variable( + Variable { + position: 141, + name: "$b", }, - value: "'a'", - position: 134, - }, - ), - ), - double_arrow: 138, - value: Variable( - Variable { - position: 141, - name: "$b", + ), }, - ), - }, - DictElementExpression { - key: Literal( - String( - LiteralString { - comments: CommentGroup { - comments: [], + DictElementExpression { + key: Literal( + String( + LiteralString { + comments: CommentGroup { + comments: [], + }, + value: "'b'", + position: 145, + }, + ), + ), + double_arrow: 149, + value: Variable( + Variable { + position: 152, + name: "$c", }, - value: "'b'", - position: 145, - }, - ), - ), - double_arrow: 149, - value: Variable( - Variable { - position: 152, - name: "$c", + ), }, - ), + ], + commas: [ + 143, + ], }, - ], - commas: [ - 143, - ], - }, - right_bracket: 154, + right_bracket: 154, + }, + ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0096/tree.txt b/tests/samples/0096/tree.txt index ce2b819..7ac7bd1 100644 --- a/tests/samples/0096/tree.txt +++ b/tests/samples/0096/tree.txt @@ -50,42 +50,47 @@ DefinitionTree { value: "if", position: 31, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 34, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 37, - }, - array: RangeOperation( - From { + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { comments: CommentGroup { comments: [], }, - from: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 40, + item: Variable( + Variable { + position: 34, + name: "$a", + }, + ), + in: Keyword { + value: "in", + position: 37, + }, + array: RangeOperation( + From { + comments: CommentGroup { + comments: [], }, - ), + from: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "1", + position: 40, + }, + ), + ), + double_dot: 41, + }, ), - double_dot: 41, }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -107,53 +112,58 @@ DefinitionTree { value: "if", position: 51, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 54, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 57, - }, - array: RangeOperation( - Between { + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { comments: CommentGroup { comments: [], }, - from: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 60, - }, - ), + item: Variable( + Variable { + position: 54, + name: "$a", + }, ), - double_dot: 61, - to: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "10", - position: 63, + in: Keyword { + value: "in", + position: 57, + }, + array: RangeOperation( + Between { + comments: CommentGroup { + comments: [], }, - ), + from: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "1", + position: 60, + }, + ), + ), + double_dot: 61, + to: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "10", + position: 63, + }, + ), + ), + }, ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -175,54 +185,59 @@ DefinitionTree { value: "if", position: 73, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 76, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 79, - }, - array: RangeOperation( - BetweenInclusive { + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { comments: CommentGroup { comments: [], }, - from: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "1", - position: 82, - }, - ), + item: Variable( + Variable { + position: 76, + name: "$a", + }, ), - double_dot: 83, - equals: 85, - to: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "10", - position: 86, + in: Keyword { + value: "in", + position: 79, + }, + array: RangeOperation( + BetweenInclusive { + comments: CommentGroup { + comments: [], }, - ), + from: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "1", + position: 82, + }, + ), + ), + double_dot: 83, + equals: 85, + to: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "10", + position: 86, + }, + ), + ), + }, ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -244,42 +259,47 @@ DefinitionTree { value: "if", position: 96, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 99, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 102, - }, - array: RangeOperation( - To { + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { comments: CommentGroup { comments: [], }, - double_dot: 105, - to: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "10", - position: 107, + item: Variable( + Variable { + position: 99, + name: "$a", + }, + ), + in: Keyword { + value: "in", + position: 102, + }, + array: RangeOperation( + To { + comments: CommentGroup { + comments: [], }, - ), + double_dot: 105, + to: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "10", + position: 107, + }, + ), + ), + }, ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -301,43 +321,48 @@ DefinitionTree { value: "if", position: 117, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 120, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 123, - }, - array: RangeOperation( - ToInclusive { + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { comments: CommentGroup { comments: [], }, - double_dot: 126, - equals: 128, - to: Literal( - Integer( - LiteralInteger { - comments: CommentGroup { - comments: [], - }, - value: "10", - position: 129, + item: Variable( + Variable { + position: 120, + name: "$a", + }, + ), + in: Keyword { + value: "in", + position: 123, + }, + array: RangeOperation( + ToInclusive { + comments: CommentGroup { + comments: [], }, - ), + double_dot: 126, + equals: 128, + to: Literal( + Integer( + LiteralInteger { + comments: CommentGroup { + comments: [], + }, + value: "10", + position: 129, + }, + ), + ), + }, ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -359,31 +384,36 @@ DefinitionTree { value: "if", position: 139, }, - condition: ArrayOperation( - In { - comments: CommentGroup { - comments: [], - }, - item: Variable( - Variable { - position: 142, - name: "$a", - }, - ), - in: Keyword { - value: "in", - position: 145, - }, - array: RangeOperation( - Full { + conditions: CommaSeparated { + inner: [ + ArrayOperation( + In { comments: CommentGroup { comments: [], }, - double_dot: 148, + item: Variable( + Variable { + position: 142, + name: "$a", + }, + ), + in: Keyword { + value: "in", + position: 145, + }, + array: RangeOperation( + Full { + comments: CommentGroup { + comments: [], + }, + double_dot: 148, + }, + ), }, ), - }, - ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0098/tree.txt b/tests/samples/0098/tree.txt index 8673867..010cc4d 100644 --- a/tests/samples/0098/tree.txt +++ b/tests/samples/0098/tree.txt @@ -50,12 +50,17 @@ DefinitionTree { value: "if", position: 31, }, - condition: Variable( - Variable { - position: 34, - name: "$x", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 34, + name: "$x", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -104,12 +109,17 @@ DefinitionTree { value: "if", position: 49, }, - condition: Variable( - Variable { - position: 52, - name: "$x", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 52, + name: "$x", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -169,12 +179,17 @@ DefinitionTree { value: "if", position: 69, }, - condition: Variable( - Variable { - position: 72, - name: "$x", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 72, + name: "$x", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -235,12 +250,17 @@ DefinitionTree { value: "if", position: 90, }, - condition: Variable( - Variable { - position: 93, - name: "$x", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 93, + name: "$x", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -289,12 +309,17 @@ DefinitionTree { value: "if", position: 109, }, - condition: Variable( - Variable { - position: 112, - name: "$x", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 112, + name: "$x", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], @@ -344,12 +369,17 @@ DefinitionTree { value: "if", position: 129, }, - condition: Variable( - Variable { - position: 132, - name: "$x", - }, - ), + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 132, + name: "$x", + }, + ), + ], + commas: [], + }, block: BlockStatement { comments: CommentGroup { comments: [], diff --git a/tests/samples/0113/code.ara b/tests/samples/0113/code.ara new file mode 100644 index 0000000..0382951 --- /dev/null +++ b/tests/samples/0113/code.ara @@ -0,0 +1,13 @@ +function foo(): void { + if { + + } + + if $a, { + + } + + if $a, $b, $c, { + + } +} diff --git a/tests/samples/0113/tree.txt b/tests/samples/0113/tree.txt new file mode 100644 index 0000000..f5b8098 --- /dev/null +++ b/tests/samples/0113/tree.txt @@ -0,0 +1,158 @@ +DefinitionTree { + definitions: [ + Function( + FunctionDefinition { + comments: CommentGroup { + comments: [], + }, + attributes: [], + function: Keyword { + value: "function", + position: 0, + }, + name: Identifier { + position: 9, + value: "foo", + }, + templates: None, + parameters: FunctionLikeParameterListDefinition { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 12, + parameters: CommaSeparated { + inner: [], + commas: [], + }, + right_parenthesis: 13, + }, + return_type: FunctionLikeReturnTypeDefinition { + colon: 14, + type_definition: Void( + Keyword { + value: "void", + position: 16, + }, + ), + }, + body: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 21, + statements: [ + If( + IfStatement { + comments: CommentGroup { + comments: [], + }, + if: Keyword { + value: "if", + position: 27, + }, + conditions: CommaSeparated { + inner: [], + commas: [], + }, + block: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 30, + statements: [], + right_brace: 41, + }, + elseifs: [], + else: None, + }, + ), + If( + IfStatement { + comments: CommentGroup { + comments: [], + }, + if: Keyword { + value: "if", + position: 48, + }, + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 51, + name: "$a", + }, + ), + ], + commas: [ + 53, + ], + }, + block: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 55, + statements: [], + right_brace: 66, + }, + elseifs: [], + else: None, + }, + ), + If( + IfStatement { + comments: CommentGroup { + comments: [], + }, + if: Keyword { + value: "if", + position: 77, + }, + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 80, + name: "$a", + }, + ), + Variable( + Variable { + position: 84, + name: "$b", + }, + ), + Variable( + Variable { + position: 88, + name: "$c", + }, + ), + ], + commas: [ + 82, + 86, + 90, + ], + }, + block: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 92, + statements: [], + right_brace: 103, + }, + elseifs: [], + else: None, + }, + ), + ], + right_brace: 105, + }, + }, + ), + ], + eof: 107, +} \ No newline at end of file diff --git a/tests/samples/0114/code.ara b/tests/samples/0114/code.ara new file mode 100644 index 0000000..09e086c --- /dev/null +++ b/tests/samples/0114/code.ara @@ -0,0 +1,13 @@ +function foo(): void { + while { + + } + + while $a, { + + } + + while $a, $b, $c, { + + } +} diff --git a/tests/samples/0114/tree.txt b/tests/samples/0114/tree.txt new file mode 100644 index 0000000..f7eb29f --- /dev/null +++ b/tests/samples/0114/tree.txt @@ -0,0 +1,152 @@ +DefinitionTree { + definitions: [ + Function( + FunctionDefinition { + comments: CommentGroup { + comments: [], + }, + attributes: [], + function: Keyword { + value: "function", + position: 0, + }, + name: Identifier { + position: 9, + value: "foo", + }, + templates: None, + parameters: FunctionLikeParameterListDefinition { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 12, + parameters: CommaSeparated { + inner: [], + commas: [], + }, + right_parenthesis: 13, + }, + return_type: FunctionLikeReturnTypeDefinition { + colon: 14, + type_definition: Void( + Keyword { + value: "void", + position: 16, + }, + ), + }, + body: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 21, + statements: [ + While( + WhileStatement { + comments: CommentGroup { + comments: [], + }, + while: Keyword { + value: "while", + position: 27, + }, + conditions: CommaSeparated { + inner: [], + commas: [], + }, + block: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 33, + statements: [], + right_brace: 44, + }, + }, + ), + While( + WhileStatement { + comments: CommentGroup { + comments: [], + }, + while: Keyword { + value: "while", + position: 55, + }, + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 61, + name: "$a", + }, + ), + ], + commas: [ + 63, + ], + }, + block: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 65, + statements: [], + right_brace: 76, + }, + }, + ), + While( + WhileStatement { + comments: CommentGroup { + comments: [], + }, + while: Keyword { + value: "while", + position: 87, + }, + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 93, + name: "$a", + }, + ), + Variable( + Variable { + position: 97, + name: "$b", + }, + ), + Variable( + Variable { + position: 101, + name: "$c", + }, + ), + ], + commas: [ + 95, + 99, + 103, + ], + }, + block: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 105, + statements: [], + right_brace: 116, + }, + }, + ), + ], + right_brace: 118, + }, + }, + ), + ], + eof: 120, +} \ No newline at end of file diff --git a/tests/samples/0115/code.ara b/tests/samples/0115/code.ara new file mode 100644 index 0000000..c2cb894 --- /dev/null +++ b/tests/samples/0115/code.ara @@ -0,0 +1,13 @@ +function foo(): void { + do { + + } while; + + do { + + } while $a, ; + + do { + + } while $a, $b, $c, ; +} diff --git a/tests/samples/0115/tree.txt b/tests/samples/0115/tree.txt new file mode 100644 index 0000000..171eafb --- /dev/null +++ b/tests/samples/0115/tree.txt @@ -0,0 +1,167 @@ +DefinitionTree { + definitions: [ + Function( + FunctionDefinition { + comments: CommentGroup { + comments: [], + }, + attributes: [], + function: Keyword { + value: "function", + position: 0, + }, + name: Identifier { + position: 9, + value: "foo", + }, + templates: None, + parameters: FunctionLikeParameterListDefinition { + comments: CommentGroup { + comments: [], + }, + left_parenthesis: 12, + parameters: CommaSeparated { + inner: [], + commas: [], + }, + right_parenthesis: 13, + }, + return_type: FunctionLikeReturnTypeDefinition { + colon: 14, + type_definition: Void( + Keyword { + value: "void", + position: 16, + }, + ), + }, + body: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 21, + statements: [ + DoWhile( + DoWhileStatement { + comments: CommentGroup { + comments: [], + }, + do: Keyword { + value: "do", + position: 27, + }, + block: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 30, + statements: [], + right_brace: 41, + }, + while: Keyword { + value: "while", + position: 43, + }, + conditions: CommaSeparated { + inner: [], + commas: [], + }, + semicolon: 48, + }, + ), + DoWhile( + DoWhileStatement { + comments: CommentGroup { + comments: [], + }, + do: Keyword { + value: "do", + position: 59, + }, + block: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 62, + statements: [], + right_brace: 73, + }, + while: Keyword { + value: "while", + position: 75, + }, + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 81, + name: "$a", + }, + ), + ], + commas: [ + 83, + ], + }, + semicolon: 85, + }, + ), + DoWhile( + DoWhileStatement { + comments: CommentGroup { + comments: [], + }, + do: Keyword { + value: "do", + position: 96, + }, + block: BlockStatement { + comments: CommentGroup { + comments: [], + }, + left_brace: 99, + statements: [], + right_brace: 110, + }, + while: Keyword { + value: "while", + position: 112, + }, + conditions: CommaSeparated { + inner: [ + Variable( + Variable { + position: 118, + name: "$a", + }, + ), + Variable( + Variable { + position: 122, + name: "$b", + }, + ), + Variable( + Variable { + position: 126, + name: "$c", + }, + ), + ], + commas: [ + 120, + 124, + 128, + ], + }, + semicolon: 130, + }, + ), + ], + right_brace: 132, + }, + }, + ), + ], + eof: 134, +} \ No newline at end of file