|
Revision 11293, 2.0 kB
(checked in by Darren_Duncan, 2 years ago)
|
|
replaced all 'use v6;' lines with 'use v6-alpha;' in 330 files (examples/, ext/, t/, t_disabled/) ... more remain to do
|
-
Property svn:mime-type set to
text/plain; charset=UTF-8
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | use v6-alpha; |
|---|
| 2 | |
|---|
| 3 | # Todo list: |
|---|
| 4 | # - There must be a cleaner way of presenting .perl without a leading \. |
|---|
| 5 | # - Need to implement :{e,E,d,D,h,r,l}. |
|---|
| 6 | |
|---|
| 7 | sub quit () { |
|---|
| 8 | say "Leaving interactive shell..."; |
|---|
| 9 | exit(0); |
|---|
| 10 | } |
|---|
| 11 | |
|---|
| 12 | # We'd like to not pollute the eval's environment with our vars ($line, etc.). |
|---|
| 13 | sub clean_eval ($___str) { eval $___str } |
|---|
| 14 | |
|---|
| 15 | say "Welcome to Pugs -- $?PUGS_VERSION"; |
|---|
| 16 | say "Type :h for help."; |
|---|
| 17 | |
|---|
| 18 | loop (;;) { |
|---|
| 19 | # XXX use :prompt |
|---|
| 20 | #my $line = =$*IN :prompt('pugs> '); |
|---|
| 21 | print "pugs> "; |
|---|
| 22 | my $line = =$*IN; |
|---|
| 23 | |
|---|
| 24 | # Quit and EOF. |
|---|
| 25 | quit() unless defined $line; |
|---|
| 26 | # Skip empty lines. |
|---|
| 27 | next if $line eq ""; |
|---|
| 28 | |
|---|
| 29 | given ($line) { |
|---|
| 30 | when rx:P5/^\:(.)/ { |
|---|
| 31 | given ($0) { |
|---|
| 32 | when "e" { |
|---|
| 33 | # XXX |
|---|
| 34 | } |
|---|
| 35 | when "E" { |
|---|
| 36 | # XXX |
|---|
| 37 | } |
|---|
| 38 | when "d" { |
|---|
| 39 | # XXX |
|---|
| 40 | } |
|---|
| 41 | when "D" { |
|---|
| 42 | # XXX |
|---|
| 43 | } |
|---|
| 44 | when "q" { |
|---|
| 45 | quit(); |
|---|
| 46 | } |
|---|
| 47 | when "h" { |
|---|
| 48 | # XXX |
|---|
| 49 | } |
|---|
| 50 | when "r" { |
|---|
| 51 | # XXX |
|---|
| 52 | } |
|---|
| 53 | when "l" { |
|---|
| 54 | # XXX |
|---|
| 55 | } |
|---|
| 56 | } |
|---|
| 57 | } |
|---|
| 58 | default { |
|---|
| 59 | # We need to .perl the result right here to make prettyprinting of |
|---|
| 60 | # junctions work. |
|---|
| 61 | my $ret = clean_eval $line; |
|---|
| 62 | say chomp $! and next if $!; |
|---|
| 63 | |
|---|
| 64 | # We've to .perl in a second pass (and in a try {...} block) to |
|---|
| 65 | # catch "fail_"s. |
|---|
| 66 | $ret = try { $ret.perl }; |
|---|
| 67 | say chomp $! and next if $!; |
|---|
| 68 | say substr($ret, 0, 1) eq "\\" ?? substr($ret, 1) !! $ret; # XXX NASTY HACK |
|---|
| 69 | #" #--vim |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | quit(); |
|---|
| 75 | |
|---|
| 76 | =head1 NAME |
|---|
| 77 | |
|---|
| 78 | eval.pl - simple read-eval-print loop implementation |
|---|
| 79 | |
|---|
| 80 | =head1 DESCRIPTION |
|---|
| 81 | |
|---|
| 82 | This simplistic program will keep reading from standard input and evaluating whatever is |
|---|
| 83 | typed. |
|---|