Skip to content

Commit

Permalink
feat!: new operator has and not-has
Browse files Browse the repository at this point in the history
  • Loading branch information
blindFS committed Feb 5, 2025
1 parent b51db01 commit 138bdd9
Show file tree
Hide file tree
Showing 7 changed files with 312,277 additions and 309,836 deletions.
26 changes: 5 additions & 21 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,19 +583,6 @@ module.exports = grammar({
field("file", choice(alias($.unquoted, $.val_string), $._stringish)),
),

stmt_register: ($) =>
prec.left(
PREC().low,
seq(
KEYWORD().register,
field(
"plugin",
choice(alias($.unquoted, $.val_string), $.val_variable),
),
field("signature", optional($.val_record)),
),
),

_stmt_hide: ($) => choice($.hide_mod, $.hide_env),

hide_mod: ($) =>
Expand Down Expand Up @@ -1530,13 +1517,12 @@ function _block_body_rules(suffix) {
/// Statements

["_statement" + suffix]: (
/**⋅@type {any} */ /** @type {{ [x: string]: string; _ctrl_statement?: any; _stmt_hide?: any; _stmt_overlay?: any; stmt_register?: any; stmt_source?: any; assignment?: any; }} */ $,
/**⋅@type {any} */ /** @type {{ [x: string]: string; _ctrl_statement?: any; _stmt_hide?: any; _stmt_overlay?: any; stmt_source?: any; assignment?: any; }} */ $,
) =>
choice(
$._ctrl_statement,
$._stmt_hide,
$._stmt_overlay,
$.stmt_register,
$.stmt_source,
alias_for_suffix($, "assignment", suffix),
alias_for_suffix($, "stmt_let", suffix),
Expand Down Expand Up @@ -2109,6 +2095,8 @@ function OPR() {
// membership tests
in: "in",
not_in: "not-in",
has: "has",
not_has: "not-has",
starts_with: "starts-with",
ends_with: "ends-with",

Expand Down Expand Up @@ -2151,12 +2139,6 @@ function PREC() {
};
}

function STATEMENT_PREC() {
return {
control: 1,
};
}

/// map of operators and their precedence
function TABLE() {
const multiplicatives = [
Expand Down Expand Up @@ -2191,6 +2173,8 @@ function PREDICATE() {
const memberships = [
OPR().in,
OPR().not_in,
OPR().has,
OPR().not_has,
OPR().starts_with,
OPR().ends_with,
];
Expand Down
67 changes: 5 additions & 62 deletions queries/nu/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"source-env"

"overlay"
"register"

"loop"
"while"
Expand Down Expand Up @@ -96,67 +95,11 @@ file_path: (val_string) @variable.parameter

;;; ---
;;; operators
(expr_binary [
"+"
"-"
"*"
"/"
"mod"
"//"
"++"
"**"
"=="
"!="
"<"
"<="
">"
">="
"=~"
"!~"
"and"
"or"
"xor"
"bit-or"
"bit-xor"
"bit-and"
"bit-shl"
"bit-shr"
"in"
"not-in"
"starts-with"
"ends-with"
] @operator )

(where_command [
"+"
"-"
"*"
"/"
"mod"
"//"
"++"
"**"
"=="
"!="
"<"
"<="
">"
">="
"=~"
"!~"
"and"
"or"
"xor"
"bit-or"
"bit-xor"
"bit-and"
"bit-shl"
"bit-shr"
"in"
"not-in"
"starts-with"
"ends-with"
] @operator)
(expr_binary
opr: _ @operator)

(where_command
opr: _ @operator)

(assignment [
"="
Expand Down
Loading

0 comments on commit 138bdd9

Please sign in to comment.