Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Fix grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmholt committed Jun 18, 2019
1 parent a0f622a commit 87b9576
Show file tree
Hide file tree
Showing 4 changed files with 17,013 additions and 5,236 deletions.
33 changes: 15 additions & 18 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,27 @@ module.exports = grammar({
class_definition: $ => seq(
/class/i,
repeat($._newline),
/[a-z_][a-z0-9_]+/,
repeat($._newline),
'{',
repeat(
seq(
repeat($._newline),
choice(
$.class_property,
seq($.class_property, $._terminator),
$.class_method
)
)
),
repeat($._newline),
'}'
),

class_property: $ => seq(
optional($.type_expr),
$._newline,
optional(
seq(
$.type_expr,
repeat($._newline)
)
),
$.simple_variable
),

Expand Down Expand Up @@ -112,17 +116,18 @@ module.exports = grammar({
'{',
repeat(
seq(
repeat($._newline),
$._statement
$._statement,
$._terminator
)
),
repeat($._newline),
'}'
),

enum_definition: $ => seq(
/enum/i,
repeat($._newline),
/[a-z_][a-z0-9_]+/,
repeat($._newline),
'{',
repeat(
seq(
Expand Down Expand Up @@ -171,16 +176,13 @@ module.exports = grammar({
'{',
repeat(
seq(
repeat($._newline),
$._statement,
$._terminator
),
),
repeat($._newline),
'}',
repeat(
seq(
repeat($._newline),
/elseif/i,
repeat($._newline),
'(',
Expand All @@ -192,12 +194,10 @@ module.exports = grammar({
'{',
repeat(
seq(
repeat($._newline),
$._statement,
$._terminator
),
),
repeat($._newline),
'}'
)
),
Expand All @@ -208,12 +208,10 @@ module.exports = grammar({
'{',
repeat(
seq(
repeat($._newline),
$._statement,
$._terminator
),
),
repeat($._newline),
'}'
)
)
Expand All @@ -231,11 +229,10 @@ module.exports = grammar({
'{',
repeat(
seq(
repeat($._newline),
$._statement
$._statement,
$._terminator
),
),
repeat($._newline),
'}'
),

Expand Down
150 changes: 53 additions & 97 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@
"name": "_newline"
}
},
{
"type": "PATTERN",
"value": "[a-z_][a-z0-9_]+"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "STRING",
"value": "{"
Expand All @@ -187,19 +198,21 @@
"content": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "class_property"
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "class_property"
},
{
"type": "SYMBOL",
"name": "_terminator"
}
]
},
{
"type": "SYMBOL",
Expand All @@ -210,13 +223,6 @@
]
}
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "STRING",
"value": "}"
Expand All @@ -230,18 +236,26 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "type_expr"
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "type_expr"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_newline"
},
{
"type": "SYMBOL",
"name": "simple_variable"
Expand Down Expand Up @@ -369,26 +383,16 @@
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
"type": "SYMBOL",
"name": "_statement"
},
{
"type": "SYMBOL",
"name": "_statement"
"name": "_terminator"
}
]
}
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "STRING",
"value": "}"
Expand All @@ -409,6 +413,17 @@
"name": "_newline"
}
},
{
"type": "PATTERN",
"value": "[a-z_][a-z0-9_]+"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "STRING",
"value": "{"
Expand Down Expand Up @@ -580,13 +595,6 @@
"content": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "SYMBOL",
"name": "_statement"
Expand All @@ -598,13 +606,6 @@
]
}
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "STRING",
"value": "}"
Expand All @@ -614,13 +615,6 @@
"content": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "PATTERN",
"value": "elseif"
Expand Down Expand Up @@ -674,13 +668,6 @@
"content": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "SYMBOL",
"name": "_statement"
Expand All @@ -692,13 +679,6 @@
]
}
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "STRING",
"value": "}"
Expand Down Expand Up @@ -732,13 +712,6 @@
"content": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "SYMBOL",
"name": "_statement"
Expand All @@ -750,13 +723,6 @@
]
}
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "STRING",
"value": "}"
Expand Down Expand Up @@ -827,26 +793,16 @@
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
"type": "SYMBOL",
"name": "_statement"
},
{
"type": "SYMBOL",
"name": "_statement"
"name": "_terminator"
}
]
}
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_newline"
}
},
{
"type": "STRING",
"value": "}"
Expand Down
Loading

0 comments on commit 87b9576

Please sign in to comment.