Skip to content

Commit

Permalink
Update to support savonet/liquidsoap#3498
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Oct 31, 2023
1 parent 38a5f0d commit 15b5779
Show file tree
Hide file tree
Showing 5 changed files with 69,579 additions and 72,316 deletions.
16 changes: 4 additions & 12 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = grammar({

precedences: $ => [
[
"uminus",
"lpar",
"colon",
"dot",
Expand Down Expand Up @@ -75,16 +76,8 @@ module.exports = grammar({
_optvar: $ => choice("_", $.var),

integer: $ =>
seq(
optional($._uminus),
token(choice(/[\d][\d_]*/, /0[xX][\da-fA-F_]+/, /0[oO][0-7_]+/)),
),

float: $ =>
seq(
optional($._uminus),
choice($._float_no_lbra, /([\d][\d_]*)?\.[\d][\d_]*/),
),
token(choice(/-?[\d][\d_]*/, /0[xX][\da-fA-F_]+/, /0[oO][0-7_]+/)),
float: $ => choice($._float_no_lbra, /-?([\d][\d_]*)?\.[\d][\d_]*/),

version: $ => /[\d][\d_]*\.[\d][\d_]*\.[\d][\d_]*/,

Expand Down Expand Up @@ -742,7 +735,7 @@ module.exports = grammar({
and: $ => prec.left("and", seq($._expr, "and", $._expr)),
or: $ => prec.left("or", seq($._expr, "or", $._expr)),

_minus: $ => seq($._uminus, "(", $._expr, ")"),
_minus: $ => prec("uminus", seq($._uminus, $._expr)),

infix: $ =>
choice(
Expand All @@ -765,7 +758,6 @@ module.exports = grammar({
$.float,
$._minus,
$.string,
// $.string_interpolation,
$.var,
$.list,
$.get,
Expand Down
116 changes: 41 additions & 75 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,69 +188,35 @@
]
},
"integer": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_uminus"
},
{
"type": "BLANK"
}
]
},
{
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[\\d][\\d_]*"
},
{
"type": "PATTERN",
"value": "0[xX][\\da-fA-F_]+"
},
{
"type": "PATTERN",
"value": "0[oO][0-7_]+"
}
]
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "-?[\\d][\\d_]*"
},
{
"type": "PATTERN",
"value": "0[xX][\\da-fA-F_]+"
},
{
"type": "PATTERN",
"value": "0[oO][0-7_]+"
}
}
]
]
}
},
"float": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_uminus"
},
{
"type": "BLANK"
}
]
"type": "SYMBOL",
"name": "_float_no_lbra"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_float_no_lbra"
},
{
"type": "PATTERN",
"value": "([\\d][\\d_]*)?\\.[\\d][\\d_]*"
}
]
"type": "PATTERN",
"value": "-?([\\d][\\d_]*)?\\.[\\d][\\d_]*"
}
]
},
Expand Down Expand Up @@ -5316,25 +5282,21 @@
}
},
"_minus": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_uminus"
},
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "_expr"
},
{
"type": "STRING",
"value": ")"
}
]
"type": "PREC",
"value": "uminus",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_uminus"
},
{
"type": "SYMBOL",
"name": "_expr"
}
]
}
},
"infix": {
"type": "CHOICE",
Expand Down Expand Up @@ -5586,6 +5548,10 @@
"conflicts": [],
"precedences": [
[
{
"type": "STRING",
"value": "uminus"
},
{
"type": "STRING",
"value": "lpar"
Expand Down
89 changes: 12 additions & 77 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -4452,17 +4452,9 @@
"named": true,
"fields": {
"cond": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "and",
"named": true
Expand Down Expand Up @@ -4610,17 +4602,9 @@
]
},
"if_false": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "and",
"named": true
Expand Down Expand Up @@ -4768,17 +4752,9 @@
]
},
"if_true": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "and",
"named": true
Expand Down Expand Up @@ -4927,11 +4903,6 @@
}
}
},
{
"type": "integer",
"named": true,
"fields": {}
},
{
"type": "invoke",
"named": true,
Expand Down Expand Up @@ -5665,17 +5636,9 @@
]
},
"value": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "and",
"named": true
Expand Down Expand Up @@ -6294,17 +6257,9 @@
"named": true,
"fields": {
"base": {
"multiple": true,
"multiple": false,
"required": false,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "and",
"named": true
Expand Down Expand Up @@ -6626,17 +6581,9 @@
]
},
"value": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "and",
"named": true
Expand Down Expand Up @@ -6810,17 +6757,9 @@
"named": true,
"fields": {
"reference": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "and",
"named": true
Expand Down Expand Up @@ -6968,17 +6907,9 @@
]
},
"value": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "and",
"named": true
Expand Down Expand Up @@ -9031,6 +8962,10 @@
"type": "if_end",
"named": false
},
{
"type": "integer",
"named": true
},
{
"type": "json.object",
"named": false
Expand Down
Loading

0 comments on commit 15b5779

Please sign in to comment.