Skip to content

Instantly share code, notes, and snippets.

@FCO
Created May 31, 2023 02:10
Show Gist options
  • Select an option

  • Save FCO/1d9faecbfaaa6370dbefdd29be3d08d8 to your computer and use it in GitHub Desktop.

Select an option

Save FCO/1d9faecbfaaa6370dbefdd29be3d08d8 to your computer and use it in GitHub Desktop.
First investigation for Red using RakuAST
#!/usr/bin/env raku
use v6.e.PREVIEW;
# Bla.^all.map: { $_ + 1 };
say [1,2,3].map: { $_ + 1 };
CHECK {
sub translate-rakuast-to-redast($raku) {
return RakuAST::IntLiteral.new: 42
}
for $*CU.grep: { $_ ~~ RakuAST::Call::Method && .name.canonicalize eq any <map grep first> } -> $ast {
$ast.args.push: RakuAST::ColonPair::Value.new(
key => "red-ast",
value => RakuAST::Circumfix::Parentheses.new(
RakuAST::SemiList.new(
RakuAST::Statement::Expression.new(
expression => translate-rakuast-to-redast($ast.args[0])
)
)
)
);
say $ast.DEPARSE;
}
#exit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment