Permalink
Browse files

[lolcode] Relocating LOLCODE compiler to languages repository from

  • Loading branch information...
0 parents commit 1012194e8fa185232ab953fca329c9298415d00e @allisonrandal allisonrandal committed Mar 11, 2009
@@ -0,0 +1,22 @@
+# Copyright (C) 2009, Parrot Foundation.
+# $Id: Configure.pl 36945 2009-02-23 19:35:13Z fperrad $
+
+use strict;
+use warnings;
+use 5.008;
+
+my $build_dir = '../..';
+my $hll = 'lolcode';
+my $cmd = qq{$^X -Ilib tools/dev/reconfigure.pl --step=gen::languages --languages=$hll};
+
+print "Running '$cmd' in $build_dir\n";
+chdir $build_dir;
+`$cmd`
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
@@ -0,0 +1,8 @@
+The following tickets were stored in parrot's RT system.
+
+They have now been marked as rejected in that system, but are listed
+here for posterity, so they can easily be migrated into lolcodes's new
+ticketing system, whatever that may be.
+
+#52178: [TODO] Improve variable declarations in LOLCODE
+ http://rt.perl.org/rt3/Ticket/Display.html?id=52178
@@ -0,0 +1,146 @@
+# Copyright (C) 2008-2009, Parrot Foundation.
+## $Id: root.in 36930 2009-02-22 10:10:01Z barney $
+
+## arguments we want to run parrot with
+PARROT_ARGS =
+
+## configuration settings
+BUILD_DIR = @build_dir@
+LOAD_EXT = @load_ext@
+O = @o@
+EXE = @exe@
+
+## Setup some commands
+PERL = @perl@
+RM_RF = @rm_rf@
+PARROT = ../../parrot$(EXE)
+CAT = @cat@
+BUILD_DYNPMC = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.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
+PBC_TO_EXE = $(BUILD_DIR)/pbc_to_exe$(EXE)
+
+PMC_DIR = src/pmc
+
+all: lolcode.pbc
+
+LOLCODE_GROUP = $(PMC_DIR)/lolcode_group$(LOAD_EXT)
+
+SOURCES = lolcode.pir \
+ src/gen_grammar.pir \
+ src/gen_actions.pir \
+ src/gen_builtins.pir \
+ src/parser/yarn_literal.pir \
+# $(LOLCODE_GROUP)
+
+BUILTINS_PIR = \
+ src/builtins/say.pir \
+ src/builtins/expr_parse.pir \
+ src/builtins/math.pir \
+ src/builtins/cmp.pir
+
+# PMCS = lolcode
+# PMC_SOURCES = $(PMC_DIR)/lolcode.pmc
+
+lolcode$(EXE): lolcode.pbc
+ $(PBC_TO_EXE) lolcode.pbc
+
+installable_lolcode$(EXE): lolcode.pbc
+ $(PBC_TO_EXE) lolcode.pbc --install
+
+# the default target
+lolcode.pbc: $(PARROT) $(SOURCES)
+ $(PARROT) $(PARROT_ARGS) -o lolcode.pbc lolcode.pir
+
+src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg
+ $(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
+ --output=src/gen_grammar.pir \
+ src/parser/grammar.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
+
+$(LOLCODE_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
+ $(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 " all: lolcode.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
+
+# this target has nothing to do
+testclean:
+
+CLEANUPS = \
+ lolcode.pbc \
+ lolcode.c \
+ lolcode.ilk \
+ *.manifest \
+ *.pdb \
+ lolcode$(O) \
+ lolcode$(EXE) \
+ installable_lolcode$(EXE) \
+ 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:
+ $(RM_RF) $(CLEANUPS)
+
+realclean: clean
+ $(RM_RF) Makefile
+
+distclean: realclean
+
+# Local variables:
+# mode: makefile
+# End:
+# vim: ft=make:
@@ -0,0 +1,85 @@
+=head1 TITLE
+
+lolcode.pir - A lolcode compiler.
+
+=head2 Description
+
+This is the base file for the lolcode compiler.
+
+This file includes the parsing and grammar rules from
+the src/ directory, loads the relevant PGE libraries,
+and registers the compiler under the name 'lolcode'.
+
+=head2 Functions
+
+=over 4
+
+=item onload()
+
+Creates the lolcode compiler using a C<PCT::HLLCompiler>
+object.
+
+=cut
+
+.HLL 'lolcode'
+
+.namespace [ 'lolcode';'Compiler' ]
+
+.loadlib 'lolcode_group'
+
+.sub '' :anon :load :init
+ load_bytecode 'PCT.pbc'
+ .local pmc parrotns, lolns, exports
+ parrotns = get_root_namespace ['parrot']
+ lolns = get_hll_namespace
+ exports = split ' ', 'PAST PCT PGE P6metaclass'
+ parrotns.'export_to'(lolns, exports)
+.end
+
+.include 'src/gen_builtins.pir'
+.include 'src/gen_grammar.pir'
+.include 'src/parser/yarn_literal.pir'
+.include 'src/gen_actions.pir'
+
+.sub 'onload' :anon :load :init
+
+ $P0 = new 'ResizablePMCArray'
+ set_hll_global ['lolcode';'Grammar';'Actions'], '@?BLOCK', $P0
+
+ $P0 = new ['PAST';'Stmts']
+ set_hll_global ['lolcode';'Grammar';'Actions'], '$?BLOCK_SIGNATURE', $P0
+
+ $P0 = get_hll_global ['PCT'], 'HLLCompiler'
+ $P1 = $P0.'new'()
+ $P1.'language'('lolcode')
+ $P0 = get_hll_namespace ['lolcode';'Grammar']
+ $P1.'parsegrammar'($P0)
+ $P0 = get_hll_namespace ['lolcode';'Grammar';'Actions']
+ $P1.'parseactions'($P0)
+.end
+
+=item main(args :slurpy) :main
+
+Start compilation by passing any command line C<args>
+to the lolcode compiler.
+
+=cut
+
+.sub 'main' :main
+ .param pmc args
+
+ $P0 = compreg 'lolcode'
+ $P1 = $P0.'command_line'(args)
+.end
+
+
+=back
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
@@ -0,0 +1,32 @@
+.sub 'BOTH SAEM'
+ .param pmc x
+ .param pmc y
+ eq x, y, WIN
+ $P0 = new 'Boolean'
+ $P0 = 0
+ .return($P0)
+ WIN:
+ $P0 = new 'Boolean'
+ $P0 = 1
+ .return ($P0)
+.end
+
+.sub 'DIFFRINT'
+ .param pmc x
+ .param pmc y
+ ne x, y, WIN
+ $P0 = new 'Boolean'
+ $P0 = 0
+ .return($P0)
+ WIN:
+ $P0 = new 'Boolean'
+ $P0 = 1
+ .return ($P0)
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
@@ -0,0 +1,41 @@
+=head1
+
+expr_parse.pir - parse an expression and dispatch function calls with their appropriate arguments.
+
+=cut
+
+.namespace []
+
+.sub lookup
+ .param string name
+ $P0 = find_name name
+ if_null $P0, null_token
+ .return($P0)
+ null_token:
+ .return("NULL")
+.end
+
+.sub lookup_class
+ .param pmc item
+ $P0 = class item
+ $S0 = $P0
+ .return($S0)
+.end
+
+.sub defined
+ .param pmc item
+ $I0 = defined item
+ .return($I0)
+.end
+
+.sub get_inspect_info
+ .param pmc item
+ $P0 = inspect item
+ .return($P0)
+.end
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
Oops, something went wrong.

0 comments on commit 1012194

Please sign in to comment.