Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created August 7, 2011 23:56
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 tadzik/1130952 to your computer and use it in GitHub Desktop.
Save tadzik/1130952 to your computer and use it in GitHub Desktop.
┌─[tadzik@yavin4]─[~/src/nom] (nom)
└─[%]─> head src/Perl6/Pod.pm
# various helper methods for Pod parsing and processing
class Perl6::Pod {
our sub document($what, $with) {
if $with ne '' {
#say("Documenting stuff using ", $*DOCEE);
say("Documenting stuff of type ", pir::typeof($what));
my $true := $*ST.add_constant('Int', 'int', 1)<compile_time_value>;
$*ST.apply_trait('&trait_mod:<is>', $what, $*DOCEE, :docs($true));
}
}
┌─[tadzik@yavin4]─[~/src/nom] (nom)
└─[%]─> cat foo.pl
#= Color screen output using ANSI escape sequences
module Term::ANSIColor;
#= emit ANSI sequence for the given string of attributes
sub color (Str $what) is export { ... }
#= color the text according to the description
sub colored (Str $what, Str $how) is export { ... }
#= is the color valid?
sub colorvalid (*@a) is export { ... }
#= string colors from the string
sub colorstrip (*@a) is export { ... }
#= transform ANSI sequences into their string descriptions
sub uncolor (Str $what) is export { ... }
for $=POD {
.WHEREFORE.WHY.say;
}
DOC INIT {
use Pod::To::Text;
print pod2text($=POD)
}
┌─[tadzik@yavin4]─[~/src/nom] (nom)
└─[%]─> ./perl6 foo.pl
Documenting stuff of type Sub
Documenting stuff of type Sub
Documenting stuff of type Sub
Documenting stuff of type Sub
Documenting stuff of type Sub
Documenting stuff of type Term::ANSIColor
Block::Declarator<56391512>
Block::Declarator<53025600>
Block::Declarator<39301744>
Method 'WHY' not found for invocant of class 'Continuation'
current instr.: '_block1064' pc 1017 ((file unknown):17801214) (foo.pl:20)
called from Sub '_block17699' pc 717791 (src/gen/CORE.setting.pir:190970) (src/gen/CORE.setting:2999)
called from Sub 'reify' pc 717454 (src/gen/CORE.setting.pir:190843) (src/gen/CORE.setting:2983)
called from Sub '_block17585' pc 716602 (src/gen/CORE.setting.pir:190522) (src/gen/CORE.setting:2912)
called from Sub '_block17578' pc 716429 (src/gen/CORE.setting.pir:0) (src/gen/CORE.setting:2908)
called from Sub '_block17569' pc 716317 (src/gen/CORE.setting.pir:190399) (src/gen/CORE.setting:2906)
called from Sub '_block17552' pc 715767 (src/gen/CORE.setting.pir:190228) (src/gen/CORE.setting:2897)
called from Sub 'reify' pc 715432 (src/gen/CORE.setting.pir:190116) (src/gen/CORE.setting:2888)
called from Sub '_block17585' pc 716602 (src/gen/CORE.setting.pir:190522) (src/gen/CORE.setting:2912)
called from Sub '_block17578' pc 716429 (src/gen/CORE.setting.pir:0) (src/gen/CORE.setting:2908)
called from Sub '_block17569' pc 716317 (src/gen/CORE.setting.pir:190399) (src/gen/CORE.setting:2906)
called from Sub '_block17552' pc 715767 (src/gen/CORE.setting.pir:190228) (src/gen/CORE.setting:2897)
called from Sub 'reify' pc 715432 (src/gen/CORE.setting.pir:190116) (src/gen/CORE.setting:2888)
called from Sub '_block18033' pc 721059 (src/gen/CORE.setting.pir:192183) (src/gen/CORE.setting:3228)
called from Sub 'gimme' pc 720957 (src/gen/CORE.setting.pir:0) (src/gen/CORE.setting:3227)
called from Sub 'eager' pc 720485 (src/gen/CORE.setting.pir:192008) (src/gen/CORE.setting:3203)
called from Sub 'eager' pc 681867 (src/gen/CORE.setting.pir:173677) (src/gen/CORE.setting:641)
called from Sub 'eager' pc 656957 (src/gen/CORE.setting.pir:161903) (src/gen/CORE.setting:3432)
called from Sub '_block1012' pc 783 ((file unknown):17801070) (foo.pl:19)
called from Sub '_block1002' pc 83 ((file unknown):17800890) (foo.pl:2)
called from Sub '_block1000' pc 14 ((file unknown):17800830) (foo.pl:1)
called from Sub 'nqp;HLL;Compiler;_block1773' pc 34028 (src/stage2/gen/NQPHLL.pir:10718) (src/stage2/gen/NQPHLL.pm:1261)
called from Sub 'nqp;HLL;Compiler;eval' pc 33877 (src/stage2/gen/NQPHLL.pir:10650) (src/stage2/gen/NQPHLL.pm:1254)
called from Sub 'nqp;HLL;Compiler;evalfiles' pc 36268 (src/stage2/gen/NQPHLL.pir:11607) (src/stage2/gen/NQPHLL.pm:1416)
called from Sub 'nqp;HLL;Compiler;command_eval' pc 35175 (src/stage2/gen/NQPHLL.pir:11160) (src/stage2/gen/NQPHLL.pm:1361)
called from Sub 'nqp;Perl6;Compiler;command_eval' pc 862 (src/gen/perl6-compiler.pir:312) (src/Perl6/Compiler.nqp:13)
called from Sub 'nqp;HLL;Compiler;command_line' pc 34847 (src/stage2/gen/NQPHLL.pir:11051) (src/stage2/gen/NQPHLL.pm:1346)
called from Sub 'MAIN' pc 715 (src/gen/perl6.pir:257) (src/main.nqp src/gen/main-version.nqp:28)
called from Sub '_block1000' pc 100 (src/gen/perl6.pir:69) (src/main.nqp src/gen/main-version.nqp:1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment