| 1 | A ruby transliteration of src/perl6/STD.pm |
|---|
| 2 | |
|---|
| 3 | INSTALL |
|---|
| 4 | |
|---|
| 5 | The release of ruby 1.9.0 (dated late December '07) is recommended. |
|---|
| 6 | It will not work with ruby 1.8. ruby svn HEAD is also not the right thing. |
|---|
| 7 | There used to be iffy support for 1.8, but adding utf handling broke it. |
|---|
| 8 | |
|---|
| 9 | http://www.ruby-lang.org/en/news/2007/12/25/ruby-1-9-0-released/ |
|---|
| 10 | $ ruby --version |
|---|
| 11 | ruby 1.9.0 (2007-12-25 revision 14709) [...] |
|---|
| 12 | |
|---|
| 13 | Debian: |
|---|
| 14 | ruby1.9 libreadline-ruby1.9 |
|---|
| 15 | * Debian (testing aka "Lenny") error: |
|---|
| 16 | `require': no such file to load -- readline (LoadError) from -e:1:in `<main>' |
|---|
| 17 | Means you don't have libreadline-ruby1.9. |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | EXAMPLE |
|---|
| 21 | ./STD_red_run -e 42 |
|---|
| 22 | |
|---|
| 23 | time ((find ../../v6/v6-KindaPerl6/t/kp6/ -type f ; find ../../t/ -type f )| grep -v '\.svn' | sort | xargs -n 1 perl -e 'local $_=shift;exit if !/\.t$/;$r=system("./STD_red_run $_ > /dev/null 2>&1");print "",($r == 0 ? "-" : "X")," ",$_,"\n";' > test-status) |
|---|
| 24 | ~5 minutes |
|---|
| 25 | |
|---|
| 26 | NOTES |
|---|
| 27 | |
|---|
| 28 | STD_red_run is currently much faster in ruby 1.9 than 1.8. |
|---|
| 29 | If you compile large things, you probably want to make sure its #! line finds 1.9. |
|---|
| 30 | Either by having 1.9's "ruby" first in your PATH, or by editing the #! line. |
|---|
| 31 | |
|---|
| 32 | Regex reminders |
|---|
| 33 | given { <a>+ <b>+ } |
|---|
| 34 | token: /^ <a>+: <b>+: $/ |
|---|
| 35 | rule: /^ <.ws> <a>+: <.ws> <b>+: <.ws> $/ |
|---|
| 36 | regex: /^ <a>+ <b>+ $/ |
|---|
| 37 | which transliterate as |
|---|
| 38 | token: plusTOK{a} and plusTOK{b} |
|---|
| 39 | rule: wsp and plusTOK{a} and wsp and plusTOK{b} and wsp #handwritten rules |
|---|
| 40 | rule: plusTOK{a} and wsp and plusTOK{b} #in token rules #XXX hmm |
|---|
| 41 | regex: plusRX(lambda{ a }){ plusRX{ b }} |
|---|
| 42 | # but note, <a> can't be a regex - we won't backtrack into it. |
|---|
| 43 | |
|---|
| 44 | There are lots of regex ruls. Only the two noted as backtracking in |
|---|
| 45 | comments actually do. |
|---|
| 46 | |
|---|
| 47 | Re backtracking, |
|---|
| 48 | plusRX et al, _do not backtrack into their subrules_. |
|---|
| 49 | We are simplifying implementation by noting there are tokens everywhere. |
|---|
| 50 | If there turns out to be a case of a regex with backtracking, containing |
|---|
| 51 | a subrule which is itself a regex with backtracking, then we'll need to |
|---|
| 52 | hand fudge passing a continuation to that subrule. Very hopefully, the |
|---|
| 53 | case won't arise. |
|---|
| 54 | We're not making a regexp engine, nor a real Grammar. |
|---|
| 55 | We're simply trying to get the ability to parse static p6, by the |
|---|
| 56 | easiest possible development path. |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | RUBY YAML |
|---|
| 60 | |
|---|
| 61 | Is not being used now, so you can ignore this section. |
|---|
| 62 | |
|---|
| 63 | --yaml won't work under ruby 1.9 without a patch applied to 1.9's yaml.rb. |
|---|
| 64 | *** But --yaml isn't being used now, so this is no longer needed. |
|---|
| 65 | Error ruby/1.9.0/yaml.rb:391:in `hash': can't convert Hash into Integer (TypeError) |
|---|
| 66 | ruby 1.9.0 yaml has a bug. On some of Match objects, (eg, --yaml -e '3'), |
|---|
| 67 | .hash fails with : can't convert Hash into Integer (TypeError). |
|---|
| 68 | But 1.9's lookbehind provides 10x faster parsing than than our current 1.8 workaround. |
|---|
| 69 | So here is a patch to lib/ruby/1.9.0/yaml.rb: |
|---|
| 70 | PATCH_START |
|---|
| 71 | --- yaml.rb.orig 2008-03-20 13:25:42.000000000 -0400 |
|---|
| 72 | +++ yaml.rb 2008-03-20 13:26:03.000000000 -0400 |
|---|
| 73 | @@ -386,6 +386,7 @@ |
|---|
| 74 | end |
|---|
| 75 | oid = |
|---|
| 76 | case oid when Fixnum, NilClass; oid |
|---|
| 77 | + when Hash,Array; oid.object_id |
|---|
| 78 | else oid = "#{oid.object_id}-#{oid.hash}" |
|---|
| 79 | end |
|---|
| 80 | out.emit( oid, &e ) |
|---|
| 81 | PATCH_END |
|---|
| 82 | |
|---|