Skip to content

Instantly share code, notes, and snippets.

@hythm7
Created November 16, 2023 18:15
Show Gist options
  • Save hythm7/e47e868bc4b3be776b38125679b935cd to your computer and use it in GitHub Desktop.
Save hythm7/e47e868bc4b3be776b38125679b935cd to your computer and use it in GitHub Desktop.
#!/usr/bin/env raku
use experimental :rakuast;
my $token1 = RakuAST::TokenDeclaration.new(
scope => "my",
name => RakuAST::Name.from-identifier("token1"),
body => RakuAST::Regex::Alternation.new(
RakuAST::Regex::Literal.new("a"),
RakuAST::Regex::Literal.new("b")
)
).EVAL;
say 'a' ~~ $token1; # 「a」
my $token2 = RakuAST::TokenDeclaration.new(
scope => "my",
name => RakuAST::Name.from-identifier("token2"),
body => RakuAST::Regex::Alternation.new(
<a b>.map({ RakuAST::Regex::Literal.new($_) })
)
).EVAL; # No such method 'visit-children' for invocant of type 'Seq'
say 'a' ~~ $token2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment