Author: particle
Date: Thu Jan 31 14:23:39 2008
New Revision: 25389
Added:
trunk/languages/perl6/config/makefiles/utils.in
trunk/languages/perl6/src/utils/ (props changed)
trunk/languages/perl6/src/utils/perl6doc/ (props changed)
trunk/languages/perl6/src/utils/perl6doc.pir
trunk/languages/perl6/src/utils/perl6doc/actions.pm
trunk/languages/perl6/src/utils/perl6doc/grammar.pg
Modified:
trunk/MANIFEST
trunk/MANIFEST.SKIP
trunk/config/gen/languages.pm
trunk/languages/perl6/config/makefiles/root.in
Log:
[rakudo] added perl6doc
this is a working partial implementation of perl6doc,
intended as a beginning for anyone who wants to hack the pod grammar
svn up && cd languages/perl6 && make Makefile && cd src/utils && make
perl6doc(.exe)?
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Thu Jan 31 14:23:39 2008
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools\dev\mk_manifest_and_skip.pl Wed Jan 30 12:30:30 2008 UT
+# generated by C:\usr\local\parrot\trunk\tools\dev\mk_manifest_and_skip.pl Wed
Jan 30 21:47:12 2008 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -1780,6 +1780,7 @@
languages/perl6/ROADMAP [perl6]
languages/perl6/Test.pm [perl6]
languages/perl6/config/makefiles/root.in [perl6]
+languages/perl6/config/makefiles/utils.in [perl6]
languages/perl6/docs/STATUS [perl6]
languages/perl6/docs/compiler_overview.pod [perl6]
languages/perl6/docs/glossary.pod [perl6]
@@ -1815,6 +1816,9 @@
languages/perl6/src/pmc/perl6bool.pmc [perl6]
languages/perl6/src/pmc/perl6str.pmc [perl6]
languages/perl6/src/pmc/perl6undef.pmc [perl6]
+languages/perl6/src/utils/perl6doc.pir [perl6]
+languages/perl6/src/utils/perl6doc/actions.pm [perl6]
+languages/perl6/src/utils/perl6doc/grammar.pg [perl6]
languages/perl6/t/00-parrot/01-literals.t [perl6]
languages/perl6/t/00-parrot/02-op-math.t [perl6]
languages/perl6/t/00-parrot/03-op-logic.t [perl6]
Modified: trunk/MANIFEST.SKIP
==============================================================================
--- trunk/MANIFEST.SKIP (original)
+++ trunk/MANIFEST.SKIP Thu Jan 31 14:23:39 2008
@@ -1,6 +1,6 @@
# ex: set ro:
# $Id$
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Jan 31 00:29:35 2008 UT
+# generated by C:\usr\local\parrot\trunk\tools\dev\mk_manifest_and_skip.pl Thu
Jan 31 22:10:51 2008 UT
#
# This file should contain a transcript of the svn:ignore properties
# of the directories in the Parrot subversion repository. (Needed for
@@ -974,6 +974,12 @@
^languages/perl6/src/pmc/.*\.pdb/
^languages/perl6/src/pmc/.*\.so$
^languages/perl6/src/pmc/.*\.so/
+# generated from svn:ignore of 'languages/perl6/src/utils/'
+^languages/perl6/src/utils/Makefile$
+^languages/perl6/src/utils/Makefile/
+# generated from svn:ignore of 'languages/perl6/src/utils/perl6doc/'
+^languages/perl6/src/utils/perl6doc/gen_.*\.pir$
+^languages/perl6/src/utils/perl6doc/gen_.*\.pir/
# generated from svn:ignore of 'languages/perl6/t/'
^languages/perl6/t/spec$
^languages/perl6/t/spec/
Modified: trunk/config/gen/languages.pm
==============================================================================
--- trunk/config/gen/languages.pm (original)
+++ trunk/config/gen/languages.pm Thu Jan 31 14:23:39 2008
@@ -81,6 +81,10 @@
expand_gmake_syntax => 1,
);
}
+ elsif ( $language eq 'perl6' ) {
+ $conf->genfile("$langdir/config/makefiles/root.in" =>
"$langdir/Makefile");
+ $conf->genfile("$langdir/config/makefiles/utils.in" =>
"$langdir/src/utils/Makefile");
+ }
else {
$conf->genfile("$langdir/config/makefiles/root.in" =>
"$langdir/Makefile"
);
Modified: trunk/languages/perl6/config/makefiles/root.in
==============================================================================
--- trunk/languages/perl6/config/makefiles/root.in (original)
+++ trunk/languages/perl6/config/makefiles/root.in Thu Jan 31 14:23:39 2008
@@ -97,7 +97,7 @@
cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT)
$(PMCS)
# regenerate the Makefile
-Makefile: config/makefiles/root.in
+Makefile: config/makefiles/root.in config/makefiles/utils.in
cd $(BUILD_DIR) && $(RECONFIGURE) --step=gen::languages
--languages=perl6
# This is a listing of all targets, that are meant to be called by users
Added: trunk/languages/perl6/config/makefiles/utils.in
==============================================================================
--- (empty file)
+++ trunk/languages/perl6/config/makefiles/utils.in Thu Jan 31 14:23:39 2008
@@ -0,0 +1,99 @@
+# $Id$
+
+## arguments we want to run parrot with
+PARROT_ARGS =
+
+## configuration settings
+BUILD_DIR = @build_dir@
+LOAD_EXT = @load_ext@
+O = @o@
+
+## Setup some commands
+LN_S = @lns@
+PERL = @perl@
+RM_RF = @rm_rf@
+CP = @cp@
+MAKE = @make_c@
+PARROT = ../../../../[EMAIL PROTECTED]@
+CAT = $(PERL) -MExtUtils::Command -e cat
+BUILD_DYNPMC = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
+RECONFIGURE = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl
+
+## places to look for things
+PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext
+PGE_LIBRARY = $(BUILD_DIR)/runtime/parrot/library/PGE
+PERL6GRAMMAR = $(PGE_LIBRARY)/Perl6Grammar.pbc
+NQP = $(BUILD_DIR)/compilers/nqp/nqp.pbc
+PCT = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc
+PBC_TO_EXE = $(BUILD_DIR)/[EMAIL PROTECTED]@
+
+
+all: perl6doc.pbc
+
+PERL6DOC_SOURCES = \
+ perl6doc.pir \
+ perl6doc/gen_grammar.pir \
+ perl6doc/gen_actions.pir \
+
+
[EMAIL PROTECTED]@: perl6doc.pbc
+ $(PBC_TO_EXE) perl6doc.pbc
+
+perl6doc.pbc: $(PARROT) $(PERL6DOC_SOURCES)
+ $(PARROT) $(PARROT_ARGS) -o perl6doc.pbc perl6doc.pir
+
+perl6doc/gen_grammar.pir: $(PERL6GRAMMAR) perl6doc/grammar.pg
+ $(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
+ --output=perl6doc/gen_grammar.pir \
+ perl6doc/grammar.pg
+
+perl6doc/gen_actions.pir: $(NQP) $(PCT) perl6doc/actions.pm
+ $(PARROT) $(PARROT_ARGS) $(NQP) --output=perl6doc/gen_actions.pir \
+ --target=pir perl6doc/actions.pm
+
+
+# regenerate the Makefile
+Makefile: ../../config/makefiles/root.in ../../config/makefiles/utils.in
+ cd $(BUILD_DIR) && $(RECONFIGURE) --step=gen::languages
--languages=perl6
+
+# 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 " all: perl6doc.pbc"
+ @echo " This is the default."
+ @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: all
+ $(PERL) t/harness t/01-sanity
+
+# this target has nothing to do
+testclean:
+
+CLEANUPS = \
+ perl6doc.pbc \
+ [EMAIL PROTECTED]@ \
+ perl6doc.c \
+ perl6doc/gen_grammar.pir \
+ perl6doc/gen_actions.pir \
+
+
+clean:
+ $(RM_RF) $(CLEANUPS)
+
+realclean: clean
+ $(RM_RF) Makefile
+
+distclean: realclean
Added: trunk/languages/perl6/src/utils/perl6doc.pir
==============================================================================
--- (empty file)
+++ trunk/languages/perl6/src/utils/perl6doc.pir Thu Jan 31 14:23:39 2008
@@ -0,0 +1,130 @@
+=head1 TITLE
+
+perl6doc.pir - The Rakudo Perl 6 document reader.
+
+=head2 Description
+
+This is the base file for the Rakudo Perl 6 document reader, C<perl6doc>.
+
+This file includes the parsing and grammar rules from
+the perl6doc/ directory, loads the relevant PGE libraries,
+and registers the compiler under the name 'Perl6doc'.
+
+=head2 Functions
+
+=over 4
+
+=item onload()
+
+Creates the Perl 6 document reader by subclassing a C<PCT::HLLCompiler> object.
+
+=cut
+
+
+.namespace [ 'Perl6doc' ]
+
+.sub 'onload' :load :init :anon
+ load_bytecode 'PCT.pbc'
+ load_bytecode 'Protoobject.pbc'
+
+ $P0 = get_hll_global 'Protomaker'
+ $P1 = get_class ['PCT::HLLCompiler']
+ $P0.'new_subclass'($P1, 'Perl6doc')
+.end
+
+
+.sub 'init' :vtable :method
+ load_bytecode 'config.pbc'
+
+ self.'language'('Perl6doc')
+ self.'parsegrammar'('Perl6doc::Grammar')
+ self.'parseactions'('Perl6doc::Grammar::Actions')
+
+ ## set the compilation stages in the @stages attribute
+ $P0 = split ' ', 'parse past post pir evalpmc'
+ setattribute self, '@stages', $P0
+
+ ## set the command line options
+ $P0 = split ' ', 'help|h target=s trace|t=s version|V'
+ setattribute self, '@cmdoptions', $P0
+
+ ## set the $usage attribute
+ $P0 = new 'String'
+ $P0 = <<'USAGE'
+Usage: perl6 [switches] [--] [programfile] [arguments]
+ -h, --help display this help text
+ --target=[stage] specify compilation stage to emit
+ -t, --trace=[flags] enable trace flags
+ -V, --version display version information
+USAGE
+ setattribute self, '$usage', $P0
+
+ ## set the $version attribute
+ .local pmc cfg
+ $P0 = new 'String'
+ $P0 = 'This is Rakudo perl6doc'
+ push_eh _handler
+ cfg = _config() # currently works in the build tree, but not in the
install tree
+ $P0 .= ', revision '
+ $S0 = cfg['revision']
+ $P0 .= $S0
+ $P0 .= ' built on parrot '
+ $S0 = cfg['VERSION']
+ $P0 .= $S0
+ $S0 = cfg['DEVEL']
+ $P0 .= $S0
+ $P0 .= "\n"
+ $P0 .= 'for '
+ $S0 = cfg['archname']
+ $P0 .= $S0
+ _handler:
+ $P0 .= ".\n\nCopyright 2006-2008, The Perl Foundation.\n"
+ setattribute self, '$version', $P0
+.end
+
+
+.namespace ['Perl6doc::Compiler']
+
+=item main(args :slurpy) :main
+
+Start compilation by passing any command line C<args>
+to the Perl 6 compiler.
+
+=cut
+
+.sub 'main' :main
+ .param pmc args_str
+
+ ## create @ARGS global. We could possibly use the args pmc
+ ## coming directly from Parrot, but currently Parrot provides
+ ## it as a ResizableStringArray and we need Undefs for
+ ## non-existent elements (RSA gives empty strings).
+ .local pmc args, iter
+ args = new 'ResizableStringArray'
+ iter = new 'Iterator', args_str
+ args_loop:
+ unless iter goto args_end
+ $P0 = shift iter
+ push args, $P0
+ goto args_loop
+ args_end:
+ set_hll_global '@ARGS', args
+
+ $P0 = compreg 'Perl6doc'
+ $P1 = $P0.'command_line'(args)
+.end
+
+
+.include 'perl6doc/gen_grammar.pir'
+.include 'perl6doc/gen_actions.pir'
+
+
+=back
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Added: trunk/languages/perl6/src/utils/perl6doc/actions.pm
==============================================================================
--- (empty file)
+++ trunk/languages/perl6/src/utils/perl6doc/actions.pm Thu Jan 31 14:23:39 2008
@@ -0,0 +1,46 @@
+# Copyright (C) 2008, The Perl Foundation.
+# $Id$
+
+class Perl6doc::Grammar::Actions;
+
+method TOP($/) {
+ my $stmts := PAST::Stmts.new();
+ if $<pod_comment> {
+ for $<pod_comment> {
+ $stmts.push(
+ PAST::Op.new(
+ $( $_ ),
+ :pirop('say')
+ )
+ );
+ }
+ }
+ else {
+ $stmts.push(
+ PAST::Op.new(
+ PAST::Val.new( :value('No POD found.') ),
+ :pirop('say')
+ )
+ );
+ }
+ make PAST::Block.new(
+ $stmts,
+ :blocktype('declaration')
+ );
+}
+
+
+method pod_comment($/, $key?) {
+ make PAST::Val.new(
+ :value( ~$<pod> ),
+ :node( $/ )
+ );
+}
+
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Added: trunk/languages/perl6/src/utils/perl6doc/grammar.pg
==============================================================================
--- (empty file)
+++ trunk/languages/perl6/src/utils/perl6doc/grammar.pg Thu Jan 31 14:23:39 2008
@@ -0,0 +1,40 @@
+# Copyright (C) 2008, The Perl Foundation.
+# $Id$
+
+=begin Introduction
+
+This is the rules portion of the grammar for the perl6 document reader.
+This grammar is based on the STD.pm grammar available from
+L<http://svn.pugscode.org/pugs/src/perl6/STD.pm>.
+
+=end Introduction
+
+grammar Perl6doc::Grammar is PCT::Grammar;
+
+token TOP { [ .*? <pod_comment> ]* {*} }
+
+
+token unsp {
+ \\ <.before [\s|'#']>
+ [ \v | \h+ ]*
+}
+
+#### pod ####
+
+## The <pod_comment> token is used to match perl 6 pod comments.
+## It's currently incomplete, but so is the spec.
+
+token pod_comment {
+ $<pod>=[
+ ^^ '=' <.unsp>?
+ [
+ | begin <.ws> <ident> .*? \n
+ '=' <.unsp>? 'end' <.ws> $<ident> \N*
+ {*} #= block
+ | \N* {*} #= misc
+ ]
+ ]
+ {*}
+}
+
+