Created
October 31, 2016 18:06
-
-
Save zoffixznet/d5e1da4b96839ddab2c50b379277ea30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
use JSON::Fast; | |
my $eco = from-json LWP::Simple.get: | |
'http://ecosystem-api.p6c.org/projects.json'; | |
π©> | |
<h1>The Perl 6 Ecosystem of <?π© $eco.elems π©> modules!</h1> | |
<table> | |
<thead> | |
<th>Module</th> | |
<th>Author</th> | |
<th>Deps</th> | |
<th>URL</th> | |
</thead> | |
<tbody> | |
<?π© for |$eco { π©π©> | |
<tr> | |
<td><?π© .<name> π©></td> | |
<td><?π© .<authors> and .<authors>.join: ", " π©></td> | |
<td><?π© .<depends> and .<depends>.join: ", " π©></td> | |
<td style="white-space: nowrap;"> | |
<a href="<?π© .<source-url> π©>"><?π© .<source-url> π©></a> | |
</td> | |
</tr> | |
<?π© } π©π©> | |
</tbody> | |
</table> | |
END_CODE | |
grammar Acme::PHP6::Grammar { | |
token TOP { <piece> ** 0..* } | |
token bs { '<?π©' } | |
token be { 'π©>' } | |
proto token piece {*} | |
token piece:sym<html> { [<!before <bs>> .]+ } | |
token piece:sym<code-block> { <bs> $<code>=.+? <be> } | |
} | |
class Acme::PHP6::Actions { | |
method TOP ($/) { make $<piece>Β».made.join } | |
method piece:sym<html> ($/) { make ";say Qπ©$/π©;"; } | |
method piece:sym<code-block>($m) { | |
given $m<code>.Str -> $_ is copy { | |
$m.make: /';' \s*$/ || s/'π©'\s*$// ?? $_ !! 'say do {' ~ $_ ~ '};' | |
} | |
} | |
} | |
say Acme::PHP6::Grammar.subparse($PHP6_CODE, :actions(Acme::PHP6::Actions)) | |
.made.EVAL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment