/// // @ts-check module.exports = grammar({ name: "dql", extras: ($) => [/\s/, $.comment], rules: { source_file: ($) => repeat($._definition), _definition: ($) => choice($.block, $.identifier, $.string, $.number), block: ($) => prec(1, seq( optional(field("name", $.identifier)), "{", repeat($._definition), "}" )), comment: ($) => token(seq("#", /.*/)), string: ($) => token( seq( '"', repeat( choice( /[^"\\]/, seq("\\", /./), ) ), '"' ) ), number: ($) => token(choice(/\d+\.\d+/, /\d+/)), identifier: ($) => token(choice( seq("@", /[a-zA-Z_][a-zA-Z0-9_.:]*/), seq("$", /[a-zA-Z_][a-zA-Z0-9_]*/), /[a-zA-Z_][a-zA-Z0-9_.:]*/, )), }, });