Add list expressions

This commit is contained in:
Bruno BELANYI 2024-04-07 23:24:14 +01:00
parent f548b1d5ad
commit e13f15e8db
5 changed files with 734 additions and 193 deletions

View file

@ -1,3 +1,7 @@
function commaSeparated(elem) {
return seq(elem, repeat(seq(",", elem)), optional(","))
}
module.exports = grammar({
name: "blueprint",
@ -32,6 +36,8 @@ module.exports = grammar({
$.identifier,
$.integer_literal,
$._string_literal,
// Composites
$.list_expression,
),
// The Blueprint scanner makes use of Go's lexer, so copy their rule
@ -72,6 +78,12 @@ module.exports = grammar({
),
)),
list_expression: ($) => seq(
"[",
optional(commaSeparated($._expr)),
"]",
),
// }}}
}
});