Add assignment
This commit is contained in:
parent
fc9f1467df
commit
38bf9532ad
5 changed files with 2184 additions and 47 deletions
36
grammar.js
36
grammar.js
|
|
@ -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]+/,
|
||||
|
||||
// }}}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue