Skip to content

Commit

Permalink
add intermediate ident (Wilfred#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoann Padioleau authored Feb 7, 2023
1 parent 505f5bd commit fdc7757
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = grammar({
name: "jsonnet",
extras: ($) => [/\s/, $.comment],
externals: ($) => [$._string_start, $._string_content, $._string_end],
word: $ => $.id,
word: $ => $._ident,
inline: ($) => [$.h, $.objinside],
conflicts: () => [],

Expand Down Expand Up @@ -242,8 +242,12 @@ module.exports = grammar({
)
),
named_argument: ($) => seq($.id, "=", $.expr),

id: () => /[_a-zA-Z][_a-zA-Z0-9]*/,
id: ($) => $._ident,
// This use of an intermediate rule for identifiers is to
// overcome some limitations in ocaml-tree-sitter-semgrep.
// Indeed, ocaml-tree-sitter-semgrep can't override terminals (here was id)
// that are also mentioned in the 'word:' directive.
_ident: () => /[_a-zA-Z][_a-zA-Z0-9]*/,

// COPIED FROM: tree-sitter-json
number: () => {
Expand Down

0 comments on commit fdc7757

Please sign in to comment.