Skip to content

Commit fdc7757

Browse files
authored
add intermediate ident (#12)
1 parent 505f5bd commit fdc7757

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

grammar.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = grammar({
2424
name: "jsonnet",
2525
extras: ($) => [/\s/, $.comment],
2626
externals: ($) => [$._string_start, $._string_content, $._string_end],
27-
word: $ => $.id,
27+
word: $ => $._ident,
2828
inline: ($) => [$.h, $.objinside],
2929
conflicts: () => [],
3030

@@ -242,8 +242,12 @@ module.exports = grammar({
242242
)
243243
),
244244
named_argument: ($) => seq($.id, "=", $.expr),
245-
246-
id: () => /[_a-zA-Z][_a-zA-Z0-9]*/,
245+
id: ($) => $._ident,
246+
// This use of an intermediate rule for identifiers is to
247+
// overcome some limitations in ocaml-tree-sitter-semgrep.
248+
// Indeed, ocaml-tree-sitter-semgrep can't override terminals (here was id)
249+
// that are also mentioned in the 'word:' directive.
250+
_ident: () => /[_a-zA-Z][_a-zA-Z0-9]*/,
247251

248252
// COPIED FROM: tree-sitter-json
249253
number: () => {

0 commit comments

Comments
 (0)