Skip to content

Commit

Permalink
Restrucure case clauses - move colons into case nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrunsfeld committed Oct 29, 2018
1 parent abed789 commit 0e8a1c1
Show file tree
Hide file tree
Showing 3 changed files with 17,360 additions and 17,084 deletions.
17 changes: 10 additions & 7 deletions grammar.js
Expand Up @@ -514,16 +514,19 @@ module.exports = grammar({

expression_case_clause: $ => seq(
choice($.expression_case, $.default_case),
':',
optional($._statement_list)
),

expression_case: $ => seq(
'case',
$.expression_list
$.expression_list,
':'
),

default_case: $ => 'default',
default_case: $ => seq(
'default',
':'
),

type_switch_statement: $ => seq(
'switch',
Expand All @@ -544,13 +547,13 @@ module.exports = grammar({

type_case_clause: $ => seq(
choice($.type_case, $.default_case),
':',
optional($._statement_list)
),

type_case: $ => seq(
'case',
commaSep1($._type)
commaSep1($._type),
':'
),

select_statement: $ => seq(
Expand All @@ -562,13 +565,13 @@ module.exports = grammar({

communication_clause: $ => seq(
choice($.communication_case, $.default_case),
':',
optional($._statement_list)
),

communication_case: $ => seq(
'case',
choice($.send_statement, $.receive_statement)
choice($.send_statement, $.receive_statement),
':'
),

_expression: $ => choice(
Expand Down
37 changes: 23 additions & 14 deletions src/grammar.json
Expand Up @@ -2291,10 +2291,6 @@
}
]
},
{
"type": "STRING",
"value": ":"
},
{
"type": "CHOICE",
"members": [
Expand All @@ -2319,12 +2315,25 @@
{
"type": "SYMBOL",
"name": "expression_list"
},
{
"type": "STRING",
"value": ":"
}
]
},
"default_case": {
"type": "STRING",
"value": "default"
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "default"
},
{
"type": "STRING",
"value": ":"
}
]
},
"type_switch_statement": {
"type": "SEQ",
Expand Down Expand Up @@ -2437,10 +2446,6 @@
}
]
},
{
"type": "STRING",
"value": ":"
},
{
"type": "CHOICE",
"members": [
Expand Down Expand Up @@ -2486,6 +2491,10 @@
}
}
]
},
{
"type": "STRING",
"value": ":"
}
]
},
Expand Down Expand Up @@ -2529,10 +2538,6 @@
}
]
},
{
"type": "STRING",
"value": ":"
},
{
"type": "CHOICE",
"members": [
Expand Down Expand Up @@ -2566,6 +2571,10 @@
"name": "receive_statement"
}
]
},
{
"type": "STRING",
"value": ":"
}
]
},
Expand Down

0 comments on commit 0e8a1c1

Please sign in to comment.