Skip to content

Commit

Permalink
Merge pull request #43 from raw1z/master
Browse files Browse the repository at this point in the history
feat: improve table parsing
  • Loading branch information
TravonteD authored Feb 2, 2024
2 parents 5171959 + 4ad5a5a commit 15e4f8c
Show file tree
Hide file tree
Showing 6 changed files with 10,153 additions and 10,130 deletions.
33 changes: 16 additions & 17 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,23 +434,22 @@ module.exports = grammar({
']',
),

table: $ => seq(
'{',
repeat(choice(
seq(
':',
choice(
$.symbol,
$.multi_symbol,
),
),
seq(
$._sexp,
$._sexp,
),
)),
'}',
),
table_pair: $ => prec.left(1, choice(
seq(':', $.binding),
seq(
field('key', $.string),
field('value', $._sexp)
),
seq(
field('key', choice(
$.symbol,
$.multi_symbol
)),
field('value', $._sexp)
)
)),

table: $ => seq('{', repeat($.table_pair), '}'),

_literal: $ => choice(
$.string,
Expand Down
113 changes: 75 additions & 38 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,79 @@
}
]
},
"table_pair": {
"type": "PREC_LEFT",
"value": 1,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "binding"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "key",
"content": {
"type": "SYMBOL",
"name": "string"
}
},
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "_sexp"
}
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "key",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "symbol"
},
{
"type": "SYMBOL",
"name": "multi_symbol"
}
]
}
},
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "_sexp"
}
}
]
}
]
}
},
"table": {
"type": "SEQ",
"members": [
Expand All @@ -1500,44 +1573,8 @@
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ":"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "symbol"
},
{
"type": "SYMBOL",
"name": "multi_symbol"
}
]
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_sexp"
},
{
"type": "SYMBOL",
"name": "_sexp"
}
]
}
]
"type": "SYMBOL",
"name": "table_pair"
}
},
{
Expand Down
Loading

0 comments on commit 15e4f8c

Please sign in to comment.