Scala 2 macros

Problem
-------
Scala 2 macro definition is not supported.

Solution
--------
This adds macro_body as an expression.
pull/659/head
Eugene Yokota 2023-07-23 14:13:02 +07:00
parent 8cdd8bdd7f
commit 7afd059843
2 changed files with 34 additions and 0 deletions

@ -1522,6 +1522,30 @@ def main() {
(identifier)
(identifier)))))
================================================================================
Macros (Scala 2 syntax)
================================================================================
class Foo {
def a: A =
macro B.b
}
--------------------------------------------------------------------------------
(compilation_unit
(class_definition
(identifier)
(template_body
(function_definition
(identifier)
(type_identifier)
(indented_block
(macro_body
(field_expression
(identifier)
(identifier))))))))
================================================================================
Macros (Scala 3 syntax)
================================================================================

@ -1019,6 +1019,7 @@ module.exports = grammar({
$.while_expression,
$.do_while_expression,
$.for_expression,
$.macro_body,
$._simple_expression,
),
@ -1306,6 +1307,15 @@ module.exports = grammar({
),
),
macro_body: $ =>
prec.left(
PREC.macro,
seq(
"macro",
choice($.infix_expression, $.prefix_expression, $._simple_expression),
)
),
/**
* PrefixExpr ::= [PrefixOperator] SimpleExpr
*/