Skip to content

Commit

Permalink
RakuAST: get meaningful .raku output for RakuAST classes
Browse files Browse the repository at this point in the history
This should help with people writing RakuAST tests, and will
probably also be helpful in the future for people doing other stuff
with RakuAST, as you can now easily get the RakuAST calls for a
given piece of Raku source code.  Something like:

    say Q|sub Bar::foo($a) { say $a }|.AST.raku

now produces a roundtripping:

RakuAST::StatementList.new(
  RakuAST::Statement::Expression.new(
    expression => RakuAST::Sub.new(
      name      => RakuAST::Name.from-identifier-parts("Bar","foo")),
      signature => RakuAST::Signature.new(
        parameters => (
          RakuAST::Parameter.new(
            type   => RakuAST::Type::Simple.new(
              RakuAST::Name.from-identifier("Any")
            ),
            target => RakuAST::ParameterTarget::Var.new("\$a")
          ),
        )
      ),
      body      => RakuAST::Blockoid.new(
        RakuAST::StatementList.new(
          RakuAST::Statement::Expression.new(
            expression => RakuAST::Call::Name.new(
              name => RakuAST::Name.from-identifier("say"),
              args => RakuAST::ArgList.new(
                RakuAST::Var::Lexical.new("\$a")
              )
            )
          )
        )
      )
    )
  )
)
  • Loading branch information
lizmat committed Feb 24, 2023
1 parent 48c19e1 commit f6fe116
Show file tree
Hide file tree
Showing 2 changed files with 1,220 additions and 0 deletions.

0 comments on commit f6fe116

Please sign in to comment.