Skip to content
This repository
Browse code

APL is now available in its new home:

  • Loading branch information...
commit b0eedead9b8c8ba0c78a7473e250b62b1e95b7a4 1 parent 55bcb8d
Will Coleda authored March 07, 2009

Showing 38 changed files with 14 additions and 3,324 deletions. Show diff stats Hide diff stats

  1. 25  MANIFEST
  2. 38  MANIFEST.SKIP
  3. 1  MANIFEST.generated
  4. 2  README_cygwin.pod
  5. 2  config/gen/languages.pm
  6. 18  config/gen/makefiles/languages.in
  7. 4  examples/tge/README
  8. 82  languages/APL/APL.pir
  9. 9  languages/APL/Configure.pl
  10. 7  languages/APL/MAINTAINER
  11. 46  languages/APL/README
  12. 33  languages/APL/STATUS
  13. 128  languages/APL/config/makefiles/root.in
  14. 3  languages/APL/demo.apl
  15. 167  languages/APL/src/parser/actions.pm
  16. 62  languages/APL/src/parser/grammar.pg
  17. 204  languages/APL/src/pmc/aplvector.pmc
  18. 95  languages/APL/t/APL.pm
  19. 37  languages/APL/t/characters.t
  20. 422  languages/APL/t/dyadic.t
  21. 12  languages/APL/t/harness
  22. 92  languages/APL/t/index.t
  23. 17  languages/APL/t/jaah.t
  24. 124  languages/APL/t/monadic.t
  25. 57  languages/APL/t/numbers.t
  26. 378  languages/APL/t/pmc_aplvector.t
  27. 63  languages/APL/t/specification.t
  28. 210  languages/APL/t/vector.t
  29. 895  languages/APL/tools/gen_operator_defs.pl
  30. 2  languages/t/harness
  31. 2  lib/Parrot/Distribution.pm
  32. 1  lib/Parrot/Docs/Section/Languages.pm
  33. 75  lib/Parrot/Test/APL.pm
  34. 1  t/codingstd/linelength.t
  35. 2  t/configure/045-generated_file_header.t
  36. 3  t/perl/Parrot_Distribution.t
  37. 4  tools/dev/mk_language_shell.pl
  38. 15  tools/install/smoke_languages.pl
25  MANIFEST
... ...
@@ -1,7 +1,7 @@
1 1
 # ex: set ro:
2 2
 # $Id$
3 3
 #
4  
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Mar  5 22:29:07 2009 UT
  4
+# generated by tools/dev/mk_manifest_and_skip.pl Sat Mar  7 19:29:03 2009 UT
5 5
 #
6 6
 # See tools/dev/install_files.pl for documentation on the
7 7
 # format of this file.
@@ -954,28 +954,6 @@ include/parrot/thread.h                                     [main]include
954 954
 include/parrot/tsq.h                                        [main]include
955 955
 include/parrot/vtables.h                                    [main]include
956 956
 include/parrot/warnings.h                                   [main]include
957  
-languages/APL/APL.pir                                       [APL]
958  
-languages/APL/Configure.pl                                  [APL]
959  
-languages/APL/MAINTAINER                                    [APL]
960  
-languages/APL/README                                        []doc
961  
-languages/APL/STATUS                                        [APL]
962  
-languages/APL/config/makefiles/root.in                      [APL]
963  
-languages/APL/demo.apl                                      [APL]
964  
-languages/APL/src/parser/actions.pm                         [APL]
965  
-languages/APL/src/parser/grammar.pg                         [APL]
966  
-languages/APL/src/pmc/aplvector.pmc                         [APL]
967  
-languages/APL/t/APL.pm                                      [test]
968  
-languages/APL/t/characters.t                                [test]
969  
-languages/APL/t/dyadic.t                                    [test]
970  
-languages/APL/t/harness                                     [test]
971  
-languages/APL/t/index.t                                     [test]
972  
-languages/APL/t/jaah.t                                      [test]
973  
-languages/APL/t/monadic.t                                   [test]
974  
-languages/APL/t/numbers.t                                   [test]
975  
-languages/APL/t/pmc_aplvector.t                             [test]
976  
-languages/APL/t/specification.t                             [test]
977  
-languages/APL/t/vector.t                                    [test]
978  
-languages/APL/tools/gen_operator_defs.pl                    [APL]
979 957
 languages/BASIC/MAINTAINER                                  [BASIC]
980 958
 languages/BASIC/compiler/BASIC_README                       []doc
981 959
 languages/BASIC/compiler/COMP_assignments.pm                [BASIC]
@@ -1882,7 +1860,6 @@ lib/Parrot/Pmc2c/VTable.pm                                  [devel]lib
1882 1860
 lib/Parrot/Revision.pm                                      [devel]lib
1883 1861
 lib/Parrot/SearchOps.pm                                     [devel]lib
1884 1862
 lib/Parrot/Test.pm                                          [devel]lib
1885  
-lib/Parrot/Test/APL.pm                                      [devel]lib
1886 1863
 lib/Parrot/Test/Cardinal.pm                                 [devel]lib
1887 1864
 lib/Parrot/Test/Harness.pm                                  [devel]lib
1888 1865
 lib/Parrot/Test/PGE.pm                                      [devel]lib
38  MANIFEST.SKIP
... ...
@@ -1,6 +1,6 @@
1 1
 # ex: set ro:
2 2
 # $Id$
3  
-# generated by tools/dev/mk_manifest_and_skip.pl Tue Mar  3 14:13:06 2009 UT
  3
+# generated by tools/dev/mk_manifest_and_skip.pl Sat Mar  7 19:22:32 2009 UT
4 4
 #
5 5
 # This file should contain a transcript of the svn:ignore properties
6 6
 # of the directories in the Parrot subversion repository. (Needed for
@@ -445,42 +445,6 @@
445 445
 ^languages/unlambda/
446 446
 ^languages/wmlscript$
447 447
 ^languages/wmlscript/
448  
-# generated from svn:ignore of 'languages/APL/'
449  
-^languages/APL/.*\.pbc$
450  
-^languages/APL/.*\.pbc/
451  
-^languages/APL/\.gdb_history$
452  
-^languages/APL/\.gdb_history/
453  
-^languages/APL/Makefile$
454  
-^languages/APL/Makefile/
455  
-# generated from svn:ignore of 'languages/APL/src/'
456  
-^languages/APL/src/APLFunctions\.pir$
457  
-^languages/APL/src/APLFunctions\.pir/
458  
-^languages/APL/src/APLGrammar\.pir$
459  
-^languages/APL/src/APLGrammar\.pir/
460  
-^languages/APL/src/gen_.*\.pir$
461  
-^languages/APL/src/gen_.*\.pir/
462  
-^languages/APL/src/parse2past\.pir$
463  
-^languages/APL/src/parse2past\.pir/
464  
-# generated from svn:ignore of 'languages/APL/src/pmc/'
465  
-^languages/APL/src/pmc/.*\.c$
466  
-^languages/APL/src/pmc/.*\.c/
467  
-^languages/APL/src/pmc/.*\.dump$
468  
-^languages/APL/src/pmc/.*\.dump/
469  
-^languages/APL/src/pmc/.*\.h$
470  
-^languages/APL/src/pmc/.*\.h/
471  
-^languages/APL/src/pmc/.*\.obj$
472  
-^languages/APL/src/pmc/.*\.obj/
473  
-^languages/APL/src/pmc/.*\.pdb$
474  
-^languages/APL/src/pmc/.*\.pdb/
475  
-^languages/APL/src/pmc/apl_group\..*$
476  
-^languages/APL/src/pmc/apl_group\..*/
477  
-# generated from svn:ignore of 'languages/APL/t/'
478  
-^languages/APL/t/.*\.apl$
479  
-^languages/APL/t/.*\.apl/
480  
-^languages/APL/t/.*\.out$
481  
-^languages/APL/t/.*\.out/
482  
-^languages/APL/t/.*\.pir$
483  
-^languages/APL/t/.*\.pir/
484 448
 # generated from svn:ignore of 'languages/BASIC/compiler/'
485 449
 ^languages/BASIC/compiler/TARG_test\.pir$
486 450
 ^languages/BASIC/compiler/TARG_test\.pir/
1  MANIFEST.generated
@@ -73,7 +73,6 @@ installable_pbc_merge                             [main]bin
73 73
 installable_pbc_to_exe.exe                        [main]bin
74 74
 installable_pbc_to_exe                            [main]bin
75 75
 languages/abc/abc.pbc                             [abc]
76  
-languages/APL/APL.pbc                             [APL]
77 76
 languages/befunge/befunge.pbc                     [befunge]
78 77
 languages/bf/bfco.pbc                             [bf]
79 78
 languages/bf/bfc.pbc                              [bf]
2  README_cygwin.pod
Source Rendered
@@ -49,8 +49,6 @@ Optional perl packages for testing:
49 49
   L<Test::TAP::HTMLMatrix> if you want to run the smoke tests
50 50
   with C<make smoke>.
51 51
 
52  
-  L<Test::Base> for some APL language tests.
53  
-
54 52
   perl L<Test::Perl::Critic> and L<Perl::Critic>
55 53
 
56 54
 =over 4
2  config/gen/languages.pm
@@ -36,7 +36,7 @@ sub _init {
36 36
     $data{description} = q{Configure languages};
37 37
     $data{result} = q{};
38 38
     $data{default_languages} = qq{
39  
-        APL abc
  39
+        abc
40 40
         befunge bf
41 41
         cardinal chitchat cola c99
42 42
         ecmascript
18  config/gen/makefiles/languages.in
@@ -15,7 +15,7 @@ SVN           := svn
15 15
 # List of languages that are currently managed in the Parrot svn repository
16 16
 # When adding or removing languages, please update the list
17 17
 LANGUAGES := \
18  
-    abc APL \
  18
+    abc \
19 19
     BASIC befunge bf \
20 20
     c99 cardinal chitchat cola \
21 21
     dotnet \
@@ -146,7 +146,7 @@ test-unified: all
146 146
 	$(PERL) t/harness
147 147
 
148 148
 test-separate: all \
149  
-    abc.test APL.test \
  149
+    abc.test \
150 150
     befunge.test bf.test \
151 151
     c99.test cardinal.test chitchat.test cola.test \
152 152
     dotnet.test \
@@ -161,7 +161,7 @@ test-separate: all \
161 161
     urm.test
162 162
 
163 163
 clean: \
164  
-    abc.clean APL.clean \
  164
+    abc.clean \
165 165
     BASIC.clean befunge.clean bf.clean \
166 166
     c99.clean cardinal.clean chitchat.clean cola.clean \
167 167
     dotnet.clean \
@@ -177,7 +177,7 @@ clean: \
177 177
     urm.clean
178 178
 
179 179
 realclean: \
180  
-    abc.realclean APL.realclean \
  180
+    abc.realclean \
181 181
     befunge.realclean bf.realclean \
182 182
     c99.realclean cardinal.realclean chitchat.realclean cola.realclean \
183 183
     dotnet.realclean \
@@ -208,16 +208,6 @@ abc.clean:
208 208
 abc.realclean:
209 209
 	- $(MAKE) abc realclean
210 210
 
211  
-APL : APL.dummy
212  
-APL.dummy:
213  
-	- $(MAKE) APL
214  
-APL.test:
215  
-	- $(MAKE) APL test
216  
-APL.clean:
217  
-	- $(MAKE) APL clean
218  
-APL.realclean:
219  
-	- $(MAKE) APL realclean
220  
-
221 211
 BASIC : BASIC.dummy
222 212
 BASIC.dummy:
223 213
 # don't know how to build BASIC
4  examples/tge/README
... ...
@@ -1,4 +1,2 @@
1 1
 This directory contains a few simple examples of uses for TGE
2  
-(compilers/tge). For more complete examples, see the Perl 1
3  
-implementation in languages/punie or the APL implementation in
4  
-languages/APL.
  2
+(compilers/tge). 
82  languages/APL/APL.pir
... ...
@@ -1,82 +0,0 @@
1  
-=head1 TITLE
2  
-
3  
-apl.pir - A APL compiler.
4  
-
5  
-=head2 Description
6  
-
7  
-This is the base file for the APL compiler.
8  
-
9  
-This file includes the parsing and grammar rules from
10  
-the src/ directory, loads the relevant PGE libraries,
11  
-and registers the compiler under the name 'APL'.
12  
-
13  
-=head2 Functions
14  
-
15  
-=over 4
16  
-
17  
-=item onload()
18  
-
19  
-Creates the APL compiler using a C<PCT::HLLCompiler>
20  
-object.
21  
-
22  
-=cut
23  
-
24  
-.HLL 'apl'
25  
-
26  
-.namespace [ 'APL';'Compiler' ]
27  
-
28  
-.loadlib 'apl_group'
29  
-
30  
-.sub '' :anon :load :init
31  
-    load_bytecode 'PCT.pbc'
32  
-
33  
-    .local pmc parrotns, aplns, exports
34  
-    parrotns = get_root_namespace ['parrot']
35  
-    aplns = get_hll_namespace
36  
-    exports = split ' ', 'PAST PCT PGE'
37  
-    parrotns.'export_to'(aplns, exports)
38  
-.end
39  
-
40  
-.include 'src/gen_builtins.pir'
41  
-.include 'src/gen_grammar.pir'
42  
-.include 'src/gen_actions.pir'
43  
-
44  
-.sub 'onload' :anon :load :init
45  
-    $P0 = get_hll_global ['PCT'], 'HLLCompiler'
46  
-    $P1 = $P0.'new'()
47  
-    $P1.'language'('APL')
48  
-    $P0 = get_hll_namespace ['APL';'Grammar']
49  
-    $P1.'parsegrammar'($P0)
50  
-    $P0 = get_hll_namespace ['APL';'Grammar';'Actions']
51  
-    $P1.'parseactions'($P0)
52  
-
53  
-    ##  tell PCT to always generate pmcs for Float constants
54  
-    $P0 = get_hll_global ['PAST';'Compiler'], '%valflags'
55  
-    $P0['Float'] = ''
56  
-.end
57  
-
58  
-=item main(args :slurpy)  :main
59  
-
60  
-Start compilation by passing any command line C<args>
61  
-to the APL compiler.
62  
-
63  
-=cut
64  
-
65  
-.sub 'main' :main
66  
-    .param pmc args
67  
-
68  
-    $P0 = compreg 'APL'
69  
-    $P1 = $P0.'command_line'(args, 'encoding'=>'utf8')
70  
-.end
71  
-
72  
-
73  
-=back
74  
-
75  
-=cut
76  
-
77  
-# Local Variables:
78  
-#   mode: pir
79  
-#   fill-column: 100
80  
-# End:
81  
-# vim: expandtab shiftwidth=4 ft=pir:
82  
-
9  languages/APL/Configure.pl
... ...
@@ -1,9 +0,0 @@
1  
-#! perl
2  
-# $Id$
3  
-# Copyright (C) 2008 Parrot Foundation
4  
-
5  
-use strict;
6  
-use warnings;
7  
-
8  
-chdir '../..';
9  
-`$^X -Ilib tools/dev/reconfigure.pl --step=gen::languages --languages=APL`;
7  languages/APL/MAINTAINER
... ...
@@ -1,7 +0,0 @@
1  
-# $Id$
2  
-
3  
-N: Patrick R. Michaud
4  
-E: pmichaud@pobox.com
5  
-
6  
-N: Will "Coke" Coleda
7  
-E: will@coleda.com
46  languages/APL/README
... ...
@@ -1,46 +0,0 @@
1  
-APL is Copyright (C) 2006, Parrot Foundation.
2  
-
3  
-INSTRUCTIONS
4  
-------------
5  
-
6  
-Compile APL to bytecode and run its test suite:
7  
-
8  
-  $ make
9  
-  $ make test
10  
-
11  
-Run the APL compiler via Parrot, passing it an APL source file to process:
12  
-
13  
-  $ parrot APL.pbc demo.apl
14  
-  20
15  
-  5.5
16  
-
17  
-Run the APL system interactively:
18  
-
19  
-  $ parrot APL.pbc
20  
-      10×2+3
21  
-  50
22  
-
23  
-Display parse trees instead of executing statements:
24  
-
25  
-  $ parrot APL.pbc --target=parse demo.apl
26  
-
27  
-Display abstract syntax trees instead of executing statements:
28  
-
29  
-  $ parrot APL.pbc --target=PAST demo.apl
30  
-
31  
-Display the generated PIR code:
32  
-
33  
-  $ parrot APL.pbc --target=PIR demo.apl
34  
-
35  
-FONT: The source code for APL uses unicode codepoints that you might
36  
-not have a font for. If you can't read the code, try installing the
37  
-SimPL.tff font, available from:
38  
-
39  
-  http://www.vector.org.uk/resource/simp2.htm
40  
-
41  
-EDITOR: On OSX, I recommend SubEthaEdit for editing utf-8 encoded files. Also,
42  
-you'll want to enable the character palette: Go to System Preferences -> International -> Input Menu; enable 'Show input menu in menu bar'. To use the palette,
43  
-Click on the flag in the menu bar, select 'Character Palette'. A window will
44  
-pop up that lets you select unicode by code point, search by name of character,
45  
-insert into the open application, or bring up information about the selected
46  
-character.
33  languages/APL/STATUS
... ...
@@ -1,33 +0,0 @@
1  
-Things to do:
2  
-
3  
-o Need more tests! More tests for each type of operand per operator.
4  
-
5  
-o Add function declarations.
6  
-
7  
-o Add selective specification {in perl: lvalues}
8  
-
9  
-o APL should be fairly whitespace agnostic - (Need TODO tests). Right now,
10  
-  extraneous whitespace around operators is a syntax error.
11  
-
12  
-o clean up the tools/ script so non-generated code is moved into a .pir file.
13  
-
14  
-o While the PMC can handle arbitrarily dimensioned vectors, we don't print
15  
-  them properly; nor do we print nested arrays properly. (Need TODO tests.)
16  
-
17  
-o More type issues: Given the APL code:
18  
-
19  
-  FOO ← 2 4⍴⍳8
20  
-1 2 3 4
21  
-5 6 7 8
22  
-  ≡ FOO
23  
-1
24  
-  ⍴⊂FOO
25  
-
26  
-  ⍴⍴⊂FOO
27  
-0
28  
-  ≡⊂FOO
29  
-2
30  
-
31  
-... How do we store ⊂FOO? It's a scalar (shape), but contains a matrix (depth).
32  
-Perhaps a ref type of some kind? Or should we try to make APLVector deal with
33  
-this?
128  languages/APL/config/makefiles/root.in
... ...
@@ -1,128 +0,0 @@
1  
-# Copyright (C) 2006-2009, Parrot Foundation.
2  
-## $Id$
3  
-
4  
-## arguments we want to run parrot with
5  
-PARROT_ARGS =
6  
-
7  
-## configuration settings
8  
-BUILD_DIR     = @build_dir@
9  
-LOAD_EXT      = @load_ext@
10  
-O             = @o@
11  
-
12  
-## Setup some commands
13  
-LN_S          = @lns@
14  
-PERL          = @perl@
15  
-RM_F          = @rm_f@
16  
-CP            = @cp@
17  
-PARROT        = ../../parrot@exe@
18  
-CAT           = @cat@
19  
-BUILD_DYNPMC  = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
20  
-RECONFIGURE   = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl
21  
-#CONDITIONED_LINE(darwin):
22  
-#CONDITIONED_LINE(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking
23  
-#CONDITIONED_LINE(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@
24  
-
25  
-## places to look for things
26  
-PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext
27  
-PGE_LIBRARY   = $(BUILD_DIR)/runtime/parrot/library/PGE
28  
-PERL6GRAMMAR  = $(PGE_LIBRARY)/Perl6Grammar.pbc
29  
-NQP           = $(BUILD_DIR)/compilers/nqp/nqp.pbc
30  
-PCT           = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc
31  
-
32  
-PMC_DIR       = src/pmc
33  
-
34  
-all: APL.pbc
35  
-
36  
-APL_GROUP = $(PMC_DIR)/apl_group$(LOAD_EXT)
37  
-
38  
-SOURCES = APL.pir \
39  
-  src/gen_grammar.pir \
40  
-  src/gen_actions.pir \
41  
-  src/gen_builtins.pir \
42  
-  $(APL_GROUP)
43  
-
44  
-PMCS = aplvector
45  
-PMC_SOURCES = $(PMC_DIR)/aplvector.pmc
46  
-
47  
-# the default target
48  
-APL.pbc: $(PARROT) $(SOURCES) $(APL_GROUP)
49  
-	$(PARROT) $(PARROT_ARGS) -o APL.pbc APL.pir
50  
-
51  
-src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg
52  
-	$(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
53  
-	    --encoding=utf8 \
54  
-	    --output=src/gen_grammar.pir \
55  
-	    src/parser/grammar.pg
56  
-
57  
-src/gen_actions.pir: $(NQP) $(PCT) src/parser/actions.pm
58  
-	$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
59  
-	    --target=pir src/parser/actions.pm
60  
-
61  
-src/gen_builtins.pir: tools/gen_operator_defs.pl
62  
-	$(PERL) tools/gen_operator_defs.pl >src/gen_builtins.pir
63  
-
64  
-$(APL_GROUP): $(PARROT) $(PMC_SOURCES)
65  
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) generate $(PMCS)
66  
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) compile $(PMCS)
67  
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) linklibs $(PMCS)
68  
-	cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT) $(PMCS)
69  
-
70  
-# regenerate the Makefile
71  
-Makefile: config/makefiles/root.in
72  
-	cd $(BUILD_DIR) && $(RECONFIGURE) --step=gen::languages --languages=APL
73  
-
74  
-# This is a listing of all targets, that are meant to be called by users
75  
-help:
76  
-	@echo ""
77  
-	@echo "Following targets are available for the user:"
78  
-	@echo ""
79  
-	@echo "  all:               APL.pbc"
80  
-	@echo "                     This is the default."
81  
-	@echo "Testing:"
82  
-	@echo "  test:              Run the test suite."
83  
-	@echo "  testclean:         Clean up test results."
84  
-	@echo ""
85  
-	@echo "Cleaning:"
86  
-	@echo "  clean:             Basic cleaning up."
87  
-	@echo "  realclean:         Removes also files generated by 'Configure.pl'"
88  
-	@echo "  distclean:         Removes also anything built, in theory"
89  
-	@echo ""
90  
-	@echo "Misc:"
91  
-	@echo "  help:              Print this help message."
92  
-	@echo ""
93  
-
94  
-test: all
95  
-	$(PERL) t/harness
96  
-
97  
-testclean:
98  
-	$(RM_F) t/*.pir
99  
-
100  
-CLEANUPS = \
101  
-  APL.pbc \
102  
-  src/gen_grammar.pir \
103  
-  src/gen_actions.pir \
104  
-  src/gen_builtins.pir \
105  
-  $(PMC_DIR)/*.h \
106  
-  $(PMC_DIR)/*.c \
107  
-  $(PMC_DIR)/*.dump \
108  
-  $(PMC_DIR)/*$(O) \
109  
-  $(PMC_DIR)/*$(LOAD_EXT) \
110  
-  $(PMC_DIR)/*.exp \
111  
-  $(PMC_DIR)/*.ilk \
112  
-  $(PMC_DIR)/*.manifest \
113  
-  $(PMC_DIR)/*.pdb \
114  
-  $(PMC_DIR)/*.lib \
115  
-
116  
-
117  
-clean: testclean
118  
-	$(RM_F) $(CLEANUPS)
119  
-
120  
-realclean: clean
121  
-	$(RM_F) Makefile
122  
-
123  
-distclean: realclean
124  
-
125  
-# Local variables:
126  
-#   mode: makefile
127  
-# End:
128  
-# vim: ft=make:
3  languages/APL/demo.apl
... ...
@@ -1,3 +0,0 @@
1  
-10×2
2  
-X←8+3
3  
-X÷2
167  languages/APL/src/parser/actions.pm
... ...
@@ -1,167 +0,0 @@
1  
-# Copyright (C) 2008, Parrot Foundation.
2  
-# $Id$
3  
-
4  
-=begin comments
5  
-
6  
-APL::Grammar::Actions - ast transformations for APL
7  
-
8  
-This file contains the methods that are used by the parse grammar
9  
-to build the PAST representation of an APL program.
10  
-Each method below corresponds to a rule in F<src/parser/grammar.pg>,
11  
-and is invoked at the point where C<{*}> appears in the rule,
12  
-with the current match object as the first argument.  If the
13  
-line containing C<{*}> also has a C<#= key> comment, then the
14  
-value of the comment is passed as the second argument to the method.
15  
-
16  
-=end comments
17  
-
18  
-class APL::Grammar::Actions;
19  
-
20  
-method TOP($/) {
21  
-    my $catchpir := "    get_results '0', $P0\n    $S0 = $P0\n    print $S0\n    .return ($P0)\n";
22  
-    my $past := PAST::Block.new(
23  
-                    PAST::Op.new( $( $<statement_list> ),
24  
-                              PAST::Op.new( :inline( $catchpir) ),
25  
-                              :pasttype('try'),
26  
-                              :node($/) ),
27  
-                        :hll('apl') );
28  
-    make $past;
29  
-}
30  
-
31  
-method statement_list($/) {
32  
-    my $past := PAST::Stmts.new( :node($/) );
33  
-    for $<statement> {
34  
-        $past.push( $( $_ ) );
35  
-    }
36  
-    make $past;
37  
-}
38  
-
39  
-method statement($/) {
40  
-    my $past := $( $<expression> );
41  
-    if $past.WHAT() ne 'Op' || $past.pasttype() ne 'copy' {
42  
-        $past := PAST::Op.new( $past, :name('aplprint'), :node( $/ ) );
43  
-    }
44  
-    make $past;
45  
-}
46  
-
47  
-
48  
-method expression($/, $key) {
49  
-    our %inlinetable;
50  
-    if ($key eq 'assign') {
51  
-        my $past := PAST::Op.new( $($<target>),
52  
-                                  $($<expression>),
53  
-                                  :pasttype('copy'),
54  
-                                  :node($/) );
55  
-        make $past;
56  
-    }
57  
-    elsif ($key eq 'monadic') {
58  
-        my $name := 'monadic:' ~ $<monadic_identifier>;
59  
-        my $past := PAST::Op.new( $($<expression>), :node($/) );
60  
-        if %inlinetable{$name} {
61  
-            $past.inline( %inlinetable{$name} );
62  
-        }
63  
-        else {
64  
-            $past.name($name);
65  
-        }
66  
-        make $past;
67  
-    }
68  
-    else {
69  
-        my $past := $( $<subexpression> );
70  
-        if $<dyadic_identifier>[0] {
71  
-            my $name := 'dyadic:' ~ $<dyadic_identifier>[0];
72  
-            $past := PAST::Op.new( $past,
73  
-                                   $($<expression>[0]),
74  
-                                   :node($/) );
75  
-            if %inlinetable{$name} {
76  
-                $past.inline(%inlinetable{$name});
77  
-            }
78  
-            else {
79  
-                $past.name($name);
80  
-            }
81  
-        }
82  
-        make $past;
83  
-    }
84  
-}
85  
-
86  
-
87  
-method subexpression($/) {
88  
-    make $( $<simple_expression> );
89  
-}
90  
-
91  
-
92  
-method simple_expression($/, $key) {
93  
-    make $( $/{$key} );
94  
-}
95  
-
96  
-method target($/) {
97  
-    my $past := $( $<variable_identifier> );
98  
-    $past.lvalue(1);
99  
-    make $past;
100  
-}
101  
-
102  
-method array_identifier($/, $key) {
103  
-    make $( $/{$key} );
104  
-}
105  
-
106  
-method constant($/, $key) {
107  
-    make $( $/{$key} );
108  
-}
109  
-
110  
-method numeric_constant($/) {
111  
-    if +$<decimal_representation> != 1 {
112  
-        my $past := PAST::Op.new( :name('aplvector'), :node($/) );
113  
-        for $<decimal_representation> {
114  
-            $past.push( $( $_ ) );
115  
-        }
116  
-        make $past;
117  
-    }
118  
-    else {
119  
-        make $( $<decimal_representation>[0] );
120  
-    }
121  
-}
122  
-
123  
-method decimal_representation($/) {
124  
-    my $value := ~$/;
125  
-    $value.replace("\x207b", '-');
126  
-    PIR q<    $P0 = find_lex '$value'  >;
127  
-    PIR q<    $S0 = $P0                >;
128  
-    PIR q<    $I0 = index $S0, '.'     >;
129  
-    PIR q<    unless $I0 < 0 goto ffff >;
130  
-    PIR q<    $I0 = index $S0, 'E'     >;
131  
-    PIR q<    unless $I0 < 0 goto ffff >;
132  
-    PIR q<    concat $P0, '.'          >;
133  
-    PIR q<  ffff:                      >;
134  
-    make PAST::Val.new( :value($value), :returns('Float'), :node($/) );
135  
-}
136  
-
137  
-method variable_identifier($/) {
138  
-    make PAST::Var.new( :name( ~$/ ),
139  
-                        :viviself('Undef'),
140  
-                        :scope('package'),
141  
-                        :node( $/ ) );
142  
-}
143  
-
144  
-method character_constant_double($/) {
145  
-    my $value := ~$/[0];
146  
-    $value.replace('""', '"');
147  
-    make PAST::Op.new( PAST::Val.new( :value($value) ),
148  
-                       :name('aplstring'),
149  
-                       :node( $/ ) );
150  
-}
151  
-
152  
-method character_constant_single($/) {
153  
-    my $value := ~$/[0];
154  
-    $value.replace("''", "'");
155  
-    make PAST::Op.new( PAST::Val.new( :value($value) ),
156  
-                       :name('aplstring'),
157  
-                       :node( $/ ) );
158  
-}
159  
-
160  
-
161  
-# Local Variables:
162  
-#   mode: cperl
163  
-#   cperl-indent-level: 4
164  
-#   fill-column: 100
165  
-# End:
166  
-# vim: expandtab shiftwidth=4:
167  
-
62  languages/APL/src/parser/grammar.pg
... ...
@@ -1,62 +0,0 @@
1  
-grammar APL::Grammar is PCT::Grammar;
2  
-
3  
-## C<TOP> defines the top level rule to the HLLCompiler
4  
-token TOP { <statement_list>  {*} }
5  
-
6  
-token statement_list { ^<statement> [ \n <statement> ]* {*} }
7  
-
8  
-token statement { <expression> [ \s*? $$ | <panic: 'Syntax error'> ] {*} }
9  
-
10  
-token expression {
11  
-    | <target> '←' <expression> {*}                             #= assign
12  
-    | <monadic_identifier> <expression> {*}                     #= monadic
13  
-    | <subexpression> [ <dyadic_identifier> <expression> ]? {*} #= dyadic
14  
-}
15  
-
16  
-token subexpression {
17  
-    <simple_expression> [ '[' <llist> ']' ]? {*}
18  
-}
19  
-
20  
-token simple_expression {
21  
-    | <array_identifier> {*}                     #= array_identifier
22  
-    | '(' <expression> ')' {*}                   #= expression
23  
-}
24  
-
25  
-token target { <variable_identifier> [ '[' <llist> ']' ]? {*} }
26  
-
27  
-token llist { $0=(<expression>?) $0=( ';' <expression>? )* }
28  
-
29  
-token dyadic_identifier  { <[|⍟*⌈⌊○!+−×÷~∧∨⍲⍱<≤=≥>≠⍳⊖↑↓⍴⍕]> }
30  
-
31  
-token monadic_identifier {
32  
-    '⎕←' |
33  
-    <[|⍟*⌈⌊○!+−×÷~⍳⌽↑⍴⍕]>
34  
-}
35  
-
36  
-token array_identifier {
37  
-    | <constant> {*}                             #= constant
38  
-    | <variable_identifier> {*}                  #= variable_identifier
39  
-}
40  
-
41  
-token constant {
42  
-    | <character_constant_double> {*}            #= character_constant_double
43  
-    | <character_constant_single> {*}            #= character_constant_single
44  
-    | <numeric_constant> {*}                     #= numeric_constant
45  
-}
46  
-
47  
-
48  
-token numeric_constant {
49  
-    <decimal_representation> [ \s+ <decimal_representation> ]*
50  
-    {*}
51  
-}
52  
-
53  
-
54  
-token decimal_representation {
55  
-    [ '⁻'? \d+ '.'? \d* | '⁻'? '.' \d+ ] [ 'E' '⁻'? \d+ ]?
56  
-    {*}
57  
-}
58  
-
59  
-token character_constant_double { \" ( [ \"\" | <-["]> ]* ) \" {*} }
60  
-token character_constant_single { \' ( [ \'\' | <-[']> ]* ) \' {*} }
61  
-
62  
-token variable_identifier { <[A..Za..z]> <[A..Za..z0..9_]>* {*} }
204  languages/APL/src/pmc/aplvector.pmc
... ...
@@ -1,204 +0,0 @@
1  
-/*
2  
-Copyright (C) 2001-2003, Parrot Foundation.
3  
-$Id$
4  
-
5  
-
6  
-=head1 NAME
7  
-
8  
-src/pmc/APLVector.pmc - APLVector
9  
-
10  
-=head1 DESCRIPTION
11  
-
12  
-These are the vtable functions for the APL Vector class.
13  
-
14  
-=cut
15  
-
16  
-=head2 Helper functions
17  
-
18  
-=over 4
19  
-
20  
-=item INTVAL size_of_shape(INTERP, PMC)
21  
-
22  
-=cut
23  
-
24  
-*/
25  
-
26  
-#include "parrot/parrot.h"
27  
-
28  
-static INTVAL
29  
-size_of_shape(Interp *interp, PMC* self, PMC* shape)
30  
-{
31  
-    INTVAL retval;
32  
-    INTVAL dimension;
33  
-    INTVAL length;
34  
-    INTVAL pos;
35  
-
36  
-    if (!shape || PMC_IS_NULL(shape)) {
37  
-        /* not set, so a simple 1D */
38  
-        return VTABLE_get_integer(interp, self);
39  
-    }
40  
-
41  
-    retval = 1;
42  
-    dimension = VTABLE_get_integer(interp, shape);
43  
-    for (pos = 0; pos < dimension; pos++)
44  
-    {
45  
-        length = VTABLE_get_integer_keyed_int(interp, shape, pos);
46  
-        retval *= length;
47  
-    }
48  
-    return retval;
49  
-}
50  
-
51  
-/*
52  
-
53  
-=back
54  
-
55  
-=head2 Methods
56  
-
57  
-=over 4
58  
-
59  
-=cut
60  
-
61  
-*/
62  
-
63  
-
64  
-
65  
-
66  
-pmclass APLVector
67  
-    extends ResizablePMCArray
68  
-    provides array
69  
-    group   apl_group
70  
-
71  
-    need_ext
72  
-    dynpmc
73  
-    {
74  
-
75  
-/*
76  
-
77  
-=item C<void class_init()>
78  
-
79  
-initialize the pmc class. Store some constants, etc.
80  
-
81  
-=cut
82  
-
83  
-*/
84  
-
85  
-    /* RT#48194: move any constant string declarations here so we just do them once. */
86  
-    void class_init() {
87  
-    }
88  
-
89  
-
90  
-/*
91  
-
92  
-=item C<PMC* init()>
93  
-
94  
-initialize the instance.
95  
-
96  
-=cut
97  
-
98  
-*/
99  
-
100  
-void init() {
101  
-    SUPER();
102  
-};
103  
-
104  
-/*
105  
-
106  
-=item C<PMC* get_shape()>
107  
-
108  
-Returns a vector-like PMC containing the shape of this PMC.
109  
-
110  
-=cut
111  
-
112  
-*/
113  
-
114  
-    METHOD PMC* get_shape() {
115  
-        PMC* shape;
116  
-        INTVAL array_t;
117  
-        STRING* property_name;
118  
-
119  
-        property_name = string_from_literal(INTERP, "shape");
120  
-        shape = VTABLE_getprop(INTERP, SELF, property_name);
121  
-        if (PMC_IS_NULL(shape)) {
122  
-           /*
123  
-            * No shape has been set yet. This means that we are
124  
-            * a simple vector
125  
-            *
126  
-            * we use our own type here. Perhaps a better way to
127  
-            * specify it?
128  
-            */
129  
-            /*
130  
-            array_t = pmc_type(INTERP,
131  
-                string_from_literal(INTERP, "APLVector"));
132  
-            */
133  
-            shape = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
134  
-
135  
-            VTABLE_set_integer_native(INTERP, shape, 1);
136  
-            VTABLE_set_integer_keyed_int(INTERP, shape, 0,
137  
-                VTABLE_get_integer(INTERP, SELF));
138  
-            VTABLE_setprop(INTERP, SELF, property_name, shape);
139  
-        }
140  
-        RETURN(PMC* shape);
141  
-    }
142  
-
143  
-/*
144  
-
145  
-=item C<PMC* set_shape()>
146  
-
147  
-Reshape the existing APLvector by passing in an existing vector.
148  
-
149  
-If the new shape is larger than our old shape, pad the end of the APLv
150  
-with elements from the beginning.
151  
-
152  
-If the new shape is shorter than our old shape, truncate elements from
153  
-the end of the APLv.
154  
-
155  
-=cut
156  
-
157  
-*/
158  
-
159  
-
160  
-    METHOD set_shape(PMC *new_shape) {
161  
-        STRING* property_name;
162  
-        PMC*    old_shape;
163  
-        INTVAL  old_size, new_size, pos;
164  
-
165  
-        /* save the old shape momentarily, set the new shape */
166  
-        property_name = string_from_literal(INTERP, "shape");
167  
-        old_shape = VTABLE_getprop(INTERP, SELF, property_name);
168  
-        VTABLE_setprop(INTERP, SELF, property_name, new_shape);
169  
-
170  
-        /* how big are these shapes? */
171  
-        old_size = size_of_shape(INTERP, SELF, old_shape);
172  
-        new_size = size_of_shape(INTERP, SELF, new_shape);
173  
-
174  
-        if (old_size > new_size) {
175  
-            for (; new_size != old_size; new_size++) {
176  
-                VTABLE_pop_pmc(INTERP, SELF);
177  
-            }
178  
-        } else if (new_size > old_size) {
179  
-            pos = 0;
180  
-            for (; new_size != old_size; old_size++, pos++) {
181  
-                /* RT#48196 clone this? */
182  
-                VTABLE_push_pmc(INTERP, SELF,
183  
-                    VTABLE_get_pmc_keyed_int(INTERP, SELF, pos));
184  
-            }
185  
-        }
186  
-    }
187  
-
188  
-/*
189  
-
190  
-=back
191  
-
192  
-=cut
193  
-
194  
-*/
195  
-
196  
-}
197  
-
198  
-
199  
-/*
200  
- * Local variables:
201  
- *   c-file-style: "parrot"
202  
- * End:
203  
- * vim: expandtab shiftwidth=4:
204  
- */
95  languages/APL/t/APL.pm
... ...
@@ -1,95 +0,0 @@
1  
-package t::APL;
2  
-
3  
-# Copyright (C) 2006-2007, Parrot Foundation.
4  
-# $Id$
5  
-
6  
-# Fail a little more gracefully for those without Test::Base installed.
7  
-
8  
-use strict;
9  
-use warnings;
10  
-
11  
-BEGIN {
12  
-    eval {
13  
-        require Test::Base;
14  
-        import Test::Base qw/ -Base /;
15  
-    };
16  
-    if ($@) {
17  
-        eval 'use Test::More skip_all => "APL tests require Test::Base.;";';
18  
-        exit 0;
19  
-    }
20  
-}
21  
-
22  
-use Parrot::Config;
23  
-use Parrot::Test;
24  
-
25  
-our @EXPORT = qw(run_apl_is);
26  
-
27  
-#BEGIN {
28  
-#  # APL *really* needs unicode to function, bail out if we don't have it.
29  
-#  if (!$PConfig{has_icu}) {
30  
-#    plan skip_all => "No unicode library available.";
31  
-#    exit 0;
32  
-#  }
33  
-#}
34  
-
35  
-# Note - we don't just use the special SKIP entry in the DATA stream because
36  
-# it doesn't actually output the skipped test in the TAP output. It just
37  
-# fails to run the test.
38  
-
39  
-# mark todo tests with TODO - but, unless an environment variable is set,
40  
-# skip the tests - speed things up for end users, give developers the ability
41  
-# to easily see if anything new is passing.
42  
-
43  
-sub run_apl_is() {
44  
-    foreach my $block (blocks) {
45  
-        my $apl = $block->APL;
46  
-        my $output;
47  
-        if ( defined( $block->out ) ) {
48  
-            $output = $block->out;
49  
-            if ($output) {
50  
-                $output .= "\n";    # XXX a slight hack
51  
-            }
52  
-            else {
53  
-                $output = "0\n"
54  
-                    ; # XXX MAJOR hack - Test::Base is borkedly converting the 0 into the empty string. Why?
55  
-            }
56  
-        }
57  
-        else {
58  
-            $output = "\n";    # this lets todo tests not bother specifying an out.
59  
-                               # XXX also gives us a way to specify a blank output,
60  
-                               # Since we're converting an explicit blank output to 0
61  
-        }
62  
-        if ( $output =~ m/\n\n$/smx ) {
63  
-            chomp $output;     # XXX Keep hackin' it up!
64  
-        }
65  
-
66  
-        my $todo = $block->todo;
67  
-        if ( defined($todo) ) {
68  
-            if ( !$todo ) {
69  
-                $todo = "not implemented";
70  
-            }
71  
-            if ( $ENV{APLDEV} ) {
72  
-            TODO: {
73  
-                    local $TODO = $todo;
74  
-                    Parrot::Test::language_output_is( 'APL', $apl, $output, $block->name );
75  
-                }
76  
-            }
77  
-            else {
78  
-            SKIP: {
79  
-                    skip( "not implemented", 1 );
80  
-                    Parrot::Test::language_output_is( 'APL', $apl, $output, $block->name );
81  
-                }
82  
-            }
83  
-        }
84  
-        else {
85  
-            Parrot::Test::language_output_is( 'APL', $apl, $output, $block->name );
86  
-        }
87  
-    }
88  
-}
89  
-
90  
-# Local Variables:
91  
-#   mode: cperl
92  
-#   cperl-indent-level: 4
93  
-#   fill-column: 100
94  
-# End:
95  
-# vim: expandtab shiftwidth=4:
37  languages/APL/t/characters.t
... ...
@@ -1,37 +0,0 @@
1  
-#! perl
2  
-
3  
-# Copyright (C) 2006-2007, Parrot Foundation.
4  
-# $Id$
5  
-
6  
-use strict;
7  
-use warnings;
8  
-use lib qw( APL . lib ../lib ../../lib ../../../lib);
9  
-use t::APL tests => 6;
10  
-
11  
-run_apl_is();
12  
-
13  
-__DATA__
14  
-
15  
-=== double quotes
16  
---- APL: "testing"
17  
---- out: testing
18  
-
19  
-=== double quote, embedded double
20  
---- APL: "he said, ""she said."""
21  
---- out: he said, "she said."
22  
-
23  
-=== double quote, embedded single
24  
---- APL: "he said, ''he can't.''"
25  
---- out: he said, ''he can't.''
26  
-
27  
-=== single quotes
28  
---- APL: 'testing'
29  
---- out: testing
30  
-
31  
-=== single quotes, embedded single
32  
---- APL: 'surely you can''t be serious.'
33  
---- out: surely you can't be serious.
34  
-
35  
-=== single quote, embedded double
36  
---- APL: '""and?""'
37  
---- out: ""and?""
422  languages/APL/t/dyadic.t
... ...
@@ -1,422 +0,0 @@
1  
-#!perl
2  
-
3  
-# Copyright (C) 2006-2007, Parrot Foundation.
4  
-# $Id$
5  
-
6  
-use strict;
7  
-use warnings;
8  
-use lib qw(APL . lib ../lib ../../lib ../../../lib);
9  
-use t::APL tests => 100;
10  
-
11  
-diag "need more tests to test int <op> int, float <op> float, etc.";
12  
-
13  
-run_apl_is();
14  
-
15  
-__DATA__
16  
-
17  
-=== plus scalar (int/int)
18  
---- APL: 2+2
19  
---- out: 4
20  
-
21  
-=== plus scalar (int/float)
22  
---- APL: 2+3.14
23  
---- out: 5.14
24  
-
25  
-=== plus vector, float
26  
---- APL: 1 2 3 4+3.14
27  
---- out: 4.14 5.14 6.14 7.14
28  
-
29  
-=== plus float, vector
30  
---- APL: 3.14+1 2 3 4
31  
---- out: 4.14 5.14 6.14 7.14
32  
-
33  
-=== plus vector
34  
---- APL: 1 2 3 4+1.1 2.2 3.3 4.4
35  
---- out: 2.1 4.2 6.3 8.4
36  
-
37  
-=== plus domain
38  
---- APL: 1+'TEA'
39  
---- out: DOMAIN ERROR
40  
-
41  
-=== minus scalar (int/int)
42  
---- APL: 2−3
43  
---- out: ⁻1
44  
-
45  
-=== minus scalar
46  
---- APL: 2−3.14
47  
---- out: ⁻1.14
48  
-
49  
-=== minus vector, float
50  
---- APL: 1 2 3 4−3.14
51  
---- out: ⁻2.14 ⁻1.14 ⁻0.14 0.86
52  
-
53  
-=== minus float, vector
54  
---- APL: 3.14−1 2 3 4
55  
---- out: 2.14 1.14 0.14 ⁻0.86
56  
-
57  
-=== minus vector
58  
---- APL: 1 2 3 4−1.1 2.2 3.3 4.4
59  
---- out: ⁻0.1 ⁻0.2 ⁻0.3 ⁻0.4
60  
-
61  
-=== minus domain
62  
---- APL: 2−'TEA'
63  
----