RakuAST
The syntax tree as objects: building, printing and running it.
34 rules from 19 tests. 12 of those tests are confirmed on both engines: Raku++ and Rakudo 2026.11 both pass, or Raku++ gives Rakudo's answer on every probe of a family. The verdict is the test's, not each rule's. How to read a case.
rakuast-declaration-terminatorRaku++ passesRakudo does not pass- 1
.AST.DEPARSEends anenumorsubsetdeclaration with;, so.AST.EVALcan parse what was rendered.subset Pos of Int where * > 0; my Pos $p = 5;survives.AST.EVAL - 2
.AST.DEPARSEkeeps themyofmy subsetandmy enum. - 3
.AST.DEPARSErendersenum C (a => 1)with one pair of parentheses, as written.enum C (a => 1)deparses asenum C (a => 1), notenum C ((a => 1))
rakuast-declaration-traitsRaku++ passesRakudo passes- 1
.AST.DEPARSEkeeps a declaration's traits:is exportwith its tags on a class, sub, enum and subset,is DEPRECATEDon a sub, and an attribute'sis default(…)andhandles <…>.
rakuast-deparseRaku++ passesRakudo passes- 1
.DEPARSEon a RakuAST tree constructed fromRakuAST::classes renders Raku source text for it. inferred
rakuast-deparse-l10nRaku++ passesRakudo cannot run itrakuast-docRaku++ passesRakudo passes- 1
.rakudocon an AST answers the source's pod asRakuAST::Doc::nodes, with the same classes in the same order for a document. inferred
More from this test: divergences (1).
rakuast-empty-and-pointy-blocksRaku++ passesRakudo passesrakuast-empty-edgeRaku++ passesRakudo does not pass- 1
RakuAST::Name::Part::EmptyEdgeis accepted besideRakuAST::Name::Part::Emptyfor the empty name part before a leading::or after a trailing one, and a tree built with either deparses and EVALs the same.
rakuast-evalRaku++ passesRakudo passes- 1
.EVALon a constructed RakuAST tree runs it in the caller's lexical scope, so the fragment sees the enclosing variables.
rakuast-eval-keeps-tree-groupingRaku++ passesRakudo passes- 1
.EVALon a RakuAST tree evaluates the tree's own grouping, so an operand that is itself an infix, prefix, list infix or ternary stays grouped.the tree of
(not 0) && (not 1)built from nodes EVALs to False - 2
.DEPARSEof a RakuAST tree writes no grouping parentheses that the nodes do not hold.the tree of
(not 0) && (not 1)deparses tonot 0 && not 1
rakuast-grammar-rule-viewRaku++ passesRakudo passes- 1
.ASTof a grammar rule builds the rule's regex tree out ofRakuAST::Regex::nodes, and.DEPARSErenders it as source.
rakuast-l10nRaku++ passesRakudo cannot run it- 1
.AST($lang)parses source written with a localized keyword set, read from therole L10N::<lang>a distribution ships, and answers the same tree the English source would.'mein $a = 42; wenn … { sag … }'.AST("DE")parses the German keywords - 2
A localized keyword for
.AST($lang)may be a bare word, a quoted non-simple word such as"il-mio", or a word outside ASCII such asfüralle.
rakuast-needs-no-pragmaRaku++ passesRakudo passes- 1
The
RakuAST::names are usable withoutuse experimental :rakuast.RakuAST::Sub.new(…).EVALruns with no pragmaAlso held by
rakuast-names.
rakuast-registryRaku++ passesRakudo cannot run itrakuast-start-block-deparseRaku++ passesRakudo passes- 1
.AST.DEPARSEof astartblock leaves out the implicit freshmy $/; my $!, so repeated.AST.DEPARSErounds render the same text, and a declaration the program wrote stays.
rakuast-start-expression-deparseRaku++ passesRakudo passes- 1
.AST.DEPARSEwritesstart EXPRas the expression it was written as, and a writtenstart { … }block as a block.my $p = start 5deparses asmy $p = start 5
rakuast-viewRaku++ passesRakudo cannot run it- 1
.ASTon source text returns aRakuAST::StatementList, and.AST(:compunit)wraps it in aRakuAST::CompUnit.q[say 1].AST.^nameisRakuAST::StatementList - 2
.ASTis a method of Cool, so it works on a number or an allomorph, while a Buf has no such method.42.AST.^nameisRakuAST::StatementList - 3
.AST.DEPARSErenders the tree back to Raku source: a CompUnit terminates every statement with;, a bare StatementList omits the last one, and a block statement ends in a newline without;.q[say [+] @a].AST.DEPARSEissay [+] @aplus a newline - 4
A
RakuAST::CompUnitanswers.statement-list, whose.statementslists the statements and whose.unshift-statementputs one in front. - 5
The
.ASTmethod itself needs nouse experimental :rakuast; only theRakuAST::names are gated.Q[say 1].ASTanswers a StatementList with no pragma
rakuast-view-declarationsRaku++ passesRakudo does not pass- 1
.ASTkeeps what a declaration says beyond its name — traits (is rw,is Int,does R),our, the pointy parameters ofifandfor,nopragmas, the path ofuse liband.=— so.AST.DEPARSErenders them and.AST.EVALruns the program as written.has $.x is rwdeparses with itsis rw;$x.=absstays.=
rakuast-view-parenthesesRaku++ passesRakudo passes- 1
.ASTkeeps the parentheses a program writes, so.AST.EVALevaluates the expression with its written grouping.'(1 + 2) * 3'.AST.EVALis 9 - 2
.AST.DEPARSErenders an angle subscript with its bare key.%h<a>deparses as%h<a>, not%h<"a"> - 3
.ASTkeeps a subscript's adverbs, so.AST.EVALapplies them.%h{"a"}:deletethrough.AST.EVALdeletes the key
rakuast-visitRaku++ passesRakudo passes