Add modifiers and case blocks in more places

pull/101/head
Max Brunsfeld 2018-02-22 16:27:15 +07:00
parent fb6af52272
commit d85f4043fa
3 changed files with 30086 additions and 26919 deletions

@ -57,7 +57,7 @@ module.exports = grammar({
import_declaration: $ => seq(
'import',
$.stable_identifier,
choice($.stable_identifier, $.identifier),
optional(seq(
'.',
choice(
@ -126,6 +126,7 @@ module.exports = grammar({
),
val_definition: $ => seq(
optional($.modifiers),
'val',
$._pattern,
optional(seq(':', $._type)),
@ -134,6 +135,7 @@ module.exports = grammar({
),
val_declaration: $ => seq(
optional($.modifiers),
'val',
commaSep1($.identifier),
':',
@ -141,6 +143,7 @@ module.exports = grammar({
),
var_declaration: $ => seq(
optional($.modifiers),
'var',
commaSep1($.identifier),
':',
@ -148,6 +151,7 @@ module.exports = grammar({
),
var_definition: $ => seq(
optional($.modifiers),
'var',
$._pattern,
optional(seq(':', $._type)),
@ -156,6 +160,7 @@ module.exports = grammar({
),
type_definition: $ => seq(
optional($.modifiers),
'type',
$._type_identifier,
optional($.type_parameters),
@ -356,6 +361,7 @@ module.exports = grammar({
$.infix_expression,
$.prefix_expression,
$.tuple_expression,
$.case_block,
$.block,
$.identifier,
$.number,
@ -378,10 +384,9 @@ module.exports = grammar({
$.case_block
),
case_block: $ => seq(
'{',
repeat($.case_clause),
'}'
case_block: $ => choice(
prec(-1, seq('{', '}')),
seq('{', repeat1($.case_clause), '}')
),
case_clause: $ => seq(
@ -410,7 +415,8 @@ module.exports = grammar({
call_expression: $ => prec(PREC.call, seq(
$._expression,
$.arguments
$.arguments,
optional(choice($.block, $.case_block))
)),
field_expression: $ => prec(PREC.field, seq(

140
src/grammar.json vendored

@ -82,8 +82,17 @@
"value": "import"
},
{
"type": "SYMBOL",
"name": "stable_identifier"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "stable_identifier"
},
{
"type": "SYMBOL",
"name": "identifier"
}
]
},
{
"type": "CHOICE",
@ -428,6 +437,18 @@
"val_definition": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "modifiers"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "val"
@ -470,6 +491,18 @@
"val_declaration": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "modifiers"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "val"
@ -512,6 +545,18 @@
"var_declaration": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "modifiers"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "var"
@ -554,6 +599,18 @@
"var_definition": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "modifiers"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "var"
@ -596,6 +653,18 @@
"type_definition": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "modifiers"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "type"
@ -1606,6 +1675,10 @@
"type": "SYMBOL",
"name": "tuple_expression"
},
{
"type": "SYMBOL",
"name": "case_block"
},
{
"type": "SYMBOL",
"name": "block"
@ -1684,22 +1757,44 @@
]
},
"case_block": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT",
"type": "PREC",
"value": -1,
"content": {
"type": "SYMBOL",
"name": "case_clause"
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "STRING",
"value": "}"
}
]
}
},
{
"type": "STRING",
"value": "}"
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "case_clause"
}
},
{
"type": "STRING",
"value": "}"
}
]
}
]
},
@ -1800,6 +1895,27 @@
{
"type": "SYMBOL",
"name": "arguments"
},
{
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "block"
},
{
"type": "SYMBOL",
"name": "case_block"
}
]
},
{
"type": "BLANK"
}
]
}
]
}

56847
src/parser.c vendored

File diff suppressed because it is too large Load Diff