Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created October 31, 2016 17:01
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 zoffixznet/aec4dcd55478859c90ebbd54f09801c4 to your computer and use it in GitHub Desktop.
Save zoffixznet/aec4dcd55478859c90ebbd54f09801c4 to your computer and use it in GitHub Desktop.
my $PHP6_CODE = Q:to/END_CODE/;
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>Today's Time and Date</title>
<?💩
use LWP::Simple;
my $*foo = get 'http://perl.org';
💩>
<h1>It's <?💩 $foo; 💩> right now!</h1>
END_CODE
grammar Acme::PHP6::Grammar {
token TOP { [ <html> | <code-block> ]+ }
token html { [<!before <bs>> .]+ }
token bs { '<?💩' }
token be { '💩>' }
token code-block { <bs> <code> <be> }
token code { .+? }
}
# class Acme::PHP6::Actions {
# method TOP ($/) { $/.Str.EVAL }
# method html ($/) { make "say Q|$/|;"; }
# method code ($/) { make $/ ~ ';'; }
# }
say Acme::PHP6::Grammar.subparse($PHP6_CODE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment