le $module.Instances ()
where
import $module
import Data.Yaml.Syck
import DrIFT.YAML
import DrIFT.JSON
import DrIFT.Perl5
import DrIFT.Perl6Class
import Control.Monad
import qualified Data.ByteString
are C<Pugs>, C<PIR>, C<GHC>, C<JS>, and various variants of PIL:
C<PIL1>, C<PIL1-Binary>, C<PIL1-JSON>, C<PIL1-Perl5> (and C<PIL2-...>).
Note that, as with C<-c>, C<BEGIN {...}> and C<CHECK {...}> b
=pod
PIL2-JSON Forth-like code emitter
by fglock
../../pugs -CPIL2-JSON -e ' say "hello "; say 1 + 1 ' | \
../../pugs pil2_json_emit_forth.pl
#! /usr/bin/forth
: &*END ;
"hello " &say
arator
}
# -- Main program
# this is the same for all languages
push @*INC, './';
require 'pil2_json_emit.pm';
# slurp stdin - xinming++
my $pil2 = ** $*IN.slurp;
my @b = tokenize( $pil2 );
# say
=pod
PIL2-JSON simple Perl 6 code emitter
by fglock
../../pugs -CPIL2-JSON -e ' say "hello" ' | \
../../pugs pil2_json_emit_p6.pl
use v6-alpha;
&*END () { }
(&say("hello"));
Other exa
mples:
../../pugs -Cpil2-json -e ' my Int $x; ($x~"a")( "a",1,$x,$x+1); { say 1 } ' | \
../../pugs pil2_json_emit_p6.pl
The code created by this example has syntax errors, but I'm not sure if
ngs are
really forbidden in p6:
../../pugs -Cpil2-json -e 'my ($x,$y)=(1,2); sub infix:<aaa>($a,$b){$a+1} 1 aaa 2;' | \
../../pugs pil2_json_emit_p6.pl
=cut
use v6-alpha;
# -- Language speci
=pod
PIL2-JSON simple Perl 6 code emitter
by fglock
../../pugs -CPIL2-JSON -e ' say "hello" ' | \
../../pugs pil2_json_emit_p6.pl
use v6-alpha;
&*END () { }
(&say("hello"));
Other exa
mples:
../../pugs -Cpil2-json -e ' my Int $x; ($x~"a")( "a",1,$x,$x+1); { say 1 } ' | \
../../pugs pil2_json_emit_p6.pl
The code created by this example has syntax errors, but I'm not sure if
ngs are
really forbidden in p6:
../../pugs -Cpil2-json -e 'my ($x,$y)=(1,2); sub infix:<aaa>($a,$b){$a+1} 1 aaa 2;' | \
../../pugs pil2_json_emit_p6.pl
=cut
use v6-alpha;
# -- Language speci
# PIL2-JSON simple tokenizer, parser, and code emitter
# ../../pugs -CPIL2-JSON -e ' say "hello" ' | ../../pugs pil2_json_emit.pl
use v6-alpha;
# tokenizer
my $tokens =
m:g:perl5 {(\"(?:\\\\|\\
"|.)*?\"|[\:\,\=\{\(\[\}\)\]]|\w+)};
# JSON parser
# outputs a p6 tree = Hash of Array|Hash|Scalar ...
sub parse (@start, $token, @end, @_ is rw) {
state %tok = (
token => sub (@_ is rw
=pod
PIL2-JSON Forth-like code emitter
by fglock
../../pugs -CPIL2-JSON -e ' say "hello "; say 1 + 1 ' | \
../../pugs pil2_json_emit_forth.pl
#! /usr/bin/forth
: &*END ;
"hello " &say
arator
}
# -- Main program
# this is the same for all languages
push @*INC, './';
require 'pil2_json_emit.pm';
# slurp stdin - xinming++
my $pil2 = ** $*IN.slurp;
my @b = tokenize( $pil2 );
# say
d
PIL2-JSON generic code emitter
by fglock
This is a non-runnable module - use 'pil2_json_emit_<language>.pl' instead
../../pugs -CPIL2-JSON -e ' say "hello" ' | \
../../pugs pil2_json_emit_p
kenize ( $s ) {
$s ~~ m:g:perl5 {(\"(?:\\\\|\\"|.)*?\"|[\:\,\=\{\(\[\}\)\]]|\w+)}; #"
}
# JSON parser - creates an Array [of Array]* of Str
sub parse (@start, $token, @end, @_ is rw) {
st
=pod
PIL2-JSON Parrot-like code emitter
by fglock
../../pugs -CPIL2-JSON -e ' say "hello "; say 1 + 1 ' | \
../../pugs pil2_json_emit_pir.pl
#! /usr/bin/parrot
... TODO
=cut
use v6-al
arator
}
# -- Main program
# this is the same for all languages
push @*INC, './';
require 'pil2_json_emit.pm';
# slurp stdin - xinming++
my $pil2 = ** $*IN.slurp;
my @b = tokenize( $pil2 );
# say
/../pugs -CPIL2-JSON -e ' say "hello" ' | ../../pugs pil2_tokenizer.pl
use v6-alpha;
# tokenizer
my $tokens =
m:g:perl5 {(\"(?:\\\\|\\"|.)*?\"|[\:\,\=\{\(\[\}\)\]]|\w+)};
# JSON parser
# outp