tree-sitter-cmake/grammar.js

31 lines
676 B
JavaScript
Raw Normal View History

2021-04-06 16:55:44 -04:00
module.exports = grammar({
name: 'CMake',
rules: {
2021-04-06 17:38:23 -04:00
source_file: $ => repeat($.command_invocation),
line_ending: $ => $.newline,
space: $ => /[ \t]+/,
newline: $ => /\n/,
identifier: $ => /[A-Za-z_][A-Za-z0-9_]*/,
argument: $ => /[^ ()#\"\\]+/,
seperation: $ => choice($.space, $.line_ending),
arguments: $ => seq($.argument, repeat($._seperated_arguments)),
_seperated_arguments: $ => prec.left(1, seq(
repeat1($.seperation),
optional($.argument)
)),
2021-04-06 17:38:23 -04:00
command_invocation: $ => seq(
repeat($.space),
$.identifier,
repeat($.space),
'(',
optional($.arguments),
2021-04-06 17:38:23 -04:00
')'
),
2021-04-06 16:55:44 -04:00
}
})