Skip to content

Commit

Permalink
refactor: remove range_with_end
Browse files Browse the repository at this point in the history
This reverts commit 125a120361abd0e9b34a5068cfc015ab905c4981.
  • Loading branch information
blindFS committed Feb 23, 2025
1 parent 25ba6bd commit 477d94b
Show file tree
Hide file tree
Showing 3 changed files with 237,560 additions and 238,051 deletions.
9 changes: 3 additions & 6 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,6 @@ module.exports = grammar({

val_range: _range_rule(false),
_val_range: _range_rule(true),
_val_range_with_end: _range_rule(true, true),

_immediate_decimal: _decimal_rule(true),

Expand Down Expand Up @@ -1763,9 +1762,8 @@ function _decimal_rule(immediate) {

/**
* @param {boolean} anonymous
* @param {boolean} with_end_decimal
*/
function _range_rule(anonymous, with_end_decimal = false) {
function _range_rule(anonymous) {
// Divide each dot as a token to distinguish $.val_range and $.val_number
const create_opr = (/** @type {boolean} */ immediate) => {
const head_token = immediate ? token.immediate : token;
Expand Down Expand Up @@ -1809,11 +1807,10 @@ function _range_rule(anonymous, with_end_decimal = false) {
seq(opr_step, step, opr_imm, end),
];
const seq_with_start = [start, optional(seq(opr_step_imm, step)), opr_imm];
const end_pattern = with_end_decimal ? end : optional(end);

return prec.right(
anonymous ? PREC().range - 1 : PREC().range,
choice(...common_choices, seq(...seq_with_start, end_pattern)),
choice(...common_choices, seq(...seq_with_start, optional(end))),
);
};
}
Expand Down Expand Up @@ -1849,7 +1846,7 @@ function _unquoted_with_expr_rule(type) {
choice(
$._unquoted_anonymous_prefix,
$._val_number_decimal,
$._val_range_with_end,
$._val_range,
alias(unquoted_head, "_head"),
),
alias($._expr_parenthesized_immediate, $.expr_parenthesized),
Expand Down
182 changes: 3 additions & 179 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -12092,182 +12092,6 @@
]
}
},
"_val_range_with_end": {
"type": "PREC_RIGHT",
"value": 14,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_val_number_decimal"
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": ".."
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "."
}
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": ".."
}
},
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "..="
}
},
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "..<"
}
}
]
},
{
"type": "SYMBOL",
"name": "_immediate_decimal"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": ".."
}
},
{
"type": "SYMBOL",
"name": "_immediate_decimal"
},
{
"type": "CHOICE",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": ".."
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "..="
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "..<"
}
}
]
},
{
"type": "SYMBOL",
"name": "_immediate_decimal"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_val_number_decimal"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": ".."
}
},
{
"type": "SYMBOL",
"name": "_immediate_decimal"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": ".."
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "..="
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "..<"
}
}
]
},
{
"type": "SYMBOL",
"name": "_immediate_decimal"
}
]
}
]
}
},
"_immediate_decimal": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -15960,7 +15784,7 @@
},
{
"type": "SYMBOL",
"name": "_val_range_with_end"
"name": "_val_range"
},
{
"type": "ALIAS",
Expand Down Expand Up @@ -16055,7 +15879,7 @@
},
{
"type": "SYMBOL",
"name": "_val_range_with_end"
"name": "_val_range"
},
{
"type": "ALIAS",
Expand Down Expand Up @@ -16150,7 +15974,7 @@
},
{
"type": "SYMBOL",
"name": "_val_range_with_end"
"name": "_val_range"
},
{
"type": "ALIAS",
Expand Down
Loading

0 comments on commit 477d94b

Please sign in to comment.