Skip to content

Commit 2f2d825

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 2f2d825

File tree

7 files changed

+634705
-634674
lines changed

7 files changed

+634705
-634674
lines changed

grammar.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,19 +1338,27 @@ module.exports = grammar({
13381338
)),
13391339

13401340
block_if_statement: $ => seq(
1341-
optional($.block_label_start_expression),
1342-
caseInsensitive('if'),
1343-
$._parenthesized_expression,
1344-
caseInsensitive('then'),
1345-
optional($._block_label),
1346-
$.end_of_statement,
1341+
$._if_clause,
13471342
repeat($._statement),
13481343
repeat($.elseif_clause),
13491344
optional($.else_clause),
13501345
optional($.statement_label),
13511346
$.end_if_statement
13521347
),
13531348

1349+
_if_clause: $ => seq(
1350+
$.if_clause,
1351+
$.end_of_statement,
1352+
),
1353+
1354+
if_clause: $ => seq(
1355+
optional($.block_label_start_expression),
1356+
caseInsensitive('if'),
1357+
$._parenthesized_expression,
1358+
caseInsensitive('then'),
1359+
optional($._block_label),
1360+
),
1361+
13541362
end_if_statement: $ => seq(
13551363
whiteSpacedKeyword('end', 'if'),
13561364
optional($._block_label)

src/grammar.json

Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14663,46 +14663,42 @@
1466314663
"block_if_statement": {
1466414664
"type": "SEQ",
1466514665
"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+
},
1466614684
{
1466714685
"type": "CHOICE",
1466814686
"members": [
1466914687
{
1467014688
"type": "SYMBOL",
14671-
"name": "block_label_start_expression"
14689+
"name": "else_clause"
1467214690
},
1467314691
{
1467414692
"type": "BLANK"
1467514693
}
1467614694
]
1467714695
},
14678-
{
14679-
"type": "ALIAS",
14680-
"content": {
14681-
"type": "PATTERN",
14682-
"value": "[iI][fF]"
14683-
},
14684-
"named": false,
14685-
"value": "if"
14686-
},
14687-
{
14688-
"type": "SYMBOL",
14689-
"name": "_parenthesized_expression"
14690-
},
14691-
{
14692-
"type": "ALIAS",
14693-
"content": {
14694-
"type": "PATTERN",
14695-
"value": "[tT][hH][eE][nN]"
14696-
},
14697-
"named": false,
14698-
"value": "then"
14699-
},
1470014696
{
1470114697
"type": "CHOICE",
1470214698
"members": [
1470314699
{
1470414700
"type": "SYMBOL",
14705-
"name": "_block_label"
14701+
"name": "statement_label"
1470614702
},
1470714703
{
1470814704
"type": "BLANK"
@@ -14711,49 +14707,71 @@
1471114707
},
1471214708
{
1471314709
"type": "SYMBOL",
14714-
"name": "end_of_statement"
14715-
},
14710+
"name": "end_if_statement"
14711+
}
14712+
]
14713+
},
14714+
"_if_clause": {
14715+
"type": "SEQ",
14716+
"members": [
1471614717
{
14717-
"type": "REPEAT",
14718-
"content": {
14719-
"type": "SYMBOL",
14720-
"name": "_statement"
14721-
}
14718+
"type": "SYMBOL",
14719+
"name": "if_clause"
1472214720
},
1472314721
{
14724-
"type": "REPEAT",
14725-
"content": {
14726-
"type": "SYMBOL",
14727-
"name": "elseif_clause"
14728-
}
14729-
},
14722+
"type": "SYMBOL",
14723+
"name": "end_of_statement"
14724+
}
14725+
]
14726+
},
14727+
"if_clause": {
14728+
"type": "SEQ",
14729+
"members": [
1473014730
{
1473114731
"type": "CHOICE",
1473214732
"members": [
1473314733
{
1473414734
"type": "SYMBOL",
14735-
"name": "else_clause"
14735+
"name": "block_label_start_expression"
1473614736
},
1473714737
{
1473814738
"type": "BLANK"
1473914739
}
1474014740
]
1474114741
},
14742+
{
14743+
"type": "ALIAS",
14744+
"content": {
14745+
"type": "PATTERN",
14746+
"value": "[iI][fF]"
14747+
},
14748+
"named": false,
14749+
"value": "if"
14750+
},
14751+
{
14752+
"type": "SYMBOL",
14753+
"name": "_parenthesized_expression"
14754+
},
14755+
{
14756+
"type": "ALIAS",
14757+
"content": {
14758+
"type": "PATTERN",
14759+
"value": "[tT][hH][eE][nN]"
14760+
},
14761+
"named": false,
14762+
"value": "then"
14763+
},
1474214764
{
1474314765
"type": "CHOICE",
1474414766
"members": [
1474514767
{
1474614768
"type": "SYMBOL",
14747-
"name": "statement_label"
14769+
"name": "_block_label"
1474814770
},
1474914771
{
1475014772
"type": "BLANK"
1475114773
}
1475214774
]
14753-
},
14754-
{
14755-
"type": "SYMBOL",
14756-
"name": "end_if_statement"
1475714775
}
1475814776
]
1475914777
},

0 commit comments

Comments
 (0)