Skip to content

Commit

Permalink
Merge pull request #102 from LeoniePhiline/fix/unnecessary-identifiers
Browse files Browse the repository at this point in the history
Fixes for misplaced `(identifier)` aliases & missing literals
  • Loading branch information
DerekStride authored Feb 19, 2023
2 parents 0d7a121 + 756ffc2 commit 3a3f92b
Show file tree
Hide file tree
Showing 10 changed files with 149,796 additions and 148,617 deletions.
37 changes: 19 additions & 18 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,20 +980,20 @@ module.exports = grammar({
storage_location: $ => prec.right(
seq(
$.keyword_location,
field('path', alias($._literal_string, $.identifier)),
field('path', alias($._literal_string, $.literal)),
optional(
seq(
$.keyword_cached,
$.keyword_in,
field('pool', alias($._literal_string, $.identifier)),
field('pool', alias($._literal_string, $.literal)),
optional(
choice(
$.keyword_uncached,
seq(
$.keyword_with,
$.keyword_replication,
'=',
field('value', alias($._number, $.literal)),
field('value', alias($._natural_number, $.literal)),
),
),
),
Expand All @@ -1011,12 +1011,12 @@ module.exports = grammar({
$.keyword_fields,
$.keyword_terminated,
$.keyword_by,
$._literal_string,
field('fields_terminated_char', alias($._literal_string, $.literal)),
optional(
seq(
$.keyword_escaped,
$.keyword_by,
$._literal_string,
field('escaped_char', alias($._literal_string, $.literal)),
)
)
)
Expand All @@ -1026,7 +1026,7 @@ module.exports = grammar({
$.keyword_lines,
$.keyword_terminated,
$.keyword_by,
$._literal_string,
field('row_terminated_char', alias($._literal_string, $.literal)),
)
)
),
Expand Down Expand Up @@ -1295,7 +1295,7 @@ module.exports = grammar({
),

_interval_definition: $ => seq(
$._number,
$._natural_number,
choice(
"millennium",
"century",
Expand Down Expand Up @@ -1339,7 +1339,7 @@ module.exports = grammar({
),

cast: $ => seq(
field('name', alias($.keyword_cast, $.identifier)),
field('name', $.keyword_cast),
'(',
seq(
field('parameter', $._expression),
Expand All @@ -1355,7 +1355,7 @@ module.exports = grammar({
),

count: $ => seq(
field('name', alias($.keyword_count, $.identifier)),
field('name', $.keyword_count),
'(',
$._aggregate_expression,
')',
Expand Down Expand Up @@ -1393,12 +1393,12 @@ module.exports = grammar({
$.keyword_preceding,
),
seq(
alias($._number, $.literal),
alias($._natural_number, $.literal),
$.keyword_preceding,
),
$._current_row,
seq(
alias($._number, $.literal),
alias($._natural_number, $.literal),
$.keyword_following,
),
seq(
Expand Down Expand Up @@ -1765,7 +1765,7 @@ module.exports = grammar({

literal: $ => prec(2,
choice(
$._number,
$._integer,
$._decimal_number,
$._literal_string,
$.keyword_true,
Expand All @@ -1780,11 +1780,12 @@ module.exports = grammar({
$._double_quote_string,
),
),
_number: _ => /\d+/,
_natural_number: _ => /\d+/,
_integer: $ => seq(optional("-"), $._natural_number),
_decimal_number: $ => choice(
seq(optional("-"), ".", $._number),
seq(optional("-"), $._number, ".", $._number),
seq(optional("-"), $._number, "."),
seq(optional("-"), ".", $._natural_number),
seq($._integer, ".", $._natural_number),
seq($._integer, "."),
),

bang: _ => '!',
Expand Down Expand Up @@ -1817,9 +1818,9 @@ function parametric_type($, type, params = ['size']) {
type,
'(',
// first parameter is guaranteed, shift it out of the array
field(params.shift(), alias($._number, $.literal)),
field(params.shift(), alias($._natural_number, $.literal)),
// then, fill in the ", next" until done
...params.map(p => seq(',', field(p, alias($._number, $.literal)))),
...params.map(p => seq(',', field(p, alias($._natural_number, $.literal)))),
')',
),
),
Expand Down
Loading

0 comments on commit 3a3f92b

Please sign in to comment.