{"size": 664, "ext": "js", "max_stars_repo_path": "test/fixtures/test_grammars/external_tokens/grammar.js", "max_stars_repo_name": "nickolay/tree-sitter", "max_stars_repo_stars_event_min_datetime": "2021-12-13T02:32:21.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-13T02:32:21.000Z", "max_issues_repo_path": "test/fixtures/test_grammars/external_tokens/grammar.js", "max_issues_repo_name": "nickolay/tree-sitter", "max_issues_repo_issues_event_min_datetime": "2021-12-23T22:59:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-05T06:53:16.000Z", "max_forks_repo_path": "test/fixtures/test_grammars/external_tokens/grammar.js", "max_forks_repo_name": "nickolay/tree-sitter", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 22.1333333333, "max_line_length": 74, "alphanum_fraction": 0.6144578313}
// This grammar uses an external scanner to match special string literals,
// that track the nesting depth of parentheses, similar to Ruby's percent
// string literals.

module.exports = grammar({
  name: "external_tokens",

  externals: $ => [
    $._percent_string,
    $._percent_string_start,
    $._percent_string_end,
  ],

  extras: $ => [/\s/],

  rules: {
    expression: $ => choice($.string, $.sum, $.identifier),

    sum: $ => prec.left(seq($.expression, '+', $.expression)),

    string: $ => choice($._percent_string, seq(
      $._percent_string_start,
      $.expression,
      $._percent_string_end,
    )),

    identifier: $ => /[a-z]+/
  }
})
