This repository has been archived by the owner on Jun 9, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a29ef43
Showing
15 changed files
with
1,057 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Makefile | ||
|
||
*.pbc | ||
gen_*.pir | ||
|
||
*.xml | ||
*.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Copyright (C) 2009, Parrot Foundation. | ||
|
||
=head1 NAME | ||
Configure.pl - a configure script for a high level language running on Parrot | ||
=head1 SYNOPSIS | ||
perl Configure.pl --help | ||
perl Configure.pl | ||
perl Configure.pl --parrot_config=<path_to_parrot> | ||
=cut | ||
|
||
use strict; | ||
use warnings; | ||
use 5.008; | ||
|
||
use Getopt::Long qw(:config auto_help); | ||
|
||
our ( $opt_parrot_config ); | ||
GetOptions( 'parrot_config=s' ); | ||
|
||
# Get a list of parrot-configs to invoke. | ||
my @parrot_config_exe = $opt_parrot_config | ||
? ( $opt_parrot_config ) | ||
: ( | ||
'parrot/parrot_config', | ||
'../../parrot_config', | ||
'parrot_config', | ||
); | ||
|
||
# Get configuration information from parrot_config | ||
my %config = read_parrot_config(@parrot_config_exe); | ||
unless (%config) { | ||
die "Unable to locate parrot_config."; | ||
} | ||
|
||
# Create the Makefile using the information we just got | ||
create_makefiles(%config); | ||
|
||
sub read_parrot_config { | ||
my @parrot_config_exe = @_; | ||
my %config = (); | ||
for my $exe (@parrot_config_exe) { | ||
no warnings; | ||
if (open my $PARROT_CONFIG, '-|', "$exe --dump") { | ||
print "Reading configuration information from $exe\n"; | ||
while (<$PARROT_CONFIG>) { | ||
$config{$1} = $2 if (/(\w+) => '(.*)'/); | ||
} | ||
close $PARROT_CONFIG; | ||
last if %config; | ||
} | ||
} | ||
%config; | ||
} | ||
|
||
|
||
# Generate Makefiles from a configuration | ||
sub create_makefiles { | ||
my %config = @_; | ||
my %makefiles = ( | ||
'build/Makefile.in' => 'Makefile', | ||
# 'build/src/pmc/Makefile.in' => 'src/pmc/Makefile', | ||
# 'build/src/ops/Makefile.in' => 'src/ops/Makefile', | ||
); | ||
my $build_tool = $config{libdir} . $config{versiondir} | ||
. '/tools/dev/gen_makefile.pl'; | ||
|
||
foreach my $template (keys %makefiles) { | ||
my $makefile = $makefiles{$template}; | ||
print "Creating $makefile\n"; | ||
system($config{perl}, $build_tool, $template, $makefile); | ||
} | ||
} | ||
|
||
# Local Variables: | ||
# mode: cperl | ||
# cperl-indent-level: 4 | ||
# fill-column: 100 | ||
# End: | ||
# vim: expandtab shiftwidth=4: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
XML on Parrot | ||
============= | ||
|
||
This module contains : | ||
* a SAX like parser | ||
* a simple handler XmlWriter | ||
|
||
There are toys, but there demonstrate the power of PCT, | ||
the Parrot Compiler Toolkit. | ||
|
||
But PCT is not handly for packaging & deployment. | ||
|
||
Now, XML modules could easy implemented with Perl 6, | ||
because with PCT, most of the code is already Perl 6. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# Copyright (C) 2009, Parrot Foundation. | ||
|
||
## arguments we want to run parrot with | ||
PARROT_ARGS := | ||
|
||
## configuration settings | ||
VERSION := @versiondir@ | ||
BIN_DIR := @bindir@ | ||
LIB_DIR := @libdir@$(VERSION) | ||
DOC_DIR := @doc_dir@$(VERSION) | ||
MANDIR := @mandir@$(VERSION) | ||
|
||
# Various paths | ||
PERL6GRAMMAR := $(LIB_DIR)/library/PGE/Perl6Grammar.pbc | ||
NQP := $(LIB_DIR)/languages/nqp/nqp.pbc | ||
PCT := $(LIB_DIR)/library/PCT.pbc | ||
|
||
## Setup some commands | ||
MAKE := @make_c@ | ||
PERL := @perl@ | ||
CAT := @cat@ | ||
CHMOD := @chmod@ | ||
CP := @cp@ | ||
MKPATH := @mkpath@ | ||
RM_F := @rm_f@ | ||
RM_RF := @rm_rf@ | ||
POD2MAN := pod2man | ||
#IF(parrot_is_shared and not(cygwin or win32)):export LD_RUN_PATH := @blib_dir@:$(LD_RUN_PATH) | ||
PARROT := $(BIN_DIR)/parrot@exe@ | ||
#IF(darwin): | ||
#IF(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking | ||
#IF(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@ | ||
|
||
SAX_XML_SOURCES := \ | ||
sax/xml/gen_grammar.pir \ | ||
sax/xml/gen_actions.pir \ | ||
sax/xml/gen_builtins.pir \ | ||
sax/xml/xml.pir | ||
|
||
SAX_XML_BUILTINS_PIR := \ | ||
sax/xml/builtins/fire.pir | ||
|
||
HANDLER_XMLWRITER_SOURCES := \ | ||
handler/xmlwriter/gen_actions.pir \ | ||
handler/xmlwriter/gen_builtins.pir \ | ||
handler/xmlwriter/xmlwriter.pir | ||
|
||
HANDLER_XMLWRITER_BUILTINS_PIR := \ | ||
handler/xmlwriter/builtins/print.pir | ||
|
||
DOCS := README | ||
|
||
BUILD_CLEANUPS := \ | ||
"sax/xml/*.pbc" \ | ||
"sax/xml/gen_*.pir" \ | ||
"handler/xmlwriter/*.pbc" \ | ||
"handler/xmlwriter/gen_*.pir" \ | ||
#IF(win32): parrot-xml.iss \ | ||
#IF(win32): "setup-parrot-*.exe" \ | ||
TEST_CLEANUPS := \ | ||
"t/*.xml" \ | ||
"t/*.out" | ||
|
||
# the default target | ||
build: xml.pbc sax/xml/xml.pbc handler/xmlwriter/xmlwriter.pbc | ||
|
||
all: build | ||
|
||
xml.pbc: xml.pir | ||
$(PARROT) $(PARROT_ARGS) -o xml.pbc xml.pir | ||
|
||
sax/xml/xml.pbc: $(SAX_XML_SOURCES) | ||
$(PARROT) $(PARROT_ARGS) -o sax/xml/xml.pbc sax/xml/xml.pir | ||
|
||
sax/xml/gen_grammar.pir: $(PERL6GRAMMAR) sax/xml/pct/grammar.pg | ||
$(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \ | ||
--output=sax/xml/gen_grammar.pir \ | ||
sax/xml/pct/grammar.pg | ||
|
||
sax/xml/gen_actions.pir: $(NQP) sax/xml/pct/actions.pm | ||
$(PARROT) $(PARROT_ARGS) $(NQP) --output=sax/xml/gen_actions.pir \ | ||
--target=pir sax/xml/pct/actions.pm | ||
|
||
sax/xml/gen_builtins.pir: $(SAX_XML_BUILTINS_PIR) | ||
$(CAT) $(SAX_XML_BUILTINS_PIR) > sax/xml/gen_builtins.pir | ||
|
||
handler/xmlwriter/xmlwriter.pbc: $(HANDLER_XMLWRITER_SOURCES) | ||
$(PARROT) $(PARROT_ARGS) -o handler/xmlwriter/xmlwriter.pbc handler/xmlwriter/xmlwriter.pir | ||
|
||
handler/xmlwriter/gen_actions.pir: $(NQP) handler/xmlwriter/pct/actions.pm | ||
$(PARROT) $(PARROT_ARGS) $(NQP) --output=handler/xmlwriter/gen_actions.pir \ | ||
--target=pir handler/xmlwriter/pct/actions.pm | ||
|
||
handler/xmlwriter/gen_builtins.pir: $(HANDLER_XMLWRITER_BUILTINS_PIR) | ||
$(CAT) $(HANDLER_XMLWRITER_BUILTINS_PIR) > handler/xmlwriter/gen_builtins.pir | ||
|
||
Makefile: build/Makefile.in | ||
$(PERL) Configure.pl | ||
|
||
# This is a listing of all targets, that are meant to be called by users | ||
help: | ||
@echo "" | ||
@echo "Following targets are available for the user:" | ||
@echo "" | ||
@echo " build: xml.pbc xmlwriter.pbc" | ||
@echo " This is the default." | ||
@echo " all: xml.pbc xmlwriter.pbc" | ||
@echo "" | ||
@echo "Testing:" | ||
@echo " test: Run the test suite." | ||
@echo " testclean: Clean up test results." | ||
@echo "" | ||
@echo "Cleaning:" | ||
@echo " clean: Basic cleaning up." | ||
@echo " realclean: Removes also files generated by 'Configure.pl'" | ||
@echo " distclean: Removes also anything built, in theory" | ||
@echo "" | ||
@echo "Misc:" | ||
@echo " help: Print this help message." | ||
@echo "" | ||
|
||
test: build | ||
$(PERL) -I$(LIB_DIR)/tools/lib t/harness | ||
|
||
install: | ||
-$(MKPATH) $(LIB_DIR)/languages/xml | ||
$(CP) xml.pbc $(LIB_DIR)/languages/xml/xml.pbc | ||
|
||
uninstall: | ||
$(RM_RF) $(LIB_DIR)/languages/xml | ||
|
||
testclean: | ||
$(RM_F) $(TEST_CLEANUPS) | ||
|
||
clean: | ||
$(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS) | ||
|
||
realclean: | ||
$(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS) Makefile | ||
|
||
distclean: realclean | ||
|
||
# Local variables: | ||
# mode: makefile | ||
# End: | ||
# vim: ft=make: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (C) 2009, Parrot Foundation. | ||
|
||
.namespace [] | ||
|
||
.sub 'print' | ||
.param pmc args :slurpy | ||
.local pmc stream | ||
stream = get_global 'Stream' | ||
.local pmc iter | ||
iter = new 'Iterator', args | ||
iter_loop: | ||
unless iter goto iter_end | ||
$P0 = shift iter | ||
stream.'print'($P0) | ||
goto iter_loop | ||
iter_end: | ||
.return () | ||
.end | ||
|
||
# Local Variables: | ||
# mode: pir | ||
# fill-column: 100 | ||
# End: | ||
# vim: expandtab shiftwidth=4 ft=pir: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright (C) 2009, Parrot Foundation. | ||
|
||
class Xml::Handler::XmlWriter; | ||
|
||
method start_document() { | ||
} | ||
|
||
method end_document() { | ||
} | ||
|
||
method characters( :$Data ) { | ||
print( $Data ); | ||
} | ||
|
||
method comment( :$Data ) { | ||
print( '<!--', $Data, '-->' ); | ||
} | ||
|
||
method processing_instruction( :$Target, :$Data ) { | ||
print( '<?', $Target ); | ||
if ?$Data { | ||
print( ' ', $Data ); | ||
} | ||
print( '?>' ); | ||
} | ||
|
||
method start_cdata() { | ||
} | ||
|
||
method end_cdata() { | ||
} | ||
|
||
method xml_decl( :$Version, :$Encoding, :$Standalone ) { | ||
print( "xml_decl", " ", $Version, " ", $Encoding, " ", $Standalone ); | ||
print( '<?xml version="', $Version, '"' ); | ||
if ?$Encoding { | ||
print( ' encoding="', $Encoding, '"' ); | ||
} | ||
if ?$Standalone { | ||
print( ' standalone="', $Standalone, '"' ); | ||
} | ||
print( '?>' ) | ||
} | ||
|
||
method start_element( :$Name, :$Attributes ) { | ||
print( '<', $Name ); | ||
print( '>' ); | ||
} | ||
|
||
method end_element( :$Name ) { | ||
print( '</', $Name, '>' ); | ||
} | ||
|
||
method entity_reference( :$Name, :$Value ) { | ||
print( '&', $Name, ';' ); | ||
} | ||
|
||
# Local Variables: | ||
# mode: cperl | ||
# cperl-indent-level: 4 | ||
# fill-column: 100 | ||
# End: | ||
# vim: expandtab shiftwidth=4: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (C) 2009, Parrot Foundation. | ||
|
||
.namespace [ 'Xml::Handler::XmlWriter' ] | ||
|
||
.include 'handler/xmlwriter/gen_builtins.pir' | ||
.include 'handler/xmlwriter/gen_actions.pir' | ||
|
||
# Local Variables: | ||
# mode: pir | ||
# fill-column: 100 | ||
# End: | ||
# vim: expandtab shiftwidth=4 ft=pir: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (C) 2009, Parrot Foundation. | ||
|
||
.namespace [] | ||
|
||
.sub 'fire' | ||
.param string event | ||
.param pmc args :slurpy :named | ||
$P0 = get_global 'Handler' | ||
$P1 = find_method $P0, event | ||
$P1($P0, args :named :flat) | ||
.return () | ||
.end | ||
|
||
# Local Variables: | ||
# mode: pir | ||
# fill-column: 100 | ||
# End: | ||
# vim: expandtab shiftwidth=4 ft=pir: | ||
|
Oops, something went wrong.