Changeset 21646

Show
Ignore:
Timestamp:
07/31/08 10:00:49 (5 months ago)
Author:
lwall
Message:

[STD] renamed main package to STD
fixed package name conflicts
fixed tests that used function call syntax for quotes
various other bugs
now parses all but one of the t/spec tests (needs macros)

Files:
6 modified
1 moved

Legend:

Unmodified
Added
Removed
  • src/perl6/Cursor.pmc

    r21614 r21646  
    111111        my $ext = ref($mixin) || $mixin; 
    112112        push @newmix, $ext; 
    113         $ext =~ s/^.*:://;      # just looking for a "cache" key, really 
    114         $NEWWHAT .= '_' . $ext; 
     113        $ext =~ s/(\w)\w*::/$1/g;       # just looking for a "cache" key, really 
     114        $NEWWHAT .= '_X_' . $ext; 
    115115    } 
    116116    $self->deb("mixin $NEWWHAT from $WHAT @newmix") if $DEBUG & DEBUG::mixins; 
     
    687687    my %r = %$self; 
    688688    $r{_herelang} = $self; 
    689     bless \%r, 'Perl::Q'; 
     689    bless \%r, 'STD::Q'; 
    690690} 
    691691 
     
    771771    delete $copy{_fate}; 
    772772    delete $copy{_orig}; 
    773     my $text = Perl::Dump(\%copy); 
     773    my $text = STD::Dump(\%copy); 
    774774    $text =~ s/^\s*_(?:pos|orig):.*\n//mg; 
    775775    $text; 
  • src/perl6/STD.pm

    r21614 r21646  
    1 grammar Perl:ver<6.0.0.alpha>:auth<http://perl.org>; 
     1grammar STD:ver<6.0.0.alpha>:auth<http://perl.org>; 
    22 
    33my $LANG is context; 
     
    392392    \v :: 
    393393    { $*LINE++ } 
    394     [ '#DEBUG -1' { say "DEBUG"; $Perl::DEBUG = $*DEBUG = -1; } ]? 
     394    [ '#DEBUG -1' { say "DEBUG"; $STD::DEBUG = $*DEBUG = -1; } ]? 
    395395} 
    396396 
     
    409409            [ 
    410410               <?after ^^ . > <.panic: "Can't use embedded comments in column 1"> 
    411             || <.quibble($¢.cursor_fresh( ::Perl::Q ))>   {*}                               #= embedded 
     411            || <.quibble($¢.cursor_fresh( ::STD::Q ))>   {*}                               #= embedded 
    412412            ] 
    413413         | :: \N*            {*}                                 #= end 
     
    992992 
    993993token postcircumfix:sym«< >» ( --> Methodcall) 
    994     { '<' <nibble($¢.cursor_fresh( ::Perl::Q ).tweak(:q).tweak(:w).balanced('<','>'))> [ '>' || <.panic: "Missing right angle quote"> ] } 
     994    { '<' <nibble($¢.cursor_fresh( ::STD::Q ).tweak(:q).tweak(:w).balanced('<','>'))> [ '>' || <.panic: "Missing right angle quote"> ] } 
    995995 
    996996token postcircumfix:sym«<< >>» ( --> Methodcall) 
    997     { '<<' <nibble($¢.cursor_fresh( ::Perl::Q ).tweak(:qq).tweak(:ww).balanced('<<','>>'))> [ '>>' || <.panic: "Missing right double-angle quote"> ] } 
     997    { '<<' <nibble($¢.cursor_fresh( ::STD::Q ).tweak(:qq).tweak(:ww).balanced('<<','>>'))> [ '>>' || <.panic: "Missing right double-angle quote"> ] } 
    998998 
    999999token postcircumfix:sym<« »> ( --> Methodcall) 
    1000     { '«' <nibble($¢.cursor_fresh( ::Perl::Q ).tweak(:qq).tweak(:ww).balanced('«','»'))> [ '»' || <.panic: "Missing right double-angle quote"> ] } 
     1000    { '«' <nibble($¢.cursor_fresh( ::STD::Q ).tweak(:qq).tweak(:ww).balanced('«','»'))> [ '»' || <.panic: "Missing right double-angle quote"> ] } 
    10011001 
    10021002token postop { 
     
    16971697        if $lang<_herelang> { 
    16981698            push @herestub_queue, 
    1699                 Perl::Herestub.new( 
     1699                STD::Herestub.new( 
    17001700                    delim => $<nibble><nibbles>[0], 
    17011701                    orignode => $¢, 
     
    17981798 
    17991799 
    1800 token quote:sym<' '>   { "'" <nibble($¢.cursor_fresh( ::Perl::Q ).tweak(:q).unbalanced("'"))> "'" } 
    1801 token quote:sym<" ">   { '"' <nibble($¢.cursor_fresh( ::Perl::Q ).tweak(:qq).unbalanced('"'))> '"' } 
    1802  
    1803 token quote:sym<« »>   { '«' <nibble($¢.cursor_fresh( ::Perl::Q ).tweak(:qq).tweak(:ww).balanced('«','»'))> '»' } 
    1804 token quote:sym«<< >>» { '<<' <nibble($¢.cursor_fresh( ::Perl::Q ).tweak(:qq).tweak(:ww).balanced('<<','>>'))> '>>' } 
    1805 token quote:sym«< >»   { '<' <nibble($¢.cursor_fresh( ::Perl::Q ).tweak(:q).tweak(:w).balanced('<','>'))> '>' } 
     1800token quote:sym<' '>   { "'" <nibble($¢.cursor_fresh( ::STD::Q ).tweak(:q).unbalanced("'"))> "'" } 
     1801token quote:sym<" ">   { '"' <nibble($¢.cursor_fresh( ::STD::Q ).tweak(:qq).unbalanced('"'))> '"' } 
     1802 
     1803token quote:sym<« »>   { '«' <nibble($¢.cursor_fresh( ::STD::Q ).tweak(:qq).tweak(:ww).balanced('«','»'))> '»' } 
     1804token quote:sym«<< >>» { '<<' <nibble($¢.cursor_fresh( ::STD::Q ).tweak(:qq).tweak(:ww).balanced('<<','>>'))> '>>' } 
     1805token quote:sym«< >»   { '<' <nibble($¢.cursor_fresh( ::STD::Q ).tweak(:q).tweak(:w).balanced('<','>'))> '>' } 
    18061806 
    18071807token quote:sym</ />   { 
     
    18281828    'qq' 
    18291829    [ 
    1830     | <quote_mod> » <!before '('> { $qm = $<quote_mod>.text } <.ws> <quibble($¢.cursor_fresh( ::Perl::Q ).tweak(:qq).tweak($qm => 1))> 
    1831     | » <!before '('> <.ws> <quibble($¢.cursor_fresh( ::Perl::Q ).tweak(:qq))> 
     1830    | <quote_mod> » <!before '('> { $qm = $<quote_mod>.text } <.ws> <quibble($¢.cursor_fresh( ::STD::Q ).tweak(:qq).tweak($qm => 1))> 
     1831    | » <!before '('> <.ws> <quibble($¢.cursor_fresh( ::STD::Q ).tweak(:qq))> 
    18321832    ] 
    18331833} 
     
    18361836    'q' 
    18371837    [ 
    1838     | <quote_mod> » <!before '('> { $qm = $<quote_mod>.text } <quibble($¢.cursor_fresh( ::Perl::Q ).tweak(:q).tweak($qm => 1))> 
    1839     | » <!before '('> <.ws> <quibble($¢.cursor_fresh( ::Perl::Q ).tweak(:q))> 
     1838    | <quote_mod> » <!before '('> { $qm = $<quote_mod>.text } <quibble($¢.cursor_fresh( ::STD::Q ).tweak(:q).tweak($qm => 1))> 
     1839    | » <!before '('> <.ws> <quibble($¢.cursor_fresh( ::STD::Q ).tweak(:q))> 
    18401840    ] 
    18411841} 
     
    18451845    'Q' 
    18461846    [ 
    1847     | <quote_mod> » <!before '('> { $qm = $<quote_mod>.text } <quibble($¢.cursor_fresh( ::Perl::Q ).tweak($qm => 1))> 
    1848     | » <!before '('> <.ws> <quibble($¢.cursor_fresh( ::Perl::Q ))> 
     1847    | <quote_mod> » <!before '('> { $qm = $<quote_mod>.text } <quibble($¢.cursor_fresh( ::STD::Q ).tweak($qm => 1))> 
     1848    | » <!before '('> <.ws> <quibble($¢.cursor_fresh( ::STD::Q ))> 
    18491849    ] 
    18501850} 
     
    18671867 
    18681868token quote:s { 
    1869     <sym> » <!before '('> <pat=sibble( $¢.cursor_fresh( ::Regex ), $¢.cursor_fresh( ::Perl::Q ).tweak(:qq))> 
     1869    <sym> » <!before '('> <pat=sibble( $¢.cursor_fresh( ::Regex ), $¢.cursor_fresh( ::STD::Q ).tweak(:qq))> 
    18701870} 
    18711871token quote:ss { 
    1872     <sym> » <!before '('> <pat=sibble( $¢.cursor_fresh( ::Regex ).tweak(:s), $¢.cursor_fresh( ::Perl::Q ).tweak(:qq))> 
     1872    <sym> » <!before '('> <pat=sibble( $¢.cursor_fresh( ::Regex ).tweak(:s), $¢.cursor_fresh( ::STD::Q ).tweak(:qq))> 
    18731873} 
    18741874token quote:tr { 
    1875     <sym> » <!before '('> <pat=tribble( $¢.cursor_fresh( ::Perl::Q ).tweak(:q))> 
     1875    <sym> » <!before '('> <pat=tribble( $¢.cursor_fresh( ::STD::Q ).tweak(:q))> 
    18761876} 
    18771877 
     
    20652065} 
    20662066 
    2067 grammar Q is Perl { 
    2068  
    2069     role b { 
     2067grammar Q is STD { 
     2068 
     2069    role b1 { 
    20702070        token escape:sym<\\> { <sym> <item=backslash> } 
    20712071        token backslash:qq { <?before 'q'> { $<quote> = $¢.cursor_fresh($+LANG).quote(); } } 
     
    20912091    } # end role 
    20922092 
    2093     role _b { 
     2093    role b0 { 
    20942094        token escape:sym<\\> { <!> } 
    20952095    } # end role 
    20962096 
    2097     role c { 
     2097    role c1 { 
    20982098        token escape:sym<{ }> { <?before '{'> [ :lang($+LANG) <block> ] } 
    20992099    } # end role 
    21002100 
    2101     role _c { 
     2101    role c0 { 
    21022102        token escape:sym<{ }> { <!> } 
    21032103    } # end role 
    21042104 
    2105     role s { 
     2105    role s1 { 
    21062106        token escape:sym<$> { <?before '$'> [ :lang($+LANG) <variable> <extrapost>? ] || <.panic: "Non-variable \$ must be backslashed"> } 
    21072107        token special_variable:sym<$"> { 
     
    21122112    } # end role 
    21132113 
    2114     role _s { 
     2114    role s0 { 
    21152115        token escape:sym<$> { <!> } 
    21162116        token special_variable:sym<$"> { <!> } 
    21172117    } # end role 
    21182118 
    2119     role a { 
     2119    role a1 { 
    21202120        token escape:sym<@> { <?before '@'> [ :lang($+LANG) <variable> <extrapost> | <!> ] } # trap ABORTBRANCH from variable's :: 
    21212121    } # end role 
    21222122 
    2123     role _a { 
     2123    role a0 { 
    21242124        token escape:sym<@> { <!> } 
    21252125    } # end role 
    21262126 
    2127     role h { 
     2127    role h1 { 
    21282128        token escape:sym<%> { <?before '%'> [ :lang($+LANG) <variable> <extrapost> | <!> ] } 
    21292129    } # end role 
    21302130 
    2131     role _h { 
     2131    role h0 { 
    21322132        token escape:sym<%> { <!> } 
    21332133    } # end role 
    21342134 
    2135     role f { 
     2135    role f1 { 
    21362136        token escape:sym<&> { <?before '&'> [ :lang($+LANG) <variable> <extrapost> | <!> ] } 
    21372137    } # end role 
    21382138 
    2139     role _f { 
     2139    role f0 { 
    21402140        token escape:sym<&> { <!> } 
    21412141    } # end role 
    21422142 
    2143     role w { 
     2143    role w1 { 
    21442144        method postprocess ($s) { $s.comb } 
    21452145    } # end role 
    21462146 
    2147     role _w { 
     2147    role w0 { 
    21482148        method postprocess ($s) { $s } 
    21492149    } # end role 
    21502150 
    2151     role ww { 
     2151    role ww1 { 
    21522152        method postprocess ($s) { $s.comb } 
    21532153    } # end role 
    21542154 
    2155     role x { 
     2155    role ww0 { 
     2156        method postprocess ($s) { $s } 
     2157    } # end role 
     2158 
     2159    role x1 { 
    21562160        method postprocess ($s) { $s.run } 
    21572161    } # end role 
    21582162 
    2159     role _x { 
     2163    role x0 { 
    21602164        method postprocess ($s) { $s } 
    21612165    } # end role 
     
    21802184    } # end role 
    21812185 
    2182     role qq does b does c does s does a does h does f { 
     2186    role qq does b1 does c1 does s1 does a1 does h1 does f1 { 
    21832187        token stopper { \" } 
    21842188        # in double quotes, omit backslash on random \W backslash by default 
     
    22102214    multi method tweak (:double(:$qq)) { self.truly($qq, ':qq'); self.mixin( ::qq ); } 
    22112215 
    2212     multi method tweak (:backslash(:$b))   { self.mixin($b ?? ::b !! ::_b) } 
    2213     multi method tweak (:scalar(:$s))      { self.mixin($s ?? ::s !! ::_s) } 
    2214     multi method tweak (:array(:$a))       { self.mixin($a ?? ::a !! ::_a) } 
    2215     multi method tweak (:hash(:$h))        { self.mixin($h ?? ::h !! ::_h) } 
    2216     multi method tweak (:function(:$f))    { self.mixin($f ?? ::f !! ::_f) } 
    2217     multi method tweak (:closure(:$c))     { self.mixin($c ?? ::c !! ::_c) } 
    2218  
    2219     multi method tweak (:exec(:$x))        { self.mixin($x ?? ::x !! ::_x) } 
    2220     multi method tweak (:words(:$w))       { self.mixin($w ?? ::w !! ::_w) } 
    2221     multi method tweak (:quotewords(:$ww)) { self.mixin($ww ?? ::ww !! ::_ww) } 
     2216    multi method tweak (:backslash(:$b))   { self.mixin($b ?? ::b1 !! ::b0) } 
     2217    multi method tweak (:scalar(:$s))      { self.mixin($s ?? ::s1 !! ::s0) } 
     2218    multi method tweak (:array(:$a))       { self.mixin($a ?? ::a1 !! ::a0) } 
     2219    multi method tweak (:hash(:$h))        { self.mixin($h ?? ::h1 !! ::h0) } 
     2220    multi method tweak (:function(:$f))    { self.mixin($f ?? ::f1 !! ::f0) } 
     2221    multi method tweak (:closure(:$c))     { self.mixin($c ?? ::c1 !! ::c0) } 
     2222 
     2223    multi method tweak (:exec(:$x))        { self.mixin($x ?? ::x1 !! ::x0) } 
     2224    multi method tweak (:words(:$w))       { self.mixin($w ?? ::w1 !! ::w0) } 
     2225    multi method tweak (:quotewords(:$ww)) { self.mixin($ww ?? ::ww1 !! ::ww0) } 
    22222226 
    22232227    multi method tweak (:heredoc(:$to)) { self.truly($to, ':to'); self.cursor_herelang; } 
     
    28532857    <sym> 
    28542858    { $¢ = (self.<sigil>//'') eq '$'  
    2855         ?? Perl::Item_assignment.coerce($¢) 
    2856         !! Perl::List_assignment.coerce($¢); 
     2859        ?? STD::Item_assignment.coerce($¢) 
     2860        !! STD::List_assignment.coerce($¢); 
    28572861    } 
    28582862} 
     
    29252929 
    29262930# unrecognized identifiers are assumed to be post-declared listops. 
    2927 # (XXX for cheating purposes this rule must be the last term: rule) 
    2928 token term:name ( --> List_prefix) 
     2931token term:ident ( --> Term ) 
     2932{ 
     2933    <ident> 
     2934    [ 
     2935    | '.(' <semilist> [ ')' || <.panic: "Missing right parenthesis"> ] {*}                               #= func args 
     2936    | '(' <semilist> [ ')' || <.panic: "Missing right parenthesis"> ] {*}                                #= func args 
     2937    | <.unsp> '.'? '(' <semilist> [ ')' || <.panic: "Missing right parenthesis"> ] {*}                   #= func args 
     2938    ] 
     2939} 
     2940 
     2941token term:name ( --> Term) 
    29292942{ 
    29302943    <longname> :: 
     
    32393252################################################# 
    32403253 
    3241 grammar Regex is Perl { 
     3254grammar Regex is STD { 
    32423255 
    32433256    # begin tweaks (DO NOT ERASE) 
    3244     multi method tweak (:Perl5(:$P5)) { self.cursor_fresh( ::Perl::Q ).mixin( ::p5 ) } 
     3257    multi method tweak (:Perl5(:$P5)) { self.cursor_fresh( ::STD::Q ).mixin( ::p5 ) } 
    32453258    multi method tweak (:overlap(:$ov)) { self } 
    32463259    multi method tweak (:exhaustive(:$ex)) { self } 
     
    35363549        [ 
    35373550        | <name> 
    3538         | <before '['> <quibble($¢.cursor_fresh( ::Perl::Q ).tweak(:q))> # XXX parse as q[] for now 
     3551        | <before '['> <quibble($¢.cursor_fresh( ::STD::Q ).tweak(:q))> # XXX parse as q[] for now 
    35393552        ] 
    35403553    } 
  • src/perl6/gimme5

    r21605 r21646  
    4141our $NEEDORIGARGS; 
    4242our $PKG = "main"; 
    43 our $TOP = "Perl"; 
     43our $TOP = "STD"; 
    4444our @PKG = (); 
    4545our $ALTNAME; 
     
    256256END 
    257257 
    258         $out .= <<'END' if $TOP eq 'Perl'; 
     258        $out .= <<'END' if $TOP eq 'STD'; 
    259259    $self->_AUTOLEXpeek('termish',$retree); 
    260     system('cp lex/Perl/termish lex/Perl/EXPR'); 
     260    system('cp lex/STD/termish lex/STD/EXPR'); 
    261261END 
    262262 
  • src/perl6/try5

    r21274 r21646  
    4242        } 
    4343    } 
    44     #my $cmd = qq/perl -w -I . -MSTD5 -e 'print Perl::Dump(Perl->new(orig=>$input)->${rule}(["$rule"]));'/; 
     44    #my $cmd = qq/perl -w -I . -MSTD5 -e 'print STD::Dump(STD->new(orig=>$input)->${rule}(["$rule"]));'/; 
    4545    #warn "# ",$cmd,"\n"; 
    4646    #system "$cmd 2>try5.err"; 
     
    4848    require "STD.pmc"; 
    4949    my $err = "try5.err"; 
    50     my $perl = Perl->new($input); 
     50    my $perl = STD->new($input); 
    5151    if(!$perl->can($rule)) { die "\nERROR: Unknown rule: $rule\n"; } 
    5252    open(STDERR,">$err") or die; 
     
    5454    if($result) {  
    5555      print $result->dump(); 
    56 #      print Perl::Dump($result); 
     56#      print STD::Dump($result); 
    5757    } else { 
    5858      print "Parse failed.  See $err.\n"; 
  • src/perl6/tryfile

    r21464 r21646  
    1010my $what = 'comp_unit'; 
    1111my $text = Encode::decode('utf8', `cat $file`); 
    12 my $r = Perl->new($text)->$what(); 
     12my $r = STD->new($text)->$what(); 
    1313print Dump($r); 
  • t/spec/S02-literals/quoting.t

    r21547 r21646  
    504504    sub zeta {42}; 
    505505 
    506     is(qw(a b), <a b>, 'qw'); 
    507     is(qww($alpha $beta), <foo bar>, 'qww'); 
    508     is(qq($alpha $beta), 'foo bar', 'qq'); 
    509     is(Qs($alpha @delta[] %gamma<>), 'foo @delta %gamma', 'Qs'); 
    510     is(Qa($alpha @delta[] %gamma<>), '$alpha ' ~ @delta ~ ' %gamma', 'Qa'); 
    511     is(Qh($alpha @delta[] %gamma<>), '$alpha @delta ' ~ %gamma, 'Qh'); 
    512     is(Qf($alpha &zeta()), '$alpha 42', 'Qf'); 
    513     is(Qb($alpha\t$beta), '$alpha       $beta', 'Qb'); 
    514     is(Qc({1+1}), 2, 'Qc'); 
    515 } 
    516  
     506    is(qw[a b], <a b>, 'qw'); 
     507    is(qww[$alpha $beta], <foo bar>, 'qww'); 
     508    is(qq[$alpha $beta], 'foo bar', 'qq'); 
     509    is(Qs[$alpha @delta[] %gamma<>], 'foo @delta %gamma', 'Qs'); 
     510    is(Qa[$alpha @delta[] %gamma<>], '$alpha ' ~ @delta ~ ' %gamma', 'Qa'); 
     511    is(Qh[$alpha @delta[] %gamma<>], '$alpha @delta ' ~ %gamma, 'Qh'); 
     512    is(Qf[$alpha &zeta()], '$alpha 42', 'Qf'); 
     513    is(Qb[$alpha\t$beta], '$alpha       $beta', 'Qb'); 
     514    is(Qc[{1+1}], 2, 'Qc'); 
     515} 
     516