Legend:
- Unmodified
- Added
- Removed
-
src/perl6/Cursor.pmc
r21784 r21789 16 16 $::COMPILING::LINE = 1; 17 17 $::COMPILING::FILE = '(eval)'; 18 $::GOAL = "(eof)"; 18 19 19 20 { package DEBUG; … … 624 625 no strict 'refs'; 625 626 if ($DEBUG & DEBUG::fates or ($DEBUG & DEBUG::lexer and $x == $last)) { 626 my $p = $pats[$x ] // '<nopat>';627 my $p = $pats[$x-1] // '<nopat>'; 627 628 $self->deb("\$$x: $beg..$end\t$$x\t ", 628 629 $x == $last ? "====>" : "---->", -
src/perl6/STD.pm
r21784 r21789 5 5 my $PKG is context = ""; 6 6 my @PKGS; 7 my $GOAL is context = "(eof)"; 7 8 8 9 # random rule for debugging, please ignore … … 60 61 method TOP ($STOP = undef) { 61 62 if defined $STOP { 63 my $GOAL is context = $STOP; 62 64 self.unitstop($STOP).comp_unit; 63 65 } … … 458 460 } 459 461 460 461 462 token lambda { '->' | '<->' } 462 463 464 # Look for an expression followed by a required lambda. 465 token xblock { 466 :my $GOAL is context = '{'; 467 <EXPR> 468 <.ws> 469 <pblock> 470 } 463 471 464 472 token block { … … 477 485 token regex_block { 478 486 :my $lang = ::Regex; 487 :my $GOAL is context = '}'; 479 488 480 489 [ <quotepair> <.ws> … … 587 596 rule statement_control:if {\ 588 597 <sym> 589 <EXPR> {*} #= if expr 590 <pblock> {*} #= if block 591 $<elsif> = ( 'elsif'<?spacey> <EXPR> {*} #= elsif expr 592 <pblock> {*} )* #= elsif block 593 $<else> = ( 'else'<?spacey> <pblock> {*} )? #= else 598 <xblock> 599 $<elsif> = ( 600 'elsif'<?spacey> <xblock> {*} #= elsif 601 )* 602 $<else> = ( 603 'else'<?spacey> <pblock> {*} #= else 604 )? 594 605 } 595 606 … … 597 608 rule statement_control:unless {\ 598 609 <sym> 599 <EXPR> {*} #= expr 600 <pblock> {*} #= block 610 <xblock> 601 611 [ <!before 'else'> || <.panic: "unless does not take \"else\" in Perl 6; please rewrite using \"if\""> ] 602 612 } … … 607 617 [ <?before '(' ['my'? '$'\w+ '=']? '<' '$'?\w+ '>' ')'> #' 608 618 <.panic: "This appears to be Perl 5 code"> ]? 609 <EXPR> {*} #= expr 610 <pblock> {*} #= block 619 <xblock> 611 620 } 612 621 … … 614 623 rule statement_control:until {\ 615 624 <sym> 616 <EXPR> {*} #= expr 617 <pblock> {*} #= block 625 <xblock> 618 626 } 619 627 … … 647 655 [ <?before 'my'? '$'\w+ '(' > 648 656 <.panic: "This appears to be Perl 5 code"> ]? 649 <EXPR> {*} #= expr 650 <pblock> {*} #= block 651 } 652 657 <xblock> 658 } 653 659 654 660 rule statement_control:given {\ 655 661 <sym> 656 <EXPR> {*} #= expr 657 <pblock> {*} #= block 662 <xblock> 658 663 } 659 664 rule statement_control:when {\ 660 665 <sym> 661 <EXPR> {*} #= expr 662 <pblock> {*} #= block 666 <xblock> 663 667 } 664 668 rule statement_control:default {<sym> <block> } … … 1502 1506 [ 1503 1507 | <ident> 1504 | '(' :: < EXPR> [ ')' || <.panic: "Unable to parse indirect name; couldn't find right parenthesis"> ]1508 | '(' :: <in: ')', 'EXPR', 'indirect name'> 1505 1509 ] 1506 1510 } … … 2413 2417 2414 2418 token named_param { 2419 :my $GOAL is context = ')'; 2415 2420 ':' 2416 2421 [ … … 2432 2437 <?{ $<sigil>.text eq '@' || $<sigil>.text eq '%' }> 2433 2438 <ident>? 2434 <.ws>2435 2439 <?before <[ \< \( \[ \{ ]> > 2436 2440 <postcircumfix> … … 2525 2529 ## term 2526 2530 token term:sym<undef> ( --> Term) { 2527 <sym> » \h*2528 [ <?before '$/' >2531 <sym> » 2532 [ <?before \h*'$/' > 2529 2533 <obs('$/ variable as input record separator', 2530 2534 "the filehandle's .slurp method")> 2531 2535 ]? 2532 [ <?before < $ @ % & > >2536 [ <?before \h*< $ @ % & > > 2533 2537 <obs('undef as a verb', 'undefine function')> 2534 2538 ]? 2535 2539 } 2540 2541 token term:sym<next> ( --> Term) 2542 { <sym> » <.ws> <termish>? } 2543 2544 token term:sym<last> ( --> Term) 2545 { <sym> » <.ws> <termish>? } 2546 2547 token term:sym<redo> ( --> Term) 2548 { <sym> » <.ws> <termish>? } 2549 2550 token term:sym<goto> ( --> Term) 2551 { <sym> » <.ws> <termish> } 2536 2552 2537 2553 token term:sym<self> ( --> Term) … … 2877 2893 ## conditional 2878 2894 token infix:sym<?? !!> ( --> Conditional) { 2895 :my $GOAL is context = '!!'; 2879 2896 '??' 2880 2897 <.ws> … … 2894 2911 { <sym> <obs('?: for the conditional operator', '??!!')> } 2895 2912 2896 2897 2913 ## assignment 2898 2914 # There is no "--> type" because assignment may be coerced to either … … 2950 2966 { <sym> } 2951 2967 2952 token prefix:sym<...> ( --> List_prefix) 2953 { 2954 '...' 2955 } 2956 2957 token prefix:sym<???> ( --> List_prefix) 2958 { 2959 '???' 2960 } 2961 2962 token prefix:sym<!!!> ( --> List_prefix) 2963 { 2964 '!!!' 2965 } 2968 token term:sym<...> ( --> List_prefix) 2969 { <sym> <args>? } 2970 2971 token term:sym<???> ( --> List_prefix) 2972 { <sym> <args>? } 2973 2974 token term:sym<!!!> ( --> List_prefix) 2975 { <sym> <args>? } 2966 2976 2967 2977 token term:sigil ( --> List_prefix) … … 2977 2987 token term:ident ( --> Term ) 2978 2988 { 2979 <ident> 2989 :my $i; 2990 $i = <ident> <args( $¢.is_type($i.text) )> 2991 } 2992 2993 token term:opfunc ( --> Term ) 2994 { 2995 <category> <colonpair>+ <args> 2996 } 2997 2998 token args ($istype = 0) { 2999 :my $listopy = 0; 2980 3000 [ 2981 3001 | '.(' <in: ')', 'semilist', 'argument list'> {*} #= func args 2982 3002 | '(' <in: ')', 'semilist', 'argument list'> {*} #= func args 2983 3003 | <.unsp> '.'? '(' <in: ')', 'semilist', 'argument list'> {*} #= func args 2984 ] 2985 2986 [ 3004 | :: [<?before \s> <!{ $istype }> <.ws> <!infixstopper> <arglist>]? { $listopy = 1 } 3005 ] 3006 3007 [ 3008 || <?{ $listopy }> 2987 3009 || ':' <?before \s> <arglist> # either switch to listopiness 2988 || {{ $+prevop = $<O> = {}; }} # or allow adverbs 3010 || {{ $+prevop = $<O> = {}; }} # or allow adverbs (XXX needs hoisting?) 2989 3011 ] 2990 3012 } … … 3009 3031 3010 3032 # unrecognized names are assumed to be post-declared listops. 3011 || <?before \s> <arglist> 3012 {*} #= listop args 3013 || 3014 [ 3015 | '.(' <in: ')', 'semilist', 'argument list'> 3016 {*} #= func args 3017 3018 | '(' <in: ')', 'semilist', 'argument list'> 3019 {*} #= func args 3020 3021 | <.unsp> '.'? '(' <in: ')', 'semilist', 'argument list'> 3022 {*} #= func args 3023 3024 3025 | :: {*} #= listop noarg 3026 ] 3027 3028 [ 3029 || ':' <?before \s> <arglist> # either switch to listopiness 3030 || {{ $+prevop = $<O> = {}; }} # or allow adverbs 3031 ] 3033 || <args>? 3034 # || <?before \s> <arglist> 3035 # {*} #= listop args 3036 # || 3037 # [ 3038 # | '.(' <in: ')', 'semilist', 'argument list'> 3039 # {*} #= func args 3040 # 3041 # | '(' <in: ')', 'semilist', 'argument list'> 3042 # {*} #= func args 3043 # 3044 # | <.unsp> '.'? '(' <in: ')', 'semilist', 'argument list'> 3045 # {*} #= func args 3046 # 3047 # 3048 # | :: {*} #= listop noarg 3049 # ] 3050 # 3051 # [ 3052 # || ':' <?before \s> <arglist> # either switch to listopiness 3053 # || {{ $+prevop = $<O> = {}; }} # or allow adverbs 3054 # ] 3032 3055 ] 3033 3056 } … … 3101 3124 3102 3125 token terminator:sym<!!> ( --> Terminator) 3103 { <?before '!!' > }3126 { <?before '!!' > <?{ $+GOAL eq '!!' }> } 3104 3127 3105 3128 regex infixstopper { 3106 3129 | <?before <stopper> > 3107 | <?before '{' | <lambda> > <?{ $¢.<_>[$¢.pos]<ws> }> 3130 | <?before '!!' > <?{ $+GOAL eq '!!' }> 3131 | <?before '{' | <lambda> > <?{ $+GOAL eq '{' and $¢.<_>[$¢.pos]<ws> }> 3108 3132 } 3109 3133 … … 3376 3400 # suppress fancy end-of-line checking 3377 3401 token codeblock { 3402 :my $GOAL is context = '}'; 3378 3403 '{' :: [ :lang($¢.cursor_fresh($+LANG)) <statementlist> ] 3379 3404 [ '}' || <.panic: "Unable to parse statement list; couldn't find right brace"> ] … … 3719 3744 } 3720 3745 3746 # not quite a "between" combinator... 3721 3747 token in (Str $stop, Str $insides, Str $name = $insides) { 3748 :my $GOAL is context = $stop; 3722 3749 <x=$insides> $stop {{ $/.{$insides} = $<x>; delete $<x> }} || <.panic: "Unable to parse $name; couldn't find final '$stop'"> 3723 3750 } -
src/perl6/gimme5
r21743 r21789 1579 1579 my $var = $$self{var}; 1580 1580 my $re = $$self{atom}->walk(@_); 1581 " bindvar($var,$re)"; # doesn't do "let" semantics yet1581 "($var = $re)"; # doesn't do "let" semantics yet 1582 1582 } 1583 1583 }
