Skip to content

Commit

Permalink
Cleanup begin
Browse files Browse the repository at this point in the history
  • Loading branch information
npezza93 committed Jul 23, 2022
1 parent ec7fdab commit 76b00c5
Show file tree
Hide file tree
Showing 3 changed files with 299,301 additions and 299,640 deletions.
16 changes: 6 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,6 @@ module.exports = grammar({
'end'
),

body_statement: $ => choice(
seq($._statements, repeat(choice($.rescue, $.else, $.ensure))),
seq(optional($._statements), repeat1(choice($.rescue, $.else, $.ensure))),
),

superclass: $ => seq('<', $._expression),

singleton_class: $ => seq(
Expand Down Expand Up @@ -601,7 +596,7 @@ module.exports = grammar({
)
),

begin: $ => seq('begin', optional($._terminator), $._body_statement),
begin: $ => seq('begin', optional($._terminator), optional($._body_statement), 'end'),

ensure: $ => seq('ensure', optional($._statements)),

Expand All @@ -619,10 +614,11 @@ module.exports = grammar({

exception_variable: $ => seq('=>', $._lhs),

_body_statement: $ => seq(
optional($._statements),
repeat(choice($.rescue, $.else, $.ensure)),
'end'
body_statement: $ => $._body_statement,

_body_statement: $ => choice(
seq($._statements, repeat(choice($.rescue, $.else, $.ensure))),
seq(optional($._statements), repeat1(choice($.rescue, $.else, $.ensure))),
),

// Method calls without parentheses (aka "command calls") are only allowed
Expand Down
169 changes: 72 additions & 97 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -971,77 +971,6 @@
}
]
},
"body_statement": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_statements"
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "rescue"
},
{
"type": "SYMBOL",
"name": "else"
},
{
"type": "SYMBOL",
"name": "ensure"
}
]
}
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_statements"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "rescue"
},
{
"type": "SYMBOL",
"name": "else"
},
{
"type": "SYMBOL",
"name": "ensure"
}
]
}
}
]
}
]
},
"superclass": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -3334,8 +3263,20 @@
]
},
{
"type": "SYMBOL",
"name": "_body_statement"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_body_statement"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "end"
}
]
},
Expand Down Expand Up @@ -3474,44 +3415,78 @@
}
]
},
"body_statement": {
"type": "SYMBOL",
"name": "_body_statement"
},
"_body_statement": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_statements"
},
{
"type": "BLANK"
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "rescue"
},
{
"type": "SYMBOL",
"name": "else"
},
{
"type": "SYMBOL",
"name": "ensure"
}
]
}
}
]
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "rescue"
},
{
"type": "SYMBOL",
"name": "else"
},
{
"type": "SYMBOL",
"name": "ensure"
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_statements"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "rescue"
},
{
"type": "SYMBOL",
"name": "else"
},
{
"type": "SYMBOL",
"name": "ensure"
}
]
}
]
}
},
{
"type": "STRING",
"value": "end"
}
]
}
]
},
Expand Down
Loading

0 comments on commit 76b00c5

Please sign in to comment.