Add assignment

This commit is contained in:
Bruno BELANYI 2024-04-07 21:37:52 +01:00
parent fc9f1467df
commit 38bf9532ad
5 changed files with 2184 additions and 47 deletions

View file

@ -1,9 +1,41 @@
module.exports = grammar({
name: "blueprint",
extras: ($) => [
/\s+/,
],
rules: {
// TODO: add the actual grammar rules
source_file: $ => 'hello',
source_file: ($) => repeat($._definition),
_definition: ($) => choice(
$.assignment,
),
// Definitions {{{
assignment: ($) => seq(
field("left", $.identifier),
field("operator", "="),
field("right", $._expr),
),
// }}}
// Expressions {{{
_expr: ($) => choice(
// Literals
$.identifier,
$.integer_literal,
),
// The Blueprint scanner makes use of Go's lexer, so copy their rule
identifier: (_) => /[_\p{XID_Start}][_\p{XID_Continue}]*/,
integer_literal: (_) => /[0-9]+/,
// }}}
}
});