Raku Books / Creating a Compiler in Raku / Building AST

Function calls

Function calls are also drastically simpler in the form of AST, as the node carries only the name of the function and the node containing the argument of the function:

class AST::FunctionCall is ASTNode {
    has Str $.function-name;
    has ASTNode $.value;
}

The new action method does not do any real printing or string formatting:

method function-call($/) {
    $/.make(AST::FunctionCall.new(
        function-name => ~$<function-name>,
        value => $<value>.made
    ));
}

Course navigation

AST for expressions   |   Final tuning