const grammar_rules = require("./grammar/99_all.js");
module.exports = grammar({
name: "mcfunction",
conflicts: ($) => [
[$.subcommand_keyword, $.argument_keyword],
[$.item_slot, $._constant],
[$.selector_identifier, $._word],
[$.selector_identifier, $._data_path_node],
],
extras: (_) => [],
word: ($) => $.identifier,
reserved: {
global: (_) => ["execute", "return run", "run", "say"],
},
rules: {
source_file: ($) =>
optional(
choice(
seq(
repeat(
seq(
choice(optional($._statement), $._indentation),
seq(optional($._indentation), $._newline),
),
),
$._statement,
optional($._newline),
),
$._newline,
),
),
identifier: (_) => /[a-z_]+/,
backslash: (_) => /[ \t]*\\[ \t]*\r?\n[ \t]*/,
_whitespace: ($) => choice(/ +/, $.backslash),
_statement: ($) =>
seq(
optional($._indentation),
choice($.comment, $.special_comment, $.command),
),
_indentation: (_) => /[ \t]+/,
_newline: (_) => seq(optional(":"), /(?: *\r?\n)+/),
macro: (_) =>
token(
prec(
2,
choice(
seq("$(", /[0-9a-zA-Z._-]+/, ")"),
seq("%[", /[0-9a-zA-Z._-]+/, "]"),
),
),
),
...grammar_rules,
},
});