Add meta-variables
This is an EPITA extension of the language, used mostly by internal compiler machinery.
This commit is contained in:
parent
1cfcc43469
commit
572dab6f4b
5 changed files with 6785 additions and 4090 deletions
58
grammar.js
58
grammar.js
|
|
@ -29,6 +29,7 @@ module.exports = grammar({
|
|||
|
||||
conflicts: ($) => [
|
||||
[$._lvalue, $.array_expression],
|
||||
[$._lvalue, $.record_expression],
|
||||
[$._lvalue, $._type_identifier],
|
||||
],
|
||||
|
||||
|
|
@ -73,6 +74,9 @@ module.exports = grammar({
|
|||
$.for_expression,
|
||||
$.break_expression,
|
||||
$.let_expression,
|
||||
|
||||
$.meta_cast,
|
||||
$.meta_expression,
|
||||
),
|
||||
|
||||
nil_literal: (_) => "nil",
|
||||
|
|
@ -88,7 +92,10 @@ module.exports = grammar({
|
|||
// NOTE: includes reserved identifiers
|
||||
identifier: (_) => /[_a-zA-Z0-9]+/,
|
||||
|
||||
_type_identifier: ($) => alias($.identifier, $.type_identifier),
|
||||
_type_identifier: ($) => choice(
|
||||
alias($.identifier, $.type_identifier),
|
||||
$.meta_type_identifier,
|
||||
),
|
||||
|
||||
_field_identifier: ($) => alias($.identifier, $.field_identifier),
|
||||
|
||||
|
|
@ -112,6 +119,7 @@ module.exports = grammar({
|
|||
$.identifier,
|
||||
$.record_value,
|
||||
$.array_value,
|
||||
$.meta_lvalue,
|
||||
),
|
||||
|
||||
record_value: ($) => seq(
|
||||
|
|
@ -245,7 +253,12 @@ module.exports = grammar({
|
|||
|
||||
// Declarations {{{
|
||||
|
||||
_declaration_chunks: ($) => repeat1($._declaration_chunk),
|
||||
_declaration_chunks: ($) => repeat1(
|
||||
choice(
|
||||
$.meta_chunks,
|
||||
$._declaration_chunk,
|
||||
),
|
||||
),
|
||||
|
||||
_declaration_chunk: ($) => prec.left(
|
||||
choice(
|
||||
|
|
@ -335,6 +348,47 @@ module.exports = grammar({
|
|||
),
|
||||
|
||||
// }}}
|
||||
|
||||
// Meta-variables {{{
|
||||
|
||||
meta_chunks: ($) => seq(
|
||||
"_chunks",
|
||||
"(",
|
||||
field("index", $.integer_literal),
|
||||
")",
|
||||
),
|
||||
|
||||
meta_cast: ($) => seq(
|
||||
"_cast",
|
||||
"(",
|
||||
field("expression", $._expr),
|
||||
",",
|
||||
field("type", $._type),
|
||||
")",
|
||||
),
|
||||
|
||||
meta_expression: ($) => seq(
|
||||
"_exp",
|
||||
"(",
|
||||
field("index", $.integer_literal),
|
||||
")",
|
||||
),
|
||||
|
||||
meta_lvalue: ($) => seq(
|
||||
"_lvalue",
|
||||
"(",
|
||||
field("index", $.integer_literal),
|
||||
")",
|
||||
),
|
||||
|
||||
meta_type_identifier: ($) => seq(
|
||||
"_namety",
|
||||
"(",
|
||||
$.integer_literal,
|
||||
")",
|
||||
),
|
||||
|
||||
// }}}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue