Anonymous avatar Anonymous committed a57383f

update infrastructure with setup.pir (distutils)

Comments (0)

Files changed (7)

 syntax: glob
 *.swp
+*.tar.gz
+*.zip
+*.patch
 *.pbc
-gen_actions.pir   
-gen_builtins.pir  
-gen_grammar.pir 
-
+*.c
+*.o
+*.obj
+*.exe
+*.iss
+gen_*.pir
+installable_shakespeare
+MANIFEST

Makefile

-# ex: set ro ft=make:
-# DO NOT EDIT THIS FILE
-# Generated by Parrot::Configure::Compiler from languages/shakespeare/config/makefiles/root.in
-
-## $Id$
-
-## arguments we want to run parrot with
-PARROT_ARGS =
-
-## configuration settings
-BUILD_DIR     = /home/rff/parrot
-LOAD_EXT      = .so
-O             = .o
-
-## Setup some commands
-LN_S          = /bin/ln -s
-PERL          = /usr/bin/perl
-RM_RF         = $(PERL) -MExtUtils::Command -e rm_rf
-CP            = $(PERL) -MExtUtils::Command -e cp
-PARROT        = ../../parrot
-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
-
-PMC_DIR       = src/pmc
-
-all: shakespeare.pbc
-
-shakespeare_GROUP = $(PMC_DIR)/shakespeare_group$(LOAD_EXT)
-
-SOURCES = shakespeare.pir \
-  src/gen_grammar.pir \
-  src/gen_actions.pir \
-  src/gen_builtins.pir \
-#  $(shakespeare_GROUP)
-
-BUILTINS_PIR = \
-  src/builtins/base.pir \
-
-# PMCS = shakespeare
-# PMC_SOURCES = $(PMC_DIR)/shakespeare.pmc
-
-# the default target
-shakespeare.pbc: $(PARROT) $(SOURCES)
-	$(PARROT) $(PARROT_ARGS) -o shakespeare.pbc shakespeare.pir
-
-src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg src/parser/words.pg
-	$(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
-	    --output=src/gen_grammar.pir \
-	    src/parser/grammar.pg \
-	    src/parser/words.pg \
-
-src/gen_actions.pir: $(NQP) $(PCT) src/parser/actions.pm
-	$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
-	    --target=pir src/parser/actions.pm
-
-src/gen_builtins.pir: $(BUILTINS_PIR)
-	$(CAT) $(BUILTINS_PIR) >src/gen_builtins.pir
-
-$(shakespeare_GROUP): $(PARROT) $(PMC_SOURCES)
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) generate $(PMCS)
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) compile $(PMCS)
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) linklibs $(PMCS)
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT) $(PMCS)
-
-# regenerate the Makefile
-Makefile: config/makefiles/root.in
-	cd $(BUILD_DIR) && $(RECONFIGURE) --step=gen::languages --languages=shakespeare
-
-# 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:               shakespeare.pbc"
-	@echo "                     This is the default."
-	@echo "Testing:"
-	@echo "  test:              Run the test suite."
-	@echo "  extest:            Run the test suite for examples."
-	@echo "  fulltest:          Run both."
-	@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
-
-extest: all 
-	$(PERL) t/example_harness
-
-fulltest: all test extest
-
-# this target has nothing to do
-testclean:
-
-CLEANUPS = \
-  shakespeare.pbc \
-  src/gen_grammar.pir \
-  src/gen_actions.pir \
-  src/gen_builtins.pir \
-  $(PMC_DIR)/*.h \
-  $(PMC_DIR)/*.c \
-  $(PMC_DIR)/*.dump \
-  $(PMC_DIR)/*$(O) \
-  $(PMC_DIR)/*$(LOAD_EXT) \
-  $(PMC_DIR)/*.exp \
-  $(PMC_DIR)/*.ilk \
-  $(PMC_DIR)/*.manifest \
-  $(PMC_DIR)/*.pdb \
-  $(PMC_DIR)/*.lib \
-
-
-clean: testclean
-	$(RM_RF) $(CLEANUPS)
-
-realclean: clean
-	$(RM_RF) Makefile
-
-distclean: realclean
-
-
 INTRO
 -----
 
-SPL is a language designed to allow usage of the beatiful shakespear wording 
-while writing executable code. 
+SPL is a language designed to allow usage of the beatiful shakespear wording
+while writing executable code.
 
-The reference implementation is at [1] and you can see some more info in the 
+The reference implementation is at [1] and you can see some more info in the
 archive.org page for the shakespeare frontend for GCC [2]
 
 Quoting from the original project:
 
-    The design goal was to make a language with beautiful source code that 
-    resembled Shakespeare plays. There are no fancy data or control structures, 
-    just basic arithmetic and gotos. You could say we have combined the ex- 
-    pressiveness of BASIC with the user-friendliness of assembly language. 
+    The design goal was to make a language with beautiful source code that
+    resembled Shakespeare plays. There are no fancy data or control structures,
+    just basic arithmetic and gotos. You could say we have combined the ex-
+    pressiveness of BASIC with the user-friendliness of assembly language.
 
 How Reductive! SPL is a great achievement in unifying art and code, a noble
 goal which must not be underestimated.
 
-So, to try to learn a bit about Parrot[3], I did this. 
+So, to try to learn a bit about Parrot[3], I did this.
+
+BUILD
+-----
+
+    $ parrot setup.pir
+    $ parrot setup.pir test
+    $ parrot setup.pir spectest
+    $ sudo parrot setup.pir install
 
 USING
 -----
-If you are reading this you must have obtained the shakespeare-parrot 
-distribution, and I congratulate you. 
+If you are reading this you must have obtained the shakespeare-parrot
+distribution, and I congratulate you.
 Put the files in a languages/shakespeare/ directory in a parrot source tree
-and run make. 
+and run make.
 make test will execute the test suite, to run your own file use
     ../../parrot shakespeare.pir filename.spl
-since we used the standard parrot's HLLCompiler you can use the usual flags 
+since we used the standard parrot's HLLCompiler you can use the usual flags
 such as --target=(parse|pir) to see the parse three and the PIR output.
 
 INTERACTIVE PROMPT
 ------------------
-You can also access the interpreter interactively. 
+You can also access the interpreter interactively.
 Since setting up a whole play would be useless, you can input single sentences
 and see how they will be parsed:
 $ parrot shakespeare.pir
 
 IMPLEMENTATION
 --------------
-The original SPL project generates C code through spl2c that con 
+The original SPL project generates C code through spl2c that con
 be compiled and linked and linked with libspl to generate executables.
 The parser is built with yacc/bison and the lexer is flex. The Perl port[4] uses
 the same parser and lexer.
 
-This parrot version uses PGE to parse the grammar and generate an AST, 
+This parrot version uses PGE to parse the grammar and generate an AST,
 The parrot toolchain allows automatic transformation of the PAST (Parrot AST) into
 POST and then PIR (parrot's high level assembly).
 
-When executed this intermediate code is translated into bytecode and it uses 
-the functions defined in src/builtins/base.pir to operate. 
+When executed this intermediate code is translated into bytecode and it uses
+the functions defined in src/builtins/base.pir to operate.
 
 The runtime uses some global variables:
-* the_cast contains a list of characters, each one a tuple 
+* the_cast contains a list of characters, each one a tuple
   (value, stack, name, onstage flag)
 * the_speaker refers the current speaker, so that the references "thou" and "me"
   are meaningful. Using objects was another option.
-* the_condition is a boolean value that gets set from a 'question' statement 
-  ("is foo better than bar?") and is referenced later. Inlining of the 
-  value would require a lot of work when building the AST, while the bytecode 
-  compiler should have no problems doing it. 
+* the_condition is a boolean value that gets set from a 'question' statement
+  ("is foo better than bar?") and is referenced later. Inlining of the
+  value would require a lot of work when building the AST, while the bytecode
+  compiler should have no problems doing it.
 
 
-Although I did not initially look at the original source code while writing 
+Although I did not initially look at the original source code while writing
 the interpreter it seems that the behaviour of spl2c+libspl is the same.
 
-The list of valid words was originally generated from a list of wordlist files 
+The list of valid words was originally generated from a list of wordlist files
 with an AWK script I have lost track of. It's in the TODO list to fix it.
 
 Notice that since PGE doesn't do (yet) longest token matching, a token like this
         | 'the'
     }
 would cause a failure to parse "an empty bottle" because the token 'a'
-is matched and the token does not backtracks. The grammar goes on trying to 
-match 'n' and thus fails. 
-The words where I had test failures were hand fixed, some may still 
-cause failurese the interactive loop to check. 
+is matched and the token does not backtracks. The grammar goes on trying to
+match 'n' and thus fails.
+The words where I had test failures were hand fixed, some may still
+cause failurese the interactive loop to check.
 
 
-LANGUAGE EXTENSIONS 
+LANGUAGE EXTENSIONS
 -------------------
 
 Shakespeare did not originally support testing explicitly, but in the modern
 world of software engineering this would have prohibited building large scale
-dramatic-software projects. 
+dramatic-software projects.
 
 Thus, I've added two new instructions to the language to minimally support the
 Test Anything Protocol (TAP)[5]
  * plan an evil thing!
    will print "1..2". Every valid value can be used after the word 'plan'.
-   Suggestions for improving are welcome, I'm thinking of using 
+   Suggestions for improving are welcome, I'm thinking of using
    [othello plans an evil thing]
  * proove yourself!
-   will print "ok x" where x is the value of the spoken character. 
+   will print "ok x" where x is the value of the spoken character.
    Every valid value can be used after the word 'proove'
 
 Test failure is reached through out-of order printing, so for example
    juliet: art thou better than me?
    romeo: if so, let us proceed to scene ii.
    juliet: proove nothing.
- 
+
    Scene II: the right branch.
    juliet: proove the joy!
 
 Will print "ok 1" if juliet is better than romeo, which is fine.
-If Romeo has an higher value than Juliet "ok 0" will be printed, and considered 
+If Romeo has an higher value than Juliet "ok 0" will be printed, and considered
 as a test failure from the test harness.
 
 The grammar also ignores she-bang lines #!.
 DIFFERENCES FROM OTHER IMPLEMENTATIONS
 --------------------------------------
 
-I wrote the parser trying not to look at the original grammar, using only the 
-examples. This means that in some ways the parser is more restrictive and in 
+I wrote the parser trying not to look at the original grammar, using only the
+examples. This means that in some ways the parser is more restrictive and in
 some ways it is more loose. Until we have an ISO specification for SPL it is
-assumed that this is ok. 
+assumed that this is ok.
 
 
 EXAMPLES
 The files in example are the original files used in both Lingua::Shakespeare and
 spl2c, and their operation is checked through the script t/test.rb.
 To verify that everything works you can run "make fulltest" which will execute
-both the standard test suite and the examples' test suite. 
+both the standard test suite and the examples' test suite.
 
 
 
 
-[1] http://shakespearelang.sourceforge.net/ 
+[1] http://shakespearelang.sourceforge.net/
 [2] http://web.archive.org/web/20080121104440/http://people.csa.iisc.ernet.in/sreejith/frontends/spl/spl.htm
 [3] http://www.parrotcode.org
 [4] http://search.cpan.org/~gbarr/Lingua-Shakespeare-1.00/

config/makefiles/root.in

-## $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@
-PARROT        = ../../parrot@exe@
-CAT           = $(PERL) -MExtUtils::Command -e cat
-BUILD_DYNPMC  = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
-RECONFIGURE   = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl
-#CONDITIONED_LINE(darwin):
-#CONDITIONED_LINE(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking
-#CONDITIONED_LINE(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@
-
-## 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
-
-PMC_DIR       = src/pmc
-
-all: shakespeare.pbc
-
-shakespeare_GROUP = $(PMC_DIR)/shakespeare_group$(LOAD_EXT)
-
-SOURCES = shakespeare.pir \
-  src/gen_grammar.pir \
-  src/gen_actions.pir \
-  src/gen_builtins.pir \
-#  $(shakespeare_GROUP)
-
-BUILTINS_PIR = \
-  src/builtins/base.pir \
-
-# PMCS = shakespeare
-# PMC_SOURCES = $(PMC_DIR)/shakespeare.pmc
-
-# the default target
-shakespeare.pbc: $(PARROT) $(SOURCES)
-	$(PARROT) $(PARROT_ARGS) -o shakespeare.pbc shakespeare.pir
-
-src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg src/parser/words.pg
-	$(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
-	    --output=src/gen_grammar.pir \
-	    src/parser/grammar.pg \
-	    src/parser/words.pg \
-
-src/gen_actions.pir: $(NQP) $(PCT) src/parser/actions.pm
-	$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
-	    --target=pir src/parser/actions.pm
-
-src/gen_builtins.pir: $(BUILTINS_PIR)
-	$(CAT) $(BUILTINS_PIR) >src/gen_builtins.pir
-
-$(shakespeare_GROUP): $(PARROT) $(PMC_SOURCES)
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) generate $(PMCS)
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) compile $(PMCS)
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) linklibs $(PMCS)
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT) $(PMCS)
-
-# regenerate the Makefile
-Makefile: config/makefiles/root.in
-	cd $(BUILD_DIR) && $(RECONFIGURE) --step=gen::languages --languages=shakespeare
-
-# 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:               shakespeare.pbc"
-	@echo "                     This is the default."
-	@echo "Testing:"
-	@echo "  test:              Run the test suite."
-	@echo "  extest:            Run the test suite for examples."
-	@echo "  fulltest:          Run both."
-	@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
-
-extest: all 
-	$(PERL) t/example_harness
-
-fulltest: all test extest
-
-# this target has nothing to do
-testclean:
-
-CLEANUPS = \
-  shakespeare.pbc \
-  src/gen_grammar.pir \
-  src/gen_actions.pir \
-  src/gen_builtins.pir \
-  $(PMC_DIR)/*.h \
-  $(PMC_DIR)/*.c \
-  $(PMC_DIR)/*.dump \
-  $(PMC_DIR)/*$(O) \
-  $(PMC_DIR)/*$(LOAD_EXT) \
-  $(PMC_DIR)/*.exp \
-  $(PMC_DIR)/*.ilk \
-  $(PMC_DIR)/*.manifest \
-  $(PMC_DIR)/*.pdb \
-  $(PMC_DIR)/*.lib \
-
-
-clean: testclean
-	$(RM_RF) $(CLEANUPS)
-
-realclean: clean
-	$(RM_RF) Makefile
-
-distclean: realclean
-
-
+#!/usr/bin/env parrot
+
+=head1 NAME
+
+setup.pir - Python distutils style
+
+=head1 DESCRIPTION
+
+No Configure step, no Makefile generated.
+
+See F<runtime/library/distutils.pir>.
+
+=head1 USAGE
+
+    $ parrot setup.pir build
+    $ parrot setup.pir test
+    $ sudo parrot setup.pir install
+
+=cut
+
+.sub 'main' :main
+    .param pmc args
+    $S0 = shift args
+    load_bytecode 'distutils.pbc'
+
+    .const 'Sub' spectest = 'spectest'
+    register_step('spectest', spectest)
+
+    $P0 = new 'Hash'
+    $P0['name'] = 'Shakespeare'
+    $P0['abstract'] = 'The Shakespeare Programming Language, on Parrot'
+    $P0['authority'] = 'http://bitbucket.org/riffraff/'
+    $P0['description'] = 'The Shakespeare Programming Language, on Parrot'
+    $P0['license_type'] = 'BEER-WARE LICENSE'
+#    $P0['license_uri'] = ''
+    $P0['copyright_holder'] = 'Parrot Foundation'
+    $P0['checkout_uri'] = 'http://bitbucket.org/riffraff/shakespeare-parrot/'
+    $P0['browser_uri'] = 'http://bitbucket.org/riffraff/shakespeare-parrot/'
+    $P0['project_uri'] = 'http://bitbucket.org/riffraff/shakespeare-parrot/'
+
+    # build
+    $P1 = new 'Hash'
+    $P2 = split ' ', 'src/parser/grammar.pg src/parser/words.pg'
+    $P1['src/gen_grammar.pir'] = $P2
+    $P0['pir_pge'] = $P1
+
+    $P3 = new 'Hash'
+    $P3['src/gen_actions.pir'] = 'src/parser/actions.pm'
+    $P0['pir_nqp'] = $P3
+
+    $P4 = new 'Hash'
+    $P5 = split "\n", <<'SOURCES'
+shakespeare.pir
+src/gen_grammar.pir
+src/gen_actions.pir
+src/builtins/base.pir
+SOURCES
+    $S0 = pop $P5
+    $P4['shakespeare.pbc'] = $P5
+    $P0['pbc_pir'] = $P4
+
+    $P5 = new 'Hash'
+    $P5['parrot-shakespeare'] = 'shakespeare.pbc'
+    $P0['installable_pbc'] = $P5
+
+    # test
+    $S0 = get_parrot()
+    $S0 .= ' shakespeare.pbc'
+    $P0['prove_exec'] = $S0
+
+    # dist
+    $P10 = glob('example/*.spl t/test.rb')
+    $P0['manifest_includes'] = $P10
+
+    .tailcall setup(args :flat, $P0 :flat :named)
+.end
+
+.sub 'spectest' :anon
+    .param pmc kv :slurpy :named
+    run_step('build', kv :flat :named)
+
+    .local string cmd
+    cmd = 'prove --exec=ruby t/test.rb'
+    system(cmd, 1 :named('verbose'))
+.end
+
+# Local Variables:
+#   mode: pir
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
     say "Thou hast entered the interactive sentence verifier"
     say "Enter a Sentence to see How It Parses"
     rgx= get_hll_global ['shakespeare';'Grammar'], 'sentence'
-  loop: 
+  loop:
     unless stdin goto endloop
     # need a pmc or a string conversion from null will die()
     $P0 = stdin.'readline_interactive'(prompt)
 .end
 
 
-.include 'src/gen_builtins.pir'
+.include 'src/builtins/base.pir'
 .include 'src/gen_grammar.pir'
 .include 'src/gen_actions.pir'
 

t/harness

-#! perl
-
-# $Id$
-
-# pragmata
-use strict;
-use warnings;
-use 5.008;
-
-use lib qw( . lib ../lib ../../lib ../../lib );
-use Parrot::Test::Harness language => 'shakespeare',
-                          compiler => 'shakespeare.pbc';
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.