Skip to content

Commit

Permalink
RakuAST: give Cool.AST an :expression named argument
Browse files Browse the repository at this point in the history
To return the expression of the first statement in the statement
list.  In other words, a shortcut for .statements.head.expression.
  • Loading branch information
lizmat committed May 25, 2023
1 parent 149dd88 commit 592d11d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core.c/core_epilogue.pm6
Expand Up @@ -151,7 +151,7 @@ augment class Cool {
}

# Allow for creating an AST out of a string, for core debugging mainly
method AST(Cool:D: :$run, :$compunit) {
method AST(Cool:D: :$run, :$compunit, :$expression) {

# Make sure we don't use the EVAL's MAIN context for the
# currently compiling compilation unit
Expand All @@ -177,7 +177,9 @@ augment class Cool {

$run
?? EVAL($ast)
!! $compunit ?? $ast !! $ast.statement-list
!! $expression
?? $ast.statement-list.statements.head.expression
!! $compunit ?? $ast !! $ast.statement-list
}
}

Expand Down

0 comments on commit 592d11d

Please sign in to comment.