Skip to content

Commit 0f8c79c

Browse files
committed
Add if_clause
so we can visit the first line of the `block_if_statement` in a single node.
1 parent aa449f2 commit 0f8c79c

File tree

7 files changed

+675489
-676015
lines changed

7 files changed

+675489
-676015
lines changed

grammar.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,17 +1338,21 @@ module.exports = grammar({
13381338
)),
13391339

13401340
block_if_statement: $ => seq(
1341+
$.if_clause,
1342+
repeat($._statement),
1343+
repeat($.elseif_clause),
1344+
optional($.else_clause),
1345+
optional($.statement_label),
1346+
$.end_if_statement
1347+
),
1348+
1349+
if_clause: $ => seq(
13411350
optional($.block_label_start_expression),
13421351
caseInsensitive('if'),
13431352
$._parenthesized_expression,
13441353
caseInsensitive('then'),
13451354
optional($._block_label),
13461355
$.end_of_statement,
1347-
repeat($._statement),
1348-
repeat($.elseif_clause),
1349-
optional($.else_clause),
1350-
optional($.statement_label),
1351-
$.end_if_statement
13521356
),
13531357

13541358
end_if_statement: $ => seq(

src/grammar.json

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14661,6 +14661,57 @@
1466114661
}
1466214662
},
1466314663
"block_if_statement": {
14664+
"type": "SEQ",
14665+
"members": [
14666+
{
14667+
"type": "SYMBOL",
14668+
"name": "if_clause"
14669+
},
14670+
{
14671+
"type": "REPEAT",
14672+
"content": {
14673+
"type": "SYMBOL",
14674+
"name": "_statement"
14675+
}
14676+
},
14677+
{
14678+
"type": "REPEAT",
14679+
"content": {
14680+
"type": "SYMBOL",
14681+
"name": "elseif_clause"
14682+
}
14683+
},
14684+
{
14685+
"type": "CHOICE",
14686+
"members": [
14687+
{
14688+
"type": "SYMBOL",
14689+
"name": "else_clause"
14690+
},
14691+
{
14692+
"type": "BLANK"
14693+
}
14694+
]
14695+
},
14696+
{
14697+
"type": "CHOICE",
14698+
"members": [
14699+
{
14700+
"type": "SYMBOL",
14701+
"name": "statement_label"
14702+
},
14703+
{
14704+
"type": "BLANK"
14705+
}
14706+
]
14707+
},
14708+
{
14709+
"type": "SYMBOL",
14710+
"name": "end_if_statement"
14711+
}
14712+
]
14713+
},
14714+
"if_clause": {
1466414715
"type": "SEQ",
1466514716
"members": [
1466614717
{
@@ -14712,48 +14763,6 @@
1471214763
{
1471314764
"type": "SYMBOL",
1471414765
"name": "end_of_statement"
14715-
},
14716-
{
14717-
"type": "REPEAT",
14718-
"content": {
14719-
"type": "SYMBOL",
14720-
"name": "_statement"
14721-
}
14722-
},
14723-
{
14724-
"type": "REPEAT",
14725-
"content": {
14726-
"type": "SYMBOL",
14727-
"name": "elseif_clause"
14728-
}
14729-
},
14730-
{
14731-
"type": "CHOICE",
14732-
"members": [
14733-
{
14734-
"type": "SYMBOL",
14735-
"name": "else_clause"
14736-
},
14737-
{
14738-
"type": "BLANK"
14739-
}
14740-
]
14741-
},
14742-
{
14743-
"type": "CHOICE",
14744-
"members": [
14745-
{
14746-
"type": "SYMBOL",
14747-
"name": "statement_label"
14748-
},
14749-
{
14750-
"type": "BLANK"
14751-
}
14752-
]
14753-
},
14754-
{
14755-
"type": "SYMBOL",
14756-
"name": "end_if_statement"
1475714766
}
1475814767
]
1475914768
},

0 commit comments

Comments
 (0)