Skip to content

Instantly share code, notes, and snippets.

View softmoth's full-sized avatar

Tim Siegel softmoth

View GitHub Profile
@softmoth
softmoth / gist:1069055
Created July 7, 2011 07:43
november test run
tim@lakshmi:~/g/code/p6/november$ prove -r -eperl6 t 2>&1 | less
t/cgi/01-cgi.t ................................ ok
t/cgi/03-urlencoded.t ......................... ok
t/config.t .................................... ok
t/digest/01-digest.t .......................... ok
t/dispatcher/01-basics.t ...................... ok
t/dispatcher/02-add_rules.t ................... ok
Not enough positional parameters passed; got 0 but expected 1
in <anon> at line 7:t/dispatcher/03-whatever.t
in 'Dispatcher::Rule::apply' at line 44:/Users/tim/g/code/p6/november/lib/Dispatcher/Rule.pm
@softmoth
softmoth / gist:1529700
Created December 28, 2011 20:56
simple IF grammar
grammar Directive::Grammar {
rule TOP { ^ [<direction> | <quit> | <help> | <command>] $ }
rule direction { ['n' | 's' | 'e' | 'w' | 'out' | 'in'] }
rule quit { 'quit' }
rule help { ['help' | '?'] }
rule command { <verb> <noun_phrase>? }
rule verb { \w+ }
rule noun_phrase { ['the' | 'a' | 'some']? \w+ }
@softmoth
softmoth / gist:1530283
Created December 28, 2011 23:02
whitespace in rule, differs w/ niecza (correct?) vs. nom
grammar G {
rule TOP { ^ <word> ** 2 $ }
rule word { \w+ }
}
say G.parse('take garbage')<word>.map({"«$_»"}).join(', ');
@softmoth
softmoth / gist:1536817
Created December 30, 2011 00:06
fun with imperative sentences
#use Grammar::Tracer;
grammar IF::Grammar {
my @adjectives = <small tiny big huge large shiny dull black white red blue yellow green orange purple>;
my @prepositions = <for in under over from to on off at by between below across through into behind beside with towards>, 'away \s+ from', 'next \s+ to', 'out \s+ of';
my @objPronouns = <me you him her it us them>;
my @posPronouns = <my your his her its our their>;
my @articles = <a an the some several>, 'a few', <one two three four five>, '\d+';
@softmoth
softmoth / gist:1537223
Created December 30, 2011 01:50
LTM bug with <{ join '|', @array }> regex
my @words = <north northeast>;
print "unsorted: ";
say 'northeast' ~~ / ^ <{join '|', @words }> $ / ?? "parsed $/" !! 'no parse';
print "sorted: ";
say 'northeast' ~~ / ^ <{join '|', @words.sort({ $^b.chars cmp $^a.chars }) }> $ / ?? "parsed $/" !! 'no parse';
@softmoth
softmoth / gist:1552694
Created January 2, 2012 23:57
BUILD() method called after object creation? how in perl6?
#! /usr/bin/env perl
use strict;
use warnings;
package Vocab;
use Moose;
my %WORDS;
@softmoth
softmoth / gist:1552700
Created January 2, 2012 23:59
submethod BUILD()
#! /usr/bin/env perl6
my %words = ();
class Vocab {
has Str $.word;
has Str @.synonyms = [];
submethod BUILD(:$!word, :@!synonyms, *@pos, *%nam) {
note "Vocab BUILD(): ", @pos.perl, %nam.perl;
@softmoth
softmoth / gist:3145916
Created July 19, 2012 18:43
spectest t/spec/S02-types/version.t on nom 2012-07-19
12:40 ~/g/code/p6/rakudo$ ./inst/bin/perl6 !$
./inst/bin/perl6 t/spec/S02-types/version.t
1..35
ok 1 - 1.2.1alpha1.0 cmp 1.2.1alpha1 is Same
ok 2 - 1.2.1alpha1 cmp 1.2.1.alpha1 is Same
ok 3 - 1.2.1.alpha1 cmp 1.2.1alpha.1 is Same
ok 4 - 1.2.1alpha.1 cmp 1.2.1.alpha.1 is Same
ok 5 - 1.2.1.alpha.1 cmp 1.2-1+alpha/1 is Same
ok 6 - 1.2.1_01 cmp 1.2.1_1 is Same
ok 7 - 1.2.1_1 cmp 1.2.1._1 is Same
sub checklastval () is rw {
Proxy.new(
FETCH => sub ($self) { #OK not used
'hello',
},
STORE => sub ($self, $val) { #OK not used
'hello';
}
);
};
@softmoth
softmoth / gist:3350640
Created August 14, 2012 16:28
Indented pod block doesn't work unless is first block in doc
=head1 Foo
=head1 Bar
say $=pod.perl;