Skip to content

Instantly share code, notes, and snippets.

@arnsholt
Created August 30, 2016 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnsholt/4ee0fa479b5c9dc61c80e72beb922b7d to your computer and use it in GitHub Desktop.
Save arnsholt/4ee0fa479b5c9dc61c80e72beb922b7d to your computer and use it in GitHub Desktop.
regexp: foo
generator: bar
grammar Thing {
token TOP { <check>+ }
proto regex check {*}
token check:sym<regexp> { <sym> ':' \s* (\N*)\n }
token check:sym<generator> { <sym> ':' \s* (\N*)\n }
}
class Actions {
method check:sym<regexp>($/) { say "Got regexp $0" }
method check:sym<generator>($/) { say "Got generator $0" }
}
Thing.parsefile('test.dat', :actions(Actions.new));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment