[svn:parrot] r45953 - in trunk: . compilers/nqp compilers/nqp/bootstrap compilers/nqp/bootstrap/t compilers/nqp/src compilers/nqp/src/Grammar compilers/nqp/t config/gen/makefiles
bacek at svn.parrot.org
bacek at svn.parrot.org
Sat Apr 24 02:23:43 UTC 2010
Author: bacek
Date: Sat Apr 24 02:23:42 2010
New Revision: 45953
URL: https://trac.parrot.org/parrot/changeset/45953
Log:
Remove deprecated compiler/nqp. Welcome to brave new world of nqp-rx.
Closing TT#1462
Deleted:
trunk/compilers/nqp/Defines.mak
trunk/compilers/nqp/README.pod
trunk/compilers/nqp/Rules.mak
trunk/compilers/nqp/TODO.pod
trunk/compilers/nqp/bootstrap/actions.pm
trunk/compilers/nqp/bootstrap/nqp.pir
trunk/compilers/nqp/bootstrap/t/harness
trunk/compilers/nqp/nqp.pir
trunk/compilers/nqp/src/Grammar.pg
trunk/compilers/nqp/src/Grammar/Actions.pir
trunk/compilers/nqp/src/builtins.pir
trunk/compilers/nqp/t/01-literals.t
trunk/compilers/nqp/t/02-if-else.t
trunk/compilers/nqp/t/02-if.t
trunk/compilers/nqp/t/03-unless.t
trunk/compilers/nqp/t/04-comments.t
trunk/compilers/nqp/t/05-pod.t
trunk/compilers/nqp/t/06-args-pos.t
trunk/compilers/nqp/t/07-boolean.t
trunk/compilers/nqp/t/08-blocks.t
trunk/compilers/nqp/t/09-var.t
trunk/compilers/nqp/t/10-sub.t
trunk/compilers/nqp/t/11-cmp.t
trunk/compilers/nqp/t/12-list.t
trunk/compilers/nqp/t/13-logical.t
trunk/compilers/nqp/t/14-op.t
trunk/compilers/nqp/t/15-module.t
trunk/compilers/nqp/t/16-while.t
trunk/compilers/nqp/t/17-class.t
trunk/compilers/nqp/t/18-inline.t
trunk/compilers/nqp/t/19-hash_access.t
trunk/compilers/nqp/t/20-list_access.t
trunk/compilers/nqp/t/22-optional_args.t
trunk/compilers/nqp/t/23-named_args.t
trunk/compilers/nqp/t/24-scalar_context.t
trunk/compilers/nqp/t/25-list_context.t
trunk/compilers/nqp/t/26-method_ops.t
trunk/compilers/nqp/t/27-ternary.t
trunk/compilers/nqp/t/28-return.t
trunk/compilers/nqp/t/29-self.t
trunk/compilers/nqp/t/30-subclass.t
trunk/compilers/nqp/t/harness
Modified:
trunk/MANIFEST
trunk/config/gen/makefiles/root.in
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST Sat Apr 24 01:26:30 2010 (r45952)
+++ trunk/MANIFEST Sat Apr 24 02:23:42 2010 (r45953)
@@ -85,48 +85,6 @@
compilers/ncigen/t/parse_00.t [test]
compilers/ncigen/t/parse_01.t [test]
compilers/ncigen/t/parse_02.t [test]
-compilers/nqp/Defines.mak [nqp]
-compilers/nqp/README.pod []doc
-compilers/nqp/Rules.mak [nqp]
-compilers/nqp/TODO.pod [nqp]
-compilers/nqp/bootstrap/actions.pm [nqp]
-compilers/nqp/bootstrap/nqp.pir [nqp]
-compilers/nqp/bootstrap/t/harness [test]
-compilers/nqp/nqp.pir [nqp]
-compilers/nqp/src/Grammar.pg [nqp]
-compilers/nqp/src/Grammar/Actions.pir [nqp]
-compilers/nqp/src/builtins.pir [nqp]
-compilers/nqp/t/01-literals.t [test]
-compilers/nqp/t/02-if-else.t [test]
-compilers/nqp/t/02-if.t [test]
-compilers/nqp/t/03-unless.t [test]
-compilers/nqp/t/04-comments.t [test]
-compilers/nqp/t/05-pod.t [test]
-compilers/nqp/t/06-args-pos.t [test]
-compilers/nqp/t/07-boolean.t [test]
-compilers/nqp/t/08-blocks.t [test]
-compilers/nqp/t/09-var.t [test]
-compilers/nqp/t/10-sub.t [test]
-compilers/nqp/t/11-cmp.t [test]
-compilers/nqp/t/12-list.t [test]
-compilers/nqp/t/13-logical.t [test]
-compilers/nqp/t/14-op.t [test]
-compilers/nqp/t/15-module.t [test]
-compilers/nqp/t/16-while.t [test]
-compilers/nqp/t/17-class.t [test]
-compilers/nqp/t/18-inline.t [test]
-compilers/nqp/t/19-hash_access.t [test]
-compilers/nqp/t/20-list_access.t [test]
-compilers/nqp/t/22-optional_args.t [test]
-compilers/nqp/t/23-named_args.t [test]
-compilers/nqp/t/24-scalar_context.t [test]
-compilers/nqp/t/25-list_context.t [test]
-compilers/nqp/t/26-method_ops.t [test]
-compilers/nqp/t/27-ternary.t [test]
-compilers/nqp/t/28-return.t [test]
-compilers/nqp/t/29-self.t [test]
-compilers/nqp/t/30-subclass.t [test]
-compilers/nqp/t/harness [test]
compilers/pct/Defines.mak [pct]
compilers/pct/PCT.pir [pct]
compilers/pct/README.pod []doc
Deleted: trunk/compilers/nqp/Defines.mak
==============================================================================
--- trunk/compilers/nqp/Defines.mak Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,7 +0,0 @@
-NQP_LIB_PBCS = compilers/nqp/nqp.pbc
-
-NQP_CLEANUPS = \
- compilers/nqp/nqp.pbc \
- compilers/nqp/src/Grammar_gen.pir \
- compilers/nqp/bootstrap/gen_actions.pir \
- compilers/nqp/bootstrap/nqp.pbc
Deleted: trunk/compilers/nqp/README.pod
==============================================================================
--- trunk/compilers/nqp/README.pod Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,95 +0,0 @@
-## $Id$
-
-=head1 NQP - Not Quite Perl (6)
-
-This is "Not Quite Perl" -- a compiler for quickly generating PIR
-routines from Perl6-like code. The key feature of NQP is that it's
-designed to be a very small compiler (as compared with, say, perl6
-or Rakudo) and is focused on being a high-level way to create
-transformers for Parrot (especially hll compilers). In addition,
-unlike Rakudo, NQP attempts to restrict itself to generating code
-that can run in Parrot without the existence of any NQP-specific
-runtime libraries.
-
-One way that NQP aims to be a lighter version of Perl 6 is by
-avoiding syntactic sugar and "dwimminess" that isn't needed
-for the types of routines that are written. Sometimes this
-makes coding a bit more work, but it also lowers the learning
-curve somewhat.
-
-
-=head2 Things that NQP has (or should have)
-
-This list isn't exhaustive; for now it's intended to identify the
-language constructs that we explicitly know will be supported
-
-=over 4
-
-=item * scalars
-
-=item * binding
-
-=item * lexical 'my', package 'our'
-
-=item * method calls (including named, optional, and slurpy arguments)
-
-=item * subroutine calls (including named, optional, and slurpy arguments)
-
-=item * method definitions
-
-=item * subroutine definitions
-
-=item * '...' # string constants
-
-=item * "..." # string value with escapes (non-interpolating)
-
-=item * postcircumfix:<[ ]> # array subscript
-
-=item * postcircumfix:<{ }> # hash subscript
-
-=item * postcircumfix:«< >» # constant hash subscript
-
-=item * $<...> # constant hash subscript of $/
-
-=item * $(...) # scalar context
-
-=item * prefix:~ # string context
-
-=item * prefix:+ # numeric context
-
-=item * say(), print() # output
-
-=item * if/unless # conditional
-
-=item * for # iterative loop
-
-=item * PIR q<>, PIR q:to:<END> # inline PIR
-
-=back
-
-=head2 Things that aren't in NQP
-
-There are a large number of Perl 6 constructs and idioms that
-aren't supported or expected to be supported in NQP. This
-is by design -- the point of NQP is to provide a lightweight
-HLL for generating PIR subroutines while adhering to a Perl 6
-syntax.
-
-Some items not planned for NQP:
-
-=over 4
-
-=item * string interpolation
-
-=item * listops
-
-=item * quoted lists
-
-=item * array and hash slices
-
-=back
-
-Of course, if we later decide that some item is vitally
-important for NQP programs, we can add it -- but for now
-the point is to maintain a minimal set of constructs.
-
Deleted: trunk/compilers/nqp/Rules.mak
==============================================================================
--- trunk/compilers/nqp/Rules.mak Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,21 +0,0 @@
-compilers/nqp/nqp.pbc : compilers/nqp/src/builtins.pir \
- compilers/nqp/src/Grammar/Actions.pir \
- compilers/nqp/src/Grammar_gen.pir \
- $(LIBRARY_DIR)/PCT.pbc \
- $(LIBRARY_DIR)/PGE.pbc
-
-compilers/nqp/src/Grammar_gen.pir : $(PARROT) $(LIBRARY_DIR)/PGE/Perl6Grammar.pir compilers/nqp/src/Grammar.pg $(LIBRARY_DIR)/PCT/HLLCompiler.pbc $(LIBRARY_DIR)/PGE.pbc
- $(PARROT) $(LIBRARY_DIR)/PGE/Perl6Grammar.pir --output=$@ compilers/nqp/src/Grammar.pg
-
-# Developer target to regnerate bootstrap. Unused?
-nqp-boot: \
- compilers/nqp/bootstrap/nqp.pir \
- compilers/nqp/bootstrap/gen_actions.pir
-
-compilers/nqp/bootstrap/gen_actions.pir : $(PARROT) \
- compilers/nqp/nqp.pbc \
- compilers/nqp/bootstrap/actions.pm
- $(PARROT) compilers/nqp/nqp.pbc --output=$@ --target=pir \
- compilers/nqp/bootstrap/actions.pm
-
-compilers/nqp/bootstrap/nqp.pbc : $(LIBRARY)/PCT.pbc
Deleted: trunk/compilers/nqp/TODO.pod
==============================================================================
--- trunk/compilers/nqp/TODO.pod Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,84 +0,0 @@
-## $Id$
-
-=head1 Things that NQP needs
-
-This list is based on discussions with pmichaud and unimplemented
-items in the grammar, C<src/Grammar.pg>.
-
-Last updated: 2007-11-24
-
-=head2 Code
-
-=over 4
-
-=item * C<&> sigil
-
-Handle the mapping between C<&foo> and 'foo' subroutines.
-
-=item * C<return> statement
-
-While it seems like implementing C<return> would be a simple
-matter of generating PIR C<.return> statements, it's not quite
-that simple, because C<return> statements can occur inside of
-nested blocks.
-
-So, we need an NQP C<return> statement to throw a "return exception",
-which is then caught by the outermost block of the currently
-executing subroutine and then used as the argument to C<.return>.
-
-Fortunately, the new design of S05 means that we don't really need
-return statements for developing action grammars, so this is no
-longer as much of a priority as it was.
-
-=back
-
-=head2 Tests
-
-=over 4
-
-=item * More tests for method ops
-
-We should be able to load an external module (Pm suggests Test.pbc)
-and exercise methods using that.
-
-=item * Match variable access C<$/>
-
-=item * More tests for scalar context $( ... )
-
-=item * More tests for list context @( ... )
-
-=item * Variables with twigils
-
-=item * More tests for optional arguments and parameters
-
-=item * More tests for named arguments and parameters
-
-=back
-
-=head2 Bootstrap
-
-The directory C<bootstrap> contains the necessary files to implement NPQ
-in NQP. While this is not a major goal, it is interesting to compare the
-speed of NQP implemented in PIR and in NQP. For this to work, some things
-must be fixed. The bootstrap version can be tested with
-
- cd bootstrap && perl t/harness
-
-=over 4
-
-=item * it seems that the action for the C<for-statement> is broken.
-
-=item * NQP should not have a runtime containing support routines. The
-original NQP (in PIR) implements all operators as PIR instructions. This
-should also be the case for the bootstrapped NQP. Currently, the optable
-action does not handle the "inline" specifications.
-
-=item * Some actions are not complete. For instance, the action method
-C<package_declarator>, where classes can be defined.
-
-=item * the NQP compiler driver should accept a commandline option indicating
-which Actions object should be used: the PIR or NQP version. HLLCompiler
-has support for adding commandline options, this could be used.
-
-=back
-
Deleted: trunk/compilers/nqp/bootstrap/actions.pm
==============================================================================
--- trunk/compilers/nqp/bootstrap/actions.pm Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,1035 +0,0 @@
-# Copyright (C) 2008-2008, Parrot Foundation.
-# $Id$
-
-
-
-
-class NQP::Grammar::Actions;
-
-
-method TOP($/) {
- my $past := $($<statement_block>);
- $past.blocktype('declaration');
- make $past;
-}
-##.sub 'TOP' :method
-## .param pmc match
-## .local pmc past
-## $P0 = match['statement_block']
-## past = $P0.'get_scalar'()
-## past.'blocktype'('declaration')
-## match.'result_object'(past)
-##.end
-
-
-#### Blocks and Statements ####
-
-method statement_block($/, $key) {
- our $?BLOCK;
- our @?BLOCK;
- if ($key eq 'open') {
- $?BLOCK := PAST::Block.new( PAST::Stmts.new( :node($/) ),
- :blocktype('immediate'),
- :node($/) );
- @?BLOCK.unshift($?BLOCK);
- }
- else {
- my $past := @?BLOCK.shift();
- $?BLOCK := @?BLOCK[0];
- $past.push($($<statement_list>));
- make $past;
- }
-}
-##.sub 'statement_block' :method
-## .param pmc match
-## .param string key
-## if key == 'close' goto block_close
-## block_open:
-## .local pmc past
-## $P1 = get_hll_global ['PAST'], 'Stmts'
-## $P2 = $P1.'new'()
-## $P0 = get_hll_global ['PAST'], 'Block'
-## past = $P0.'new'($P2, 'blocktype'=>'immediate', 'node'=>match)
-## set_global '$?BLOCK', past
-## $P0 = get_global '@?BLOCK'
-## unshift $P0, past
-## .return ()
-## block_close:
-## $P0 = get_global '@?BLOCK'
-## past = shift $P0
-## $P1 = $P0[0]
-## set_global '$?BLOCK', $P1
-## $P2 = match['statement_list']
-## $P3 = $P2.'get_scalar'()
-## past.'push'($P3)
-## match.'result_object'(past)
-##.end
-
-
-method statement_list($/) {
- my $past := PAST::Stmts.new(:node($/));
- for $<statement> {
- $past.push($($_));
- }
- make $past;
-}
-##.sub 'statement_list' :method
-## .param pmc match
-## .local pmc past
-## $P0 = get_hll_global ['PAST'], 'Stmts'
-## past = $P0.'new'('node'=>match)
-## $P1 = match['statement']
-## if null $P1 goto iter_end
-## .local pmc iter
-## iter = new 'Iterator', $P1
-## iter_loop:
-## unless iter goto iter_end
-## $P2 = shift iter
-## $P2 = $P2.'get_scalar'()
-## past.'push'($P2)
-## goto iter_loop
-## iter_end:
-## match.'result_object'(past)
-##.end
-
-
-method statement($/, $key) {
- make $($/{$key});
-}
-
-##.sub 'statement' :method
-## .param pmc match
-## .param string key
-## $P0 = match[key]
-## $P1 = $P0.'get_scalar'()
-## match.'result_object'($P1)
-##.end
-
-
-method if_statement($/) {
- my $cond := +$<EXPR> - 1;
- my $past := PAST::Op.new( $( $<EXPR>[$cond] ),
- $( $<block>[$cond] ),
- :pasttype('if'),
- :node( $/ )
- );
- if ( $<else> ) {
- $past.push( $( $<else>[0] ) );
- }
- while ($cond != 0) {
- $cond := $cond - 1;
- $past := PAST::Op.new( $( $<EXPR>[$cond] ),
- $( $<block>[$cond] ),
- $past,
- :pasttype('if'),
- :node( $/ )
- );
- }
- make $past;
-}
-##.sub 'if_statement' :method
-## .param pmc match
-## .local pmc expr, block, past
-## .local int cond
-## cond = match['EXPR']
-## cond -= 1
-## bsr get_expr
-## bsr get_block
-## $P2 = get_hll_global ['PAST'], 'Op'
-## past = $P2.'new'(expr, block, 'pasttype'=>'if', 'node'=>match)
-##
-## $I0 = exists match['else']
-## unless $I0 goto while
-## block = match['else']
-## block = block[0]
-## block = block.'get_scalar'()
-## past.'push'( block )
-##
-## while:
-## unless cond != 0 goto end_while
-## cond -= 1
-## bsr get_expr
-## bsr get_block
-## past = $P2.'new'(expr, block, past, 'pasttype'=>'if', 'node'=>match)
-## goto while
-##
-## end_while:
-## goto end
-##
-## get_expr:
-## expr = match['EXPR']
-## expr = expr[cond]
-## expr = expr.'get_scalar'()
-## ret
-## get_block:
-## block = match['block']
-## block = block[cond]
-## block = block.'get_scalar'()
-## ret
-## end:
-## match.'result_object'(past)
-##.end
-
-
-method unless_statement($/) {
- my $past := PAST::Op.new( $( $<EXPR> ),
- $( $<block> ),
- :pasttype('unless'),
- :node( $/ )
- );
- make $past;
-}
-##.sub 'unless_statement' :method
-## .param pmc match
-## .local pmc expr, block, past
-## expr = match['EXPR']
-## expr = expr
-## expr = expr.'get_scalar'()
-## block = match['block']
-## block = block
-## block = block.'get_scalar'()
-## $P0 = get_hll_global ['PAST'], 'Op'
-## past = $P0.'new'(expr, block, 'pasttype'=>'unless', 'node'=>match)
-## match.'result_object'(past)
-##.end
-
-
-method repeat_statement($/) {
- make PAST::Op.new( $($<EXPR>),
- $($<block>),
- :pasttype( 'repeat_' ~ $<sym> ),
- :node( $/ )
- );
-}
-##.sub 'repeat_statement' :method
-## .param pmc match
-## $P1 = match['EXPR']
-## $P1 = $P1.'get_scalar'()
-## $P2 = match['block']
-## $P2 = $P2.'get_scalar'()
-## $S0 = match['sym']
-## $S0 = concat 'repeat_', $S0
-## $P0 = get_hll_global ['PAST'], 'Op'
-## $P5 = $P0.'new'( $P1, $P2, 'pasttype'=>$S0, 'node'=>match)
-## match.'result_object'($P5)
-##.end
-
-
-method while_statement($/) {
- make PAST::Op.new( $($<EXPR>),
- $($<block>),
- :pasttype( ~$<sym> ),
- :node( $/ )
- );
-}
-##.sub 'while_statement' :method
-## .param pmc match
-## $P1 = match['EXPR']
-## $P1 = $P1.'get_scalar'()
-## $P2 = match['block']
-## $P2 = $P2.'get_scalar'()
-## $S0 = match['sym']
-## $P0 = get_hll_global ['PAST'], 'Op'
-## $P5 = $P0.'new'( $P1, $P2, 'pasttype'=>$S0, 'node'=>match)
-## match.'result_object'($P5)
-##.end
-
-
-method for_statement($/) {
- my $block := $( $<block> );
- $block.blocktype('declaration');
- $block.symbol( '$_', :scope('lexical'));
- my $topic_var := PAST::Var.new(:name('$_'), :scope('parameter'));
- $block[0].push($topic_var);
- my $past := PAST::Op.new($($<EXPR>),
- $($<block>),
- :pasttype(~$<sym>),
- :node($/));
- make $past;
-}
-##.sub 'for_statement' :method
-## .param pmc match
-## .local pmc block, past
-## $P0 = match['EXPR']
-## $P0 = $P0.'get_scalar'()
-## $P1 = match['block']
-## block = $P1.'get_scalar'()
-## block.'blocktype'('sub')
-## .local pmc params, topic_var
-## params = block[0]
-## $P3 = get_hll_global ['PAST'], 'Var'
-## topic_var = $P3.'new'('name'=>'$_', 'scope'=>'parameter')
-## params.'push'(topic_var)
-## block.'symbol'('$_', 'scope'=>'lexical')
-## $P2 = get_hll_global ['PAST'], 'Op'
-## $S1 = match['sym']
-## past = $P2.'new'($P0, block, 'pasttype'=>$S1, 'node'=>match)
-## match.'result_object'(past)
-##.end
-
-
-method make_statement($/) {
- make PAST::Op.new( PAST::Var.new( :name('$/'),
- :scope('lexical') ),
- $($<EXPR>),
- :name('result_object'),
- :pasttype('callmethod') );
-}
-##.sub 'make_statement' :method
-## .param pmc match
-## $P0 = get_hll_global ['PAST'], 'Var'
-## $P1 = $P0.'new'( 'name'=>'$/', 'scope'=>'lexical' )
-## $P2 = match['EXPR']
-## $P3 = $P2.'get_scalar'()
-## $P4 = get_hll_global ['PAST'], 'Op'
-## $P5 = $P4.'new'($P1, $P3, 'name'=>'result_object', 'pasttype'=>'callmethod')
-## match.'result_object'($P5)
-##.end
-
-
-method inline_pir_statement($/, $key) {
- my $inline;
- if ($key eq 'quote') { $inline := ~$($<quote><string_literal>) }
- if ($key eq 'heredoc') { $inline := ~$/<text> }
-
- make PAST::Op.new( :inline( $inline ),
- :pasttype('inline'),
- :node( $/ )
- );
-}
-##.sub 'inline_pir_statement' :method
-## .param pmc match
-## .param pmc key
-## .local pmc inline
-## if key != 'quote' goto not_quote
-## $P0 = match['quote']
-## $P0 = $P0['string_literal']
-## inline = $P0.'get_scalar'()
-## goto make
-## not_quote:
-## if key != 'heredoc' goto not_heredoc
-## $P0 = match['text']
-## inline = $P0.'text'()
-## not_heredoc:
-## make:
-## $P1 = get_hll_global ['PAST'], 'Op'
-## $P2 = $P1.'new'( 'inline'=>inline, 'pasttype'=>'inline', 'node'=>match)
-## match.'result_object'($P2)
-##.end
-
-
-method block($/) {
- make $($<statement_block>);
-}
-##.sub 'block' :method
-## .param pmc match
-## $P0 = match['statement_block']
-## $P0 = $P0.'get_scalar'()
-## match.'result_object'($P0)
-##.end
-
-
-#### Subroutine and method definitions ####
-
-method routine_def($/) {
- my $past := $($<block>);
- $past.name(~$<ident>);
- $past.node($/);
- $past.blocktype('declaration');
- my $params := $past[0];
- if $<declarator> eq 'method' {
- $past.blocktype('method');
- unshift $past, PAST::Op.new('inline'=>'.lex "self", self',
- 'pasttype'=>'inline');
- }
- for $<signature>[0] {
- my $parameter := $($_<parameter>);
- $past.symbol($parameter.name(), :scope('lexical'));
- $params.push($parameter);
- }
- make $past;
-}
-##.sub 'routine_def' :method
-## .param pmc match
-## .local pmc past
-## $P0 = match['block']
-## past = $P0.'get_scalar'()
-## $S0 = match['ident']
-## past.'name'($S0)
-## past.'node'(match)
-## past.'blocktype'('declaration')
-## .local pmc params
-## params = past[0]
-## $S0 = match['declarator']
-## if $S0 != 'method' goto add_signature
-## past.'blocktype'('method')
-## add_signature:
-## $P0 = match['signature']
-## $P0 = $P0[0]
-## unless $P0 goto param_end
-## .local pmc iter
-## iter = new 'Iterator', $P0
-## param_loop:
-## unless iter goto param_end
-## $P1 = shift iter
-## .local pmc parameter
-## $P2 = $P1['parameter']
-## parameter = $P2.'get_scalar'()
-## $S0 = parameter.'name'()
-## past.'symbol'($S0, 'scope'=>'lexical')
-## params.'push'(parameter)
-## goto param_loop
-## param_end:
-## match.'result_object'(past)
-##.end
-
-
-method parameter($/, $key) {
- my $past := $( $<param_var> );
- my $sigil := $<param_var><sigil>;
- if $key eq 'slurp' { # slurpy
- $past.slurpy( $sigil eq '@' || $sigil eq '%' );
- $past.named( $sigil eq '%' );
- }
- else {
- if $<named> eq ':' { # named
- $past.named(~$<param_var><ident>);
- if $<quant> ne '!' { # required (optional is default)
- $past.viviself('Undef');
- }
- }
- else { # positional
- if $<quant> eq '?' { # optional (required is default)
- $past.viviself('Undef');
- }
- }
- }
- make $past;
-}
-##.sub 'parameter' :method
-## .param pmc match
-## .param pmc key
-## .local pmc past, sigil
-## past = match['param_var']
-## past = past.'get_scalar'()
-## sigil = match['param_var';'sigil']
-## if key != 'slurp' goto not_slurp
-## if sigil != '@' goto not_slurpy_array
-## past.'slurpy'(1)
-## not_slurpy_array:
-## if sigil != '%' goto not_slurpy_hash
-## past.'slurpy'(1)
-## not_slurpy_hash:
-## if sigil != '%' goto not_slurp
-## past.'named'(1)
-## goto make_past
-## not_slurp:
-## $S0 = match['named']
-## if $S0 != ':' goto not_named
-## $S0 = match['param_var';'ident']
-## past.'named'($S0)
-## $S0 = match['quant']
-## if $S0 == '!' goto not_named
-## past.'viviself'('Undef')
-## not_named:
-## $S0 = match['quant']
-## if $S0 != '?' goto make_past
-## past.'viviself'('Undef')
-## make_past:
-## match.'result_object'(past)
-##.end
-
-
-method param_var($/) {
- make PAST::Var.new(:name(~$/),
- :scope('parameter'),
- :node($/) );
-}
-##.sub 'param_var' :method
-## .param pmc match
-## $S0 = match
-## $P0 = get_hll_global ['PAST'], 'Var'
-## $P1 = $P0.'new'('name'=>$S0, 'scope'=>'parameter', 'node'=>match)
-## match.'result_object'($P1)
-##.end
-
-
-#### Terms and expressions ####
-
-method term($/, $key) {
- my $past := $($<noun>);
- for $<postfix> {
- my $term := $past;
- $past := $($_);
- #print("term()");
- $past.unshift($term);
- }
- make $past;
-}
-##.sub 'term' :method
-## .param pmc match
-## .param pmc key
-## .local pmc past
-## $P0 = match['noun']
-## past = $P0.'get_scalar'()
-## $P1 = match['postfix']
-## if null $P1 goto end
-## .local pmc iter, term
-## iter = new 'Iterator', $P1
-## iter_loop:
-## unless iter goto end
-## $P2 = shift iter
-## term = past
-## past = $P2.'get_scalar'()
-## past.'unshift'(term)
-## goto iter_loop
-## end:
-## match.'result_object'(past)
-##.end
-
-
-method postfix($/, $key) {
- make $($/{$key});
-}
-##.sub 'postfix' :method
-## .param pmc match
-## .param string key
-## $P0 = match[key]
-## $P1 = $P0.'get_scalar'()
-## match.'result_object'($P1)
-##.end
-
-
-method methodop($/, $key) {
- my $past := $($<arglist>);
- $past.name(~$<ident>);
- $past.pasttype('callmethod');
- $past.node($/);
- make $past;
-}
-##.sub 'methodop' :method
-## .param pmc match
-## .param string key
-## .local pmc past
-## $P0 = match['arglist']
-## past = $P0.'get_scalar'()
-## $S0 = match['ident']
-## past.'name'($S0)
-## past.'pasttype'('callmethod')
-## past.'node'(match)
-## match.'result_object'(past)
-##.end
-
-
-method postcircumfix($/, $key) {
- if $key eq '( )' {
- my $past := $($<arglist>);
- $past.pasttype('call');
- $past.node($/);
- make $past;
- }
- elsif $key eq '< >' {
- my $value := PAST::Val.new( :value( $($<string_literal>) ) );
- make PAST::Var.new( $value,
- :scope('keyed'),
- :vivibase('Hash'),
- :viviself('Undef'),
- :node( $/ ) );
- }
- else {
- my $vivibase; ## := ($key eq '{ }') ? 'Hash' : 'ResizablePMCArray';
- if $key eq '{ }' {
- $vivibase := 'Hash';
- }
- else {
- $vivibase := 'ResizablePMCArray';
- }
- make PAST::Var.new( $($<EXPR>),
- :scope('keyed'),
- :vivibase($vivibase),
- :viviself('Undef'),
- :node($/) );
- }
-}
-##.sub 'postcircumfix' :method
-## .param pmc match
-## .param string key
-## .local pmc past
-## if key == '( )' goto subcall
-## if key == '< >' goto keyed_const
-## keyed_var:
-## .local string vivibase
-## vivibase = 'ResizablePMCArray'
-## if key != '{ }' goto keyed_array
-## vivibase = 'Hash'
-## keyed_array:
-## $P0 = get_hll_global ['PAST'], 'Var'
-## $P1 = match['EXPR']
-## $P2 = $P1.'get_scalar'()
-## $P3 = $P0.'new'( $P2, 'scope'=>'keyed', 'vivibase'=>vivibase, 'viviself'=>'Undef', 'node'=>match )
-## match.'result_object'($P3)
-## .return ()
-## subcall:
-## $P0 = match['arglist']
-## past = $P0.'get_scalar'()
-## past.'pasttype'('call')
-## past.'node'(match)
-## match.'result_object'(past)
-## .return ()
-## keyed_const:
-## $P0 = get_hll_global ['PAST'], 'Val'
-## $P1 = match['string_literal']
-## $P2 = $P1.'get_scalar'()
-## .local pmc value
-## value = $P0.'new'( 'value' => $P2, 'node'=> $P1 )
-## $P0 = get_hll_global ['PAST'], 'Var'
-## $P1 = $P0.'new'( value, 'scope'=>'keyed', 'vivibase'=>'Hash', 'viviself'=>'Undef', 'node'=>match)
-## match.'result_object'($P1)
-##.end
-
-
-method circumfix($/, $key) {
- my $expr := $($<EXPR>[0]);
- if $key eq '@( )' {
- make PAST::Op.new( $expr,
- :name('get_array'),
- :pasttype('callmethod'),
- :node($/) );
- }
- if $key eq '$( )' {
- make PAST::Op.new( $expr,
- :name('get_scalar'),
- :pasttype('callmethod'),
- :node($/) );
- }
- make $expr;
-}
-##.sub 'circumfix' :method
-## .param pmc match
-## .param string key
-## .local pmc past
-## $P0 = match['EXPR']
-## unless null $P0 goto have_expr
-## $P1 = match
-## goto get_past
-## have_expr:
-## $P1 = $P0[0]
-## get_past:
-## $P1 = $P1.'get_scalar'()
-## $P0 = get_hll_global ['PAST'], 'Op'
-## if key == '@( )' goto list_context
-## if key == '$( )' goto scalar_context
-## parenthetical:
-## match.'result_object'($P1)
-## .return ()
-## list_context:
-## past = $P0.'new'($P1, 'name' => 'get_array', 'pasttype'=>'callmethod', 'node'=>match)
-## match.'result_object'(past)
-## .return ()
-## scalar_context:
-## past = $P0.'new'($P1, 'name' => 'get_scalar', 'pasttype'=>'callmethod', 'node'=>match)
-## match.'result_object'(past)
-##.end
-
-#sub callarg($arg) {
-# if $arg.returns() eq 'Pair' {
-# $arg[1].named($arg[0]);
-# $arg := $arg[1];
-# }
-# return $arg;
-#}
-
-method arglist($/) {
- my $past := PAST::Op.new( :node($/) );
- if ($<EXPR>) {
- my $expr := $($<EXPR>[0]);
- if ($expr.name() eq 'infix:,') {
- for @($expr) {
- if $_.returns() eq 'Pair' {
- $_[1].named($_[0]);
- $_ := $_[1];
- }
- $past.push( $_ );
- }
- }
- else {
- if $expr.returns() eq 'Pair' {
- $expr[1].named($expr[0]);
- $expr := $expr[1];
- }
- $past.push( $expr );
- }
- }
- make $past;
-}
-##.sub 'arglist' :method
-## .param pmc match
-## .local pmc past
-## $P0 = get_hll_global ['PAST'], 'Op'
-## past = $P0.'new'( 'node'=>match )
-## $P1 = match['EXPR']
-## if null $P1 goto end
-## .local pmc expr, iter
-## $P2 = $P1[0]
-## expr = $P2.'get_scalar'()
-## $S0 = expr.'name'()
-## if $S0 != 'infix:,' goto one_arg
-## comma_arg:
-## .local pmc iter
-## iter = expr.'iterator'()
-## iter_loop:
-## unless iter goto end
-## $P0 = shift iter
-## $P0 = 'callarg'($P0)
-## past.'push'($P0)
-## goto iter_loop
-## one_arg:
-## $P0 = 'callarg'(expr)
-## past.'push'($P0)
-## end:
-## match.'result_object'(past)
-##.end
-
-
-##.sub 'callarg'
-## .param pmc arg
-## $S0 = arg.'returns'()
-## unless $S0 == 'Pair' goto end
-## $P0 = arg[0]
-## $P1 = arg[1]
-## $P1.'named'($P0)
-## arg = $P1
-## end:
-## .return (arg)
-##.end
-
-
-method noun($/, $key) {
- if $key eq 'self' {
- make PAST::Var.new('name'=>'self', 'node'=>$/);
- }
- else {
- make $($/{$key});
- }
-}
-##.sub 'noun' :method
-## .param pmc match
-## .param pmc key
-## $P0 = match[key]
-## $P1 = $P0.'get_scalar'()
-## match.'result_object'($P1)
-##.end
-
-
-method colonpair($/) {
- make PAST::Op.new( PAST::Val.new( :value(~$<ident>),
- :node($<ident>)),
- $($<EXPR>),
- :name('infix:=>'),
- :returns('Pair'),
- :node($/)
- );
-}
-##.sub 'colonpair' :method
-## .param pmc match
-## $S0 = match['ident']
-## $P0 = match['ident']
-## $P9 = get_hll_global ['PAST'], 'Val'
-## $P1 = $P9.'new'('value'=>$S0, 'node'=>$P0)
-## $P2 = match['EXPR']
-## $P2 = $P2.'get_scalar'()
-## $P9 = get_hll_global ['PAST'], 'Op'
-## $P3 = $P9.'new'($P1, $P2, 'name'=>'infix:=>', 'returns'=>'Pair', 'node'=>match)
-## match.'result_object'($P3)
-##.end
-
-
-method package_declarator($/, $key) {
- my $past := $($/{$key});
- $past.namespace($<name><ident>);
- $past.blocktype('declaration');
- $past.pirflags(':init :load');
- $past.lexical(0);
-
- #if ($<sym> eq 'class') { ...code to make class... }
-
- make $past;
- # PIR q< $P0 = get_hll_global ['NQP';'Grammar';'Actions'], 'package_declarator_helper' >;
- # PIR q< $P1 = find_lex '$/' >;
- # PIR q< $P2 = find_lex '$key' >;
- # PIR q< $P0($P1, $P2) >;
-}
-#
-##.sub 'package_declarator' :method
-## .param pmc match
-## .param pmc key
-## .local pmc past
-## $P0 = match[key]
-## past = $P0.'get_scalar'()
-## $P1 = match['name']
-## $P1 = $P1['ident']
-## past.'namespace'($P1)
-## past.'blocktype'('declaration')
-## past.'pirflags'(':init :load')
-## past.'lexical'(0)
-## $S0 = match['sym']
-## if $S0 != 'class' goto class_done
-## .local string inline
-## inline = <<' INLINE'
-## $P0 = get_hll_global 'Protomaker'
-## $P1 = split '::', '%s'
-## push_eh subclass_done
-## $P2 = $P0.'new_subclass'('Protoobject', $P1)
-## pop_eh
-## subclass_done:
-## INLINE
-## $S0 = match['name']
-## $I0 = index inline, '%s'
-## substr inline, $I0, 2, $S0
-## $P0 = get_hll_global ['PAST'], 'Op'
-## $P1 = $P0.'new'('inline'=>inline, 'pasttype'=>'inline')
-## $P2 = past[0]
-## $P2.'push'($P1)
-## class_done:
-## match.'result_object'(past)
-##.end
-
-
-method scope_declarator($/) {
- my $past := $($<variable>);
- my $name := $past.name();
- our $?BLOCK;
- unless $?BLOCK.symbol($name) {
- $past.isdecl(1);
- #my $scope := ($<declarator> eq 'my') ? 'lexical' : 'package';
- my $scope;
- if $<declarator> eq 'my' {
- $scope := 'lexical';
- }
- else {
- $scope := 'package';
- }
- $?BLOCK.symbol($name, :scope($scope));
- }
- make $past;
-}
-##.sub 'scope_declarator' :method
-## .param pmc match
-## .local pmc past, block
-## .local string name
-## $P0 = match['variable']
-## past = $P0.'get_scalar'()
-## name = past.'name'()
-## block = get_global '$?BLOCK'
-## $P0 = block.'symbol'(name)
-## if $P0 goto end
-## past.'isdecl'(1)
-## .local string scope
-## scope = 'package'
-## $S0 = match['declarator']
-## if $S0 != 'my' goto have_scope
-## scope = 'lexical'
-## have_scope:
-## block.'symbol'(name, 'scope'=>scope)
-## end:
-## match.'result_object'(past)
-##.end
-
-
-method variable($/, $key) {
- if ($key eq '$< >') {
- say("variable", ~$/[0]);
- make PAST::Var.new(
- PAST::Var.new(:scope('lexical'), :name('$/')),
- PAST::Val.new(:value(~$/[0])),
- :scope('keyed'),
- :viviself('Undef') );
- }
- else {
- make PAST::Var.new(:node($/), :name(~$/) );
- }
-}
-##.sub 'variable' :method
-## .param pmc match
-## .param pmc key
-## if key != '$< >' goto past_var
-## past_match_keyed:
-## $P0 = get_hll_global ['PAST'], 'Var'
-## $P1 = $P0.'new'('scope'=>'lexical', 'name'=>'$/')
-## $P2 = get_hll_global ['PAST'], 'Val'
-## $S0 = match[0]
-## $P3 = $P2.'new'('value'=>$S0)
-## $P4 = $P0.'new'($P1, $P3, 'scope'=>'keyed', 'viviself'=>'Undef')
-## match.'result_object'($P4)
-## .return ()
-## past_var:
-## $S0 = match
-## $S1 = match['sigil']
-## $S2 = 'Undef'
-## if $S1 != '%' goto past_sigil_is_array
-## $S2 = 'Hash'
-## goto past_sigil
-## past_sigil_is_array:
-## if $S1 != '@' goto past_sigil
-## $S2 = 'ResizablePMCArray'
-## goto past_sigil
-## past_sigil:
-## $P0 = get_hll_global ['PAST'], 'Var'
-## $P1 = $P0.'new'('node'=>match, 'name'=>$S0, 'viviself'=>$S2)
-## match.'result_object'($P1)
-##.end
-
-
-method value($/, $key) {
- make $($/{$key});
-}
-###.sub 'value' :method
-### .param pmc match
-### .param pmc key
-### $P0 = match[key]
-### $P1 = $P0.'get_scalar'()
-### match.'result_object'($P1)
-###.end
-
-
-method quote($/) {
- make PAST::Val.new(:node($/), :value(~($<string_literal>)));
-}
-##.sub 'quote' :method
-## .param pmc match
-## .param pmc key :optional
-## .local string value
-## $P0 = match['string_literal']
-## value = $P0.'get_scalar'()
-## $P0 = get_hll_global ['PAST'], 'Val'
-## $P1 = $P0.'new'('node'=>match, 'value'=>value)
-## match.'result_object'($P1)
-##.end
-
-
-
-
-method typename($/, $key) {
- my $ns := $<name><ident>;
- my $shortname;
- PIR q< $P0 = find_lex '$ns' >;
- PIR q< $P0 = clone $P0 >;
- PIR q< $P1 = pop $P0 >;
- PIR q< store_lex '$ns', $P0 >;
- PIR q< store_lex '$shortname', $P1 >;
- make PAST::Var.new( :name($shortname),
- :namespace($ns),
- :scope('package'),
- :node($/)
- );
-}
-
-
-##.sub 'typename' :method
-## .param pmc match
-## .param pmc key
-## .local pmc ns, name
-## $P0 = match['name']
-## $P0 = $P0['ident']
-## ns = clone $P0
-## name = pop ns
-## $P0 = get_hll_global ['PAST'], 'Var'
-## $P1 = $P0.'new'('node'=>match, 'scope'=>'package', 'name'=>name, 'namespace'=>ns)
-## match.'result_object'($P1)
-##.end
-
-
-method number($/ ) {
- make PAST::Val.new(:node($/), :value(~$/), :returns('Integer'));
-}
-##.sub 'number' :method
-## .param pmc match
-## .param pmc key :optional
-## .local pmc past
-## $I0 = match
-## $P0 = get_hll_global ['PAST'], 'Val'
-## past = $P0.'new'('node'=>match, 'value'=>$I0)
-## match.'result_object'(past)
-##.end
-
-
-method subcall($/) {
- my $past := $($<arglist>);
- $past.name(~$<ident>);
- $past.pasttype('call');
- $past.node($/);
- make $past;
-}
-##.sub 'subcall' :method
-## .param pmc match
-## .param pmc key :optional
-## .local pmc past
-## $P0 = match['arglist']
-## past = $P0.'get_scalar'()
-## $S0 = match['ident']
-## past.'name'($S0)
-## past.'pasttype'('call')
-## past.'node'(match)
-## match.'result_object'(past)
-##.end
-
-
-#### Expressions and operators ####
-method EXPR($/, $key) {
- if ($key eq 'end') {
- make $($<expr>);
- }
- else {
- my $past := PAST::Op.new( :name($<type>),
- :pasttype($<top><pasttype>),
- :pirop($<top><pirop>),
- :inline($<top><inline>),
- :lvalue($<top><lvalue>),
- :node($/)
- );
- for @($/) {
- $past.push( $($_) );
- }
- make $past;
- }
-}
-
-
-##.sub 'EXPR' :method
-## .param pmc match
-## .param pmc key
-## if key != 'end' goto expr_reduce
-## expr_end:
-## $P0 = match['expr']
-## $P1 = $P0.'get_scalar'()
-## match.'result_object'($P1)
-## .return ()
-## expr_reduce:
-## .local pmc past
-## .local string name, pirop, pasttype, inline, lvalue
-## name = match['type']
-## pirop = match['top';'pirop']
-## pasttype = match['top'; 'pasttype']
-## inline = match['top'; 'inline']
-## lvalue = match['top'; 'lvalue']
-## $P0 = get_hll_global ['PAST'], 'Op'
-## past = $P0.'new'('node'=>match, 'name'=>name, 'pirop'=>pirop, 'pasttype'=>pasttype, 'inline'=>inline, 'lvalue'=>lvalue)
-## $P1 = match.'get_array'()
-## if null $P1 goto iter_end
-## .local pmc iter
-## iter = new 'Iterator', $P1
-## iter_loop:
-## unless iter goto iter_end
-## $P2 = shift iter
-## $P2 = $P2.'get_scalar'()
-## past.'push'($P2)
-## goto iter_loop
-## iter_end:
-## match.'result_object'(past)
-##.end
-
-# Local Variables:
-# mode: pir
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
Deleted: trunk/compilers/nqp/bootstrap/nqp.pir
==============================================================================
--- trunk/compilers/nqp/bootstrap/nqp.pir Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,212 +0,0 @@
-# Copyright (C) 2008-2009, Parrot Foundation.
-# $Id$
-
-=head1 TITLE
-
-nqp.pir - A nqp compiler.
-
-=head2 Description
-
-This is the base file for the nqp 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 'nqp'.
-
-=head2 Functions
-
-=over 4
-
-=item onload()
-
-Creates the nqp compiler using a C<PCT::HLLCompiler>
-object.
-
-=cut
-
-.namespace [ 'NQP';'Compiler' ]
-
-.loadlib 'nqp_group'
-
-.sub 'onload' :anon :load :init
- load_bytecode 'PCT.pbc'
-
- $P0 = get_hll_global ['PCT'], 'HLLCompiler'
- $P1 = $P0.'new'()
- $P1.'language'('NQP')
- $P1.'parsegrammar'('NQP::Grammar')
- $P1.'parseactions'('NQP::Grammar::Actions')
-.end
-
-=item main(args :slurpy) :main
-
-Start compilation by passing any command line C<args>
-to the nqp compiler.
-
-=cut
-
-.sub 'main' :main
- .param pmc args
-
- $P0 = compreg 'NQP'
- $P1 = $P0.'command_line'(args)
-.end
-
-.include 'compilers/nqp/src/builtins.pir'
-.include 'compilers/nqp/src/Grammar_gen.pir'
-.include 'compilers/nqp/bootstrap/gen_actions.pir'
-
-
-.namespace []
-
-.sub 'initlist' :anon :load :init
- subclass $P0, 'ResizablePMCArray', 'List'
- $P0 = new 'List'
- set_hll_global ['NQP';'Grammar';'Actions'], '@?BLOCK', $P0
-.end
-
-
-.namespace [ 'List' ]
-
-.sub 'unshift' :method
- .param pmc obj
- unshift self, obj
-.end
-
-.sub 'shift' :method
- shift $P0, self
- .return ($P0)
-.end
-
-.sub 'push' :method
- .param pmc obj
- push self, obj
-.end
-
-
-#.namespace [ 'NQP';'Grammar';'Actions' ]
-#
-#.sub 'package_declarator_helper'
-# .param pmc match
-# .param pmc key
-# .local pmc past
-# $P0 = match[key]
-# past = $P0.'get_scalar'()
-# $P1 = match['name']
-# $P1 = $P1['ident']
-# past.'namespace'($P1)
-# past.'blocktype'('declaration')
-# past.'pirflags'(':init :load')
-# past.'lexical'(0)
-# $S0 = match['sym']
-# if $S0 != 'class' goto class_done
-# .local string inline
-# inline = <<' INLINE'
-# $P0 = get_hll_global 'Protomaker'
-# $P1 = split '::', '%s'
-# push_eh subclass_done
-# $P2 = $P0.'new_subclass'('Protoobject', $P1)
-# pop_eh
-# subclass_done:
-# INLINE
-# $S0 = match['name']
-# $I0 = index inline, '%s'
-# substr inline, $I0, 2, $S0
-# $P0 = get_hll_global ['PAST'], 'Op'
-# $P1 = $P0.'new'('inline'=>inline, 'pasttype'=>'inline')
-# $P2 = past[0]
-# $P2.'push'($P1)
-# class_done:
-# match.'result_object'(past)
-#.end
-
-
-
-.sub '__onload' :init :load
-
- ## initialize optable with inline PIR
- .local pmc optable
- optable = get_hll_global [ 'NQP';'Grammar' ], '$optable'
- optable['prefix:~'; 'inline'] = <<" END"
- ## inline prefix:~
- $S0 = %0
- %r = new 'String'
- %r = $S0
- END
-
- optable['prefix:+'; 'inline'] = <<" END"
- ## inline prefix:+
- $N0 = %0
- %r = new 'Float'
- %r = $N0
- END
-
- optable['infix:=='; 'inline'] = <<" END"
- ## inline infix:==
- $I0 = cmp_num %0, %1
- $I0 = iseq $I0, 0
- %r = new 'Integer'
- %r = $I0
- END
-
- optable['infix:!='; 'inline'] = <<" END"
- ## inline infix:!=
- $I0 = cmp_num %0, %1
- $I0 = isne $I0, 0
- %r = new 'Integer'
- %r = $I0
- END
-
- optable['infix:eq'; 'inline'] = <<" END"
- ## inline infix:eq
- $S0 = %0
- $S1 = %1
- $I0 = iseq $S0, $S1
- %r = new 'Integer'
- %r = $I0
- END
-
- optable['infix:ne'; 'inline'] = <<" END"
- ## inline infix:ne
- $S0 = %0
- $S1 = %1
- $I0 = isne $S0, $S1
- %r = new 'Integer'
- %r = $I0
- END
-
- optable['infix:=:='; 'inline'] = <<" END"
- ## inline infix:=:=
- $I0 = issame %0, %1
- %r = new 'Integer'
- %r = $I0
- END
-
- optable['prefix:!'; 'inline'] = <<" END"
- ## inline prefix:!
- $I0 = isfalse %0
- %r = new 'Integer'
- %r = $I0
- END
-
- optable['prefix:?'; 'inline'] = <<" END"
- ## inline prefix:?
- $I0 = istrue %0
- %r = new 'Integer'
- %r = $I0
- END
-
- .return ()
-.end
-
-
-=back
-
-=cut
-
-# Local Variables:
-# mode: pir
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
-
Deleted: trunk/compilers/nqp/bootstrap/t/harness
==============================================================================
--- trunk/compilers/nqp/bootstrap/t/harness Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,14 +0,0 @@
-#! perl
-
-# $Id$
-
-use strict;
-use warnings;
-
-use FindBin;
-use lib "$FindBin::Bin/../../../../lib";
-
-use Parrot::Test::Harness
- language => 'nqp',
- exec => [ '../../../parrot', 'nqp.pbc' ],
- files => [ '../t/*.t' ];
Deleted: trunk/compilers/nqp/nqp.pir
==============================================================================
--- trunk/compilers/nqp/nqp.pir Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,35 +0,0 @@
-# Copyright (C) 2007-2008, Parrot Foundation.
-# $Id$
-
-.namespace [ 'NQP';'Compiler' ]
-
-.sub '__onload' :load :init
- load_bytecode 'PGE.pbc'
- load_bytecode 'PCT.pbc'
-
- $P0 = new [ 'PCT';'HLLCompiler' ]
- $P0.'language'('NQP')
- $P0.'parsegrammar'('NQP::Grammar')
- $P0.'parseactions'('NQP::Grammar::Actions')
-
- $P0 = new 'Integer'
- set_hll_global ['NQP';'Grammar'], '$!endstmt', $P0
-.end
-
-.sub 'main' :main
- .param pmc args
- $P0 = compreg 'NQP'
- .tailcall $P0.'command_line'(args, 'encoding'=>'utf8', 'transcode'=>'ascii')
-.end
-
-.include 'compilers/nqp/src/Grammar_gen.pir'
-
-.include 'compilers/nqp/src/Grammar/Actions.pir'
-
-.include 'compilers/nqp/src/builtins.pir'
-
-# Local Variables:
-# mode: pir
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
Deleted: trunk/compilers/nqp/src/Grammar.pg
==============================================================================
--- trunk/compilers/nqp/src/Grammar.pg Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,507 +0,0 @@
-# Copyright (C) 2007-2009, Parrot Foundation.
-# $Id$
-
-
-=begin overview
-
-The following is the grammar for nqp written as a sequence of
-Perl 6 rules. In each of the rules, the special notation C<{*}>
-marks a point in the rule where the corresponding action in
-NQP::Grammar::Actions is to be invoked (see F<src/Grammar/Actions.pir>).
-These actions are then used to construct the AST nodes for
-the program.
-
-The C<#=> markers at the ends of lines are used to distinguish
-among multiple C<{*}> actions within a rule, by passing the value
-after the marker as a 'key' argument to the action method.
-
-=end overview
-
-grammar NQP::Grammar is PCT::Grammar;
-
-
-token TOP {
- <statement_block>
- [ $ || <panic: 'Syntax error'> ]
- {*}
-}
-
-## The <ws> and <pod_comment> rules handle whitespace and comments.
-## These are taken from an earlier draft of Perl 6, so they do not
-## yet handle all valid forms of Perl 6 whitespace.
-token ws {
- {{ $P0 = match.'to'()
- $P1 = get_hll_global [ 'NQP';'Grammar' ], '$!ws'
- if null $P1 goto set_new_ws
- $P2 = $P1.'to'()
- if $P0 != $P2 goto set_new_ws
- .return (1)
- set_new_ws:
- set_hll_global [ 'NQP';'Grammar' ], '$!ws', match
- }}
- [ \s+
- | ^^ [ \# \N*
- | <.pod_comment>
- ]
- | \# \N*
- ]*
-}
-
-
-token afterws {
- ## <?{ $¢ == $!ws_to != $!ws_from }>
- {{ $P0 = match.'to'()
- $P1 = get_hll_global [ 'NQP';'Grammar' ], '$!ws'
- $P2 = $P1.'to'()
- if $P0 != $P2 goto end
- $P2 = $P1.'from'()
- if $P0 == $P1 goto end
- .return (1)
- end:
- }}
- <!>
-}
-
-
-regex pod_comment {
- ^^ '=' [ [ 'cut' \h*: | 'end' [\h\N*]? ]
- | 'for' [ \h\N+: ] \n [ \N+\n ]*:
- | \w\N*: \n .*? \n '=' [ 'cut' \h*: | 'end' [\h\N*:]? ]
- ]
- [\n|$]
-}
-
-
-#### Blocks and Statements ####
-
-## A <statement_block> is a statement list that is returned as
-## a PAST::Block node.
-rule statement_block {
- {*} #= open
- <statement_list>
- {*} #= close
-}
-
-## Parse a list of statements.
-rule statement_list {
- [ <statement>
- [ <.statement_end> || <panic: 'Statement not terminated properly'> ]
- ]*
- {*}
-}
-
-
-## Parse a single statement, which may be either a bare block
-## or an expression. Any statement termination is handled by
-## the calling rule.
-rule statement {
- | <if_statement> {*} #= if_statement
- | <unless_statement> {*} #= unless_statement
- | <while_statement> {*} #= while_statement
- | <repeat_statement> {*} #= repeat_statement
- | <for_statement> {*} #= for_statement
- | <return_statement> {*} #= return_statement
- | <make_statement> {*} #= make_statement
- | <inline_pir_statement> {*} #= inline_pir_statement
- | <block> {*} #= block
- | <EXPR> {*} #= EXPR
-}
-
-
-## The statement_end rule detects when we're at valid statement
-## termination point. A semicolon always acts as a valid
-## statement ending point, as does the presence of any expression
-## terminator. The MARK_STATEMENT_END subrule is used by other
-## rules to indicate a valid statement end even when a terminator
-## isn't present (e.g., the closing '}' at the end of a line for
-## a <block> ).
-
-token terminator { <[ } \] ) ]> | $ }
-
-token statement_end {
- || ';'
- || <?before <terminator>>
- || {{ $P0 = get_hll_global ['NQP';'Grammar'], '$!endstmt'
- $P1 = get_hll_global ['NQP';'Grammar'], '$!ws'
- $P2 = $P1.'from'()
- if $P0 != $P2 goto end
- .return (1)
- end:
- }} <!>
-}
-
-token MARK_STATEMENT_END {
- {{ $P0 = match.'to'()
- $P0 = clone $P0
- set_hll_global ['NQP';'Grammar'], '$!endstmt', $P0
- }}
- <.ws>
-}
-
-
-## The if_statement handles conditional statements such as 'if' and
-## 'unless'.
-
-rule if_statement {
- $<sym>=['if']
- <EXPR> <block>
- [ 'elsif' <EXPR> <block> ]*
- [ 'else' $<else>=<block> ]?
- {*}
-}
-
-rule unless_statement {
- $<sym>=['unless']
- <EXPR> <block>
- {*}
-}
-
-rule while_statement {
- $<sym>=['while'|'until'] <EXPR> <block>
- {*}
-}
-
-rule repeat_statement {
- 'repeat' <block> $<sym>=['while'|'until'] <EXPR>
- {*}
-}
-
-rule for_statement {
- $<sym>=['for'] <EXPR> <block>
- {*}
-}
-
-
-rule return_statement {
- $<sym>=['return']
- [ <EXPR> || <panic: 'Unable to parse argument to "return"'> ]
- {*}
-}
-
-rule make_statement {
- $<sym>=['make']
- [ <EXPR> || <panic: 'Unable to parse argument to "make"'> ]
- {*}
-}
-
-rule inline_pir_statement {
- 'PIR'
- [ <quote> {*} #= quote
- | 'q:to:' [ \' (<-['\n]>+) \' | \" (<-["\n]>+) \" | \< (<-[\>\n]>+) \> ]
- [:sigspace(0):ratchet(0)
- ';' \h*: \n
- $<text>=[ [\N*:\n]*? ]
- ^^ \h*: $0 \h*: \n
- <.MARK_STATEMENT_END>
- ] {*} #= heredoc
- ]
-}
-
-
-## Parse a block. If the closing brace is at the end of a line,
-## then we call <.MARK_STATEMENT_END> so that any following
-## <statement_end> rule can succeed.
-
-token block {
- '{'
- <statement_block>
- [ '}' || <panic: 'Missing "}"'> ]
- [ \h* [ \# \N* ]? \n <.MARK_STATEMENT_END> ]?
- {*}
-}
-
-
-#### Subroutine and method definitions ####
-
-rule routine_def {
- $<declarator>=['sub'|'method']
- $<name>=[<ident>[':sym<'<-[>]>+'>']?]
- '(' <signature> ')'
- <block>
- {*}
-}
-
-rule signature {
- ( <parameter> ( ',' | <?before ')'> ) )*
- {*}
-}
-
-token parameter {
- | [
- $<named>=[':'?]
- <param_var>
- $<quant>=[ <[ ? ! ]>? ]
- ] {*} #= non-slurp
- | $<quant>=['*'?] <param_var> {*} #= slurp
-}
-
-token param_var {
- [
- | '$/'
- | <sigil> <ident>
- ]
- {*}
-}
-
-
-#### Terms ####
-
-token term {
- <noun>
- <postfix>*
- {*} #= end
-}
-
-token postfix {
- <!afterws>
- [ <methodop> {*} #= methodop
- | <postcircumfix> {*} #= postcircumfix
- ]
-}
-
-token methodop {
- '.' <ident>
- [
- | '(' ~ ')' <arglist> {*} #= arglist
- | {*} #= null
- ]
-}
-
-token postcircumfix {
- | '(' <arglist> ')' {*} #= ( )
- | '[' <EXPR> <.ws> ']' {*} #= [ ]
- | '{' <EXPR> <.ws> '}' {*} #= { }
- | '<' <string_literal: '>' > '>' {*} #= < >
-}
-
-rule arglist {
- <EXPR>?
- {*}
-}
-
-token noun {
- | <colonpair> {*} #= colonpair
- | <package_declarator> {*} #= package_declarator
- | <scope_declarator> {*} #= scope_declarator
- | <routine_def> {*} #= routine_def
- | <circumfix> {*} #= circumfix
- | <variable> {*} #= variable
- | <subcall> {*} #= subcall
- | 'self' >> {*} #= self
- | <value> {*} #= value
- | <name> {*} #= name
-}
-
-
-token colonpair {
- | ':' <ident> [ '(' <EXPR> <.ws> ')' ] {*}
-}
-
-
-rule package_declarator {
- $<sym>=[module|class]
- <name>
- [ 'is' <parent=name> ]?
- [
- || ';' <statement_block> {*} #= statement_block
- || <block> {*} #= block
- ]
-}
-
-
-rule scope_declarator {
- $<declarator>=[my|our]
- <variable>
- {*}
-}
-
-
-token circumfix {
- | '(' <EXPR>? <.ws> ')' {*} #= ( )
- | '$(' <EXPR>? <.ws> ')' {*} #= $( )
- | '@(' <EXPR>? <.ws> ')' {*} #= @( )
-}
-
-
-token variable {
- | '$<' ( <-[\>]>* ) '>' {*} #= $< >
- | '$/' {*} #= $/
- | <sigil> <twigil>? <ident> {*} #= $var
-}
-
-token sigil { <[$@%&]> }
-
-token twigil { <[.!^*+?=]> }
-
-token value {
- | <quote> {*} #= quote
- | <number> {*} #= number
- | <typename> {*} #= typename
-}
-
-token quote {
- [ \' <string_literal: '\''> \' {*} #= string
- | '"' <string_literal: '"'> '"' {*} #= string
- | 'q' <.ws> '<' <string_literal: '>'> '>' {*} #= string
- | 'Q' <.ws> ':PIR' <.ws>
- [:ratchet(0) '{{' (.*?) '}}' | '{' (.*?) '}' ] {*} #= PIR
- ]
-}
-
-
-token typename {
- <name> {*} #= name
-}
-
-
-token name {
- <ident> [ '::' <ident> ]*
- {*}
-}
-
-
-token number { \d+ {*} }
-
-
-token subcall {
- <ident> '(' <arglist> ')'
- {*}
-}
-
-
-
-#### Expressions and operators ####
-
-rule EXPR is optable { ... }
-
-## Terms
-proto 'term:' is precedence('z=')
- is parsed(&term)
- { ... }
-
-## Postfix operators
-proto postfix:<++> is looser('term:')
- is pasttype('inline')
- { ... }
-proto postfix:<--> is equiv(postfix:<++>)
- is pasttype('inline')
- { ... }
-
-## Unary prefix operators
-proto prefix:<+> is looser(postfix:<++>)
- is pirop('set N*')
- { ... }
-proto prefix:<~> is equiv(prefix:<+>)
- is pirop('set S*')
- { ... }
-proto prefix:<-> is equiv(prefix:<+>)
- is pirop('neg')
- { ... }
-proto prefix:<!> is equiv(prefix:<+>)
- is pirop('isfalse')
- { ... }
-proto prefix:<?> is equiv(prefix:<+>)
- is pirop('istrue')
- { ... }
-
-## Multiplicative operators
-proto infix:<*> is looser(prefix:<+>)
- is pirop('mul')
- { ... }
-proto infix:</> is equiv(infix:<*>)
- is pirop('div')
- { ... }
-proto infix:<%> is equiv(infix:<*>)
- is pirop('mod')
- { ... }
-
-
-## Additive operators
-proto infix:<+> is looser(infix:<*>)
- is pirop('add')
- { ... }
-proto infix:<-> is equiv(infix:<+>)
- is pirop('sub')
- { ... }
-
-## Concatenation operators
-proto infix:<~> is looser(infix:<+>)
- is pirop('concat')
- { ... }
-
-## Comparison operators
-proto infix:<==> is looser(infix:<+>)
- is pirop('iseq INn')
- { ... }
-proto infix:<!=> is equiv(infix:<==>)
- is pirop('isne INn')
- { ... }
-proto infix:«>=» is equiv(infix:<==>)
- is pirop('isge INn')
- { ... }
-proto infix:«<=» is equiv(infix:<==>)
- is pirop('isle INn')
- { ... }
-proto infix:«>» is equiv(infix:<==>)
- is pirop('isgt INn')
- { ... }
-proto infix:«<» is equiv(infix:<==>)
- is pirop('islt INn')
- { ... }
-
-proto infix:<eq> is equiv(infix:<==>)
- is pirop('iseq ISs')
- { ... }
-proto infix:<ne> is equiv(infix:<==>)
- is pirop('isne ISs')
- { ... }
-proto infix:<lt> is equiv(infix:<==>)
- is pirop('islt ISs')
- { ... }
-proto infix:<le> is equiv(infix:<==>)
- is pirop('isle ISs')
- { ... }
-proto infix:<gt> is equiv(infix:<==>)
- is pirop('isgt ISs')
- { ... }
-proto infix:<ge> is equiv(infix:<==>)
- is pirop('isge ISs')
- { ... }
-proto infix:<=:=> is equiv(infix:<==>)
- is pirop('issame')
- { ... }
-
-## Tight logical operators
-proto infix:<&&> is looser(infix:<==>)
- is pasttype('if')
- { ... }
-proto infix:<||> is looser(infix:<&&>)
- is pasttype('unless')
- { ... }
-
-## Conditional
-proto ternary:<?? !!> is looser(infix:<||>)
- is pasttype('if')
- { ... }
-
-## Binding
-proto infix:<:=> is looser(ternary:<?? !!>)
- is lvalue(1)
- is pasttype('bind')
- { ... }
-
-## Comma
-proto infix:<,> is looser(infix:<:=>)
- is assoc('list')
- is pasttype('list')
- is nullterm
- { ... }
-
-## loose logical operators
-proto infix:<and> is looser(infix:<,>)
- is pasttype('if')
- { .... }
-
-proto infix:<or> is looser(infix:<and>)
- is pasttype('unless')
- { ... }
Deleted: trunk/compilers/nqp/src/Grammar/Actions.pir
==============================================================================
--- trunk/compilers/nqp/src/Grammar/Actions.pir Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,1075 +0,0 @@
-# Copyright (C) 2007-2009, Parrot Foundation.
-# $Id$
-
-.sub '__onload' :init :load
- $P0 = get_hll_global 'P6metaclass'
- $P0 = $P0.'new_class'('NQP::Grammar::Actions')
-
- ## create the stack for nested lexical blocks
- $P0 = new 'ResizablePMCArray'
- set_hll_global ['NQP';'Grammar';'Actions'], '@?BLOCK', $P0
-
- ## initialize optable with inline PIR
- .local pmc optable
- optable = get_hll_global [ 'NQP';'Grammar' ], '$optable'
-
- optable['postfix:++'; 'inline'] = <<" END"
- ## inline postfix:++
- clone %r, %0
- inc %0
- END
-
- optable['postfix:--'; 'inline'] = <<" END"
- ## inline postfix:--
- clone %r, %0
- dec %0
- END
-
- .return ()
-.end
-
-.namespace [ 'NQP';'Grammar';'Actions' ]
-
-
-## method TOP($/, $key) {
-## my $past := $($<statement_block>);
-## $past.blocktype('declaration');
-## make $past;
-## }
-.sub 'TOP' :method
- .param pmc match
- .local pmc past
- $P0 = match['statement_block']
- past = $P0.'ast'()
- past.'blocktype'('declaration')
- match.'!make'(past)
-.end
-
-
-#### Blocks and Statements ####
-
-## method statement_block($/, $key) {
-## our $?BLOCK, @?BLOCK;
-## if ($key ne 'close') {
-## $?BLOCK := PAST::Block.new( PAST::Stmts.new(),
-## :blocktype('immediate'),
-## :node($/) );
-## @?BLOCK.unshift($?BLOCK);
-## }
-## else {
-## my $past := @?BLOCK.shift();
-## $?BLOCK := @?BLOCK[0];
-## $past.push($($<statement_list>));
-## make $past;
-## }
-## }
-.sub 'statement_block' :method
- .param pmc match
- .param string key
- if key == 'close' goto block_close
- block_open:
- .local pmc past
- $P1 = get_hll_global ['PAST'], 'Stmts'
- $P2 = $P1.'new'()
- $P0 = get_hll_global ['PAST'], 'Block'
- past = $P0.'new'($P2, 'blocktype'=>'immediate', 'node'=>match)
- set_global '$?BLOCK', past
- $P0 = get_global '@?BLOCK'
- unshift $P0, past
- .return ()
- block_close:
- $P0 = get_global '@?BLOCK'
- past = shift $P0
- $P1 = $P0[0]
- set_global '$?BLOCK', $P1
- $P2 = match['statement_list']
- $P3 = $P2.'ast'()
- past.'push'($P3)
- match.'!make'(past)
-.end
-
-
-## method statement_list($/) {
-## my $past := PAST::Stmts.new(:node($/))
-## for $<statement> {
-## $past.push($($_));
-## }
-## make $past;
-## }
-.sub 'statement_list' :method
- .param pmc match
- .local pmc past
- $P0 = get_hll_global ['PAST'], 'Stmts'
- past = $P0.'new'('node'=>match)
- $P1 = match['statement']
- if null $P1 goto iter_end
- .local pmc it
- it = iter $P1
- iter_loop:
- unless it goto iter_end
- $P2 = shift it
- $P2 = $P2.'ast'()
- past.'push'($P2)
- goto iter_loop
- iter_end:
- match.'!make'(past)
-.end
-
-
-## method statement($/, $key) {
-## make $($/{$key});
-## }
-.sub 'statement' :method
- .param pmc match
- .param string key
- $P0 = match[key]
- $P1 = $P0.'ast'()
- match.'!make'($P1)
-.end
-
-
-## method if_statement($/) {
-## my $cond := +$<EXPR> - 1;
-## my $past := PAST::Op.new( $( $<EXPR>[$cond] ),
-## $( $<block>[$cond] ),
-## :pasttype('if'),
-## :node( $/ )
-## );
-## if ( $<else> ) {
-## $past.push( $( $<else>[0] ) );
-## }
-## while ($cond != 0) {
-## $cond := $cond - 1;
-## $past := PAST::Op.new( $( $<EXPR>[$cond] ),
-## $( $<block>[$cond] ),
-## $past,
-## :pasttype('if'),
-## :node( $/ )
-## );
-## }
-## make $past;
-.sub 'if_statement' :method
- .param pmc match
- .local pmc expr, block, past
- .local int cond
- .local pmc jmpstack
- jmpstack = new 'ResizableIntegerArray'
- cond = match['EXPR']
- cond -= 1
- local_branch jmpstack, get_expr
- local_branch jmpstack, get_block
- $P2 = get_hll_global ['PAST'], 'Op'
- past = $P2.'new'(expr, block, 'pasttype'=>'if', 'node'=>match)
-
- $I0 = exists match['else']
- unless $I0 goto while
- block = match['else']
- block = block[0]
- block = block.'ast'()
- past.'push'( block )
-
- while:
- unless cond != 0 goto end_while
- cond -= 1
- local_branch jmpstack, get_expr
- local_branch jmpstack, get_block
- past = $P2.'new'(expr, block, past, 'pasttype'=>'if', 'node'=>match)
- goto while
-
- end_while:
- goto end
-
- get_expr:
- expr = match['EXPR']
- expr = expr[cond]
- expr = expr.'ast'()
- local_return jmpstack
- get_block:
- block = match['block']
- block = block[cond]
- block = block.'ast'()
- local_return jmpstack
- end:
- match.'!make'(past)
-.end
-
-
-## method unless_statement($/) {
-## my $past := PAST::Op.new( $( $<EXPR> ),
-## $( $<block> ),
-## :pasttype('unless'),
-## :node( $/ )
-## );
-## make $past;
-## }
-.sub 'unless_statement' :method
- .param pmc match
- .local pmc expr, block, past
- expr = match['EXPR']
- expr = expr
- expr = expr.'ast'()
- block = match['block']
- block = block
- block = block.'ast'()
- $P0 = get_hll_global ['PAST'], 'Op'
- past = $P0.'new'(expr, block, 'pasttype'=>'unless', 'node'=>match)
- match.'!make'(past)
-.end
-
-
-## method repeat_statement($/) {
-## make PAST::Op.new( $($<EXPR>),
-## $($<block>),
-## :pasttype( 'repeat_' ~ $<sym> ),
-## :node( $/ )
-## );
-## }
-.sub 'repeat_statement' :method
- .param pmc match
- $P1 = match['EXPR']
- $P1 = $P1.'ast'()
- $P2 = match['block']
- $P2 = $P2.'ast'()
- $S0 = match['sym']
- $S0 = concat 'repeat_', $S0
- $P0 = get_hll_global ['PAST'], 'Op'
- $P5 = $P0.'new'( $P1, $P2, 'pasttype'=>$S0, 'node'=>match)
- match.'!make'($P5)
-.end
-
-
-## method while_statement($/) {
-## make PAST::Op.new( $($<EXPR>),
-## $($<block>),
-## :pasttype( ~$<sym> ),
-## :node( $/ )
-## );
-## }
-.sub 'while_statement' :method
- .param pmc match
- $P1 = match['EXPR']
- $P1 = $P1.'ast'()
- $P2 = match['block']
- $P2 = $P2.'ast'()
- $S0 = match['sym']
- $P0 = get_hll_global ['PAST'], 'Op'
- $P5 = $P0.'new'( $P1, $P2, 'pasttype'=>$S0, 'node'=>match)
- match.'!make'($P5)
-.end
-
-
-## method for_statement($/) {
-## my $block := $<block>;
-## $block.blocktype('immediate');
-## $block.symbol('$_', :scope('lexical'));
-## my $topic_var := PAST::Var.new( :name('$_'), :scope('parameter') );
-## push @($block[0]), $topic_var;
-## my $past := PAST::Op.new($($<EXPR>),
-## $($<block>),
-## :pasttype(~$<sym>),
-## :node($/) );
-## make $past;
-.sub 'for_statement' :method
- .param pmc match
- .local pmc block, past
- $P0 = match['EXPR']
- $P0 = $P0.'ast'()
- $P1 = match['block']
- block = $P1.'ast'()
- block.'blocktype'('immediate')
- .local pmc params, topic_var
- params = block[0]
- $P3 = get_hll_global ['PAST'], 'Var'
- topic_var = $P3.'new'('name'=>'$_', 'scope'=>'parameter')
- params.'push'(topic_var)
- block.'symbol'('$_', 'scope'=>'lexical')
- block.'arity'(1)
- $P2 = get_hll_global ['PAST'], 'Op'
- $S1 = match['sym']
- past = $P2.'new'($P0, block, 'pasttype'=>$S1, 'node'=>match)
- match.'!make'(past)
-.end
-
-
-## method return_statement($/) {
-## make PAST::Op.new( $($<EXPR>),
-## :pasttype('return'),
-## :node($/) );
-## }
-.sub 'return_statement' :method
- .param pmc match
- $P0 = match['EXPR']
- $P0 = $P0.'ast'()
-
- $P1 = get_hll_global ['PAST'], 'Op'
- $P1 = $P1.'new'( $P0, 'pasttype'=>'return', 'node'=>match)
- match.'!make'($P1)
-.end
-
-
-## method make_statement($/) {
-## make PAST::Op.new( PAST::Var.new( :name('$/'),
-## :scope('lexical') ),
-## $($<EXPR>),
-## :name('!make'),
-## :pasttype('callmethod') );
-## }
-.sub 'make_statement' :method
- .param pmc match
- $P0 = get_hll_global ['PAST'], 'Var'
- $P1 = $P0.'new'( 'name'=>'$/', 'scope'=>'lexical' )
- $P2 = match['EXPR']
- $P3 = $P2.'ast'()
- $P4 = get_hll_global ['PAST'], 'Op'
- $P5 = $P4.'new'($P1, $P3, 'name'=>'!make', 'pasttype'=>'callmethod')
- match.'!make'($P5)
-.end
-
-
-## method inline_pir_statement($/, $key) {
-## my $inline;
-## if ($key eq 'quote') { $inline := ~$($<quote><string_literal>) }
-## if ($key eq 'heredoc') { $inline := ~$/<text> }
-##
-## make PAST::Op.new( :inline( $inline ),
-## :pasttype('inline'),
-## :node( $/ )
-## );
-## }
-.sub 'inline_pir_statement' :method
- .param pmc match
- .param pmc key
- .local pmc inline
- if key != 'quote' goto not_quote
- $P0 = match['quote']
- $P0 = $P0['string_literal']
- inline = $P0.'ast'()
- goto make
- not_quote:
- if key != 'heredoc' goto not_heredoc
- $P0 = match['text']
- inline = $P0.'Str'()
- not_heredoc:
- make:
- $P1 = get_hll_global ['PAST'], 'Op'
- $P2 = $P1.'new'( 'inline'=>inline, 'pasttype'=>'inline', 'node'=>match)
- match.'!make'($P2)
-.end
-
-
-## method block($/) {
-## make $($<statement_block>);
-## }
-.sub 'block' :method
- .param pmc match
- $P0 = match['statement_block']
- $P0 = $P0.'ast'()
- match.'!make'($P0)
-.end
-
-
-#### Subroutine and method definitions ####
-
-## method routine_def($/) {
-## my $past := $($<block>);
-## $past.name(~$<name>);
-## $past.node($/);
-## $past.blocktype('declaration');
-## $past.control('return_pir');
-## my $params := $past[0];
-## if $<declarator> eq 'method' {
-## $past.blocktype('method');
-## $past.push(PAST::Op.new('inline'=>'.lex 'self', self);
-## $past.symbol('self', :scope('lexical'));
-## }
-## for $<signature>[0] {
-## my $parameter := $($_<parameter>);
-## $past.symbol($parameter.name(), :scope('lexical'));
-## $params.push($parameter);
-## }
-## make $past;
-## }
-.sub 'routine_def' :method
- .param pmc match
- .local pmc past
- $P0 = match['block']
- past = $P0.'ast'()
- $S0 = match['name']
- past.'name'($S0)
- past.'node'(match)
- past.'blocktype'('declaration')
- past.'control'('return_pir')
- .local pmc params
- params = past[0]
- $S0 = match['declarator']
- if $S0 != 'method' goto add_signature
- past.'blocktype'('method')
- $P3 = get_hll_global ['PAST'], 'Op'
- $P4 = $P3.'new'('inline'=>' .lex "self", self', 'pasttype'=>'inline')
- unshift past, $P4
- past.'symbol'('self', 'scope'=>'lexical')
- add_signature:
- $P0 = match['signature']
- $P0 = $P0[0]
- if null $P0 goto param_end
- unless $P0 goto param_end
- .local pmc it
- it = iter $P0
- param_loop:
- unless it goto param_end
- $P1 = shift it
- .local pmc parameter
- $P2 = $P1['parameter']
- parameter = $P2.'ast'()
- $S0 = parameter.'name'()
- past.'symbol'($S0, 'scope'=>'lexical')
- params.'push'(parameter)
- goto param_loop
- param_end:
- match.'!make'(past)
-.end
-
-
-## method parameter($/, $key) {
-## my $past := $( $<param_var> );
-## my $sigil := $<param_var><sigil>;
-## if $key eq 'slurp' { # slurpy
-## $past.slurpy( $sigil eq '@' || $sigil eq '%' );
-## $past.named( $sigil eq '%' );
-## }
-## else {
-## if $<named> eq ':' { # named
-## $past.named(~$<param_var><ident>);
-## if $<quant> ne '!' { # required (optional is default)
-## $past.viviself('Undef');
-## }
-## }
-## else { # positional
-## if $<quant> eq '?' { # optional (required is default)
-## $past.viviself('Undef');
-## }
-## }
-## }
-## make $past;
-## }
-.sub 'parameter' :method
- .param pmc match
- .param pmc key
- .local pmc past, sigil
- past = match['param_var']
- past = past.'ast'()
- sigil = match['param_var';'sigil']
- if key != 'slurp' goto not_slurp
- if sigil != '@' goto not_slurpy_array
- past.'slurpy'(1)
- not_slurpy_array:
- if sigil != '%' goto not_slurpy_hash
- past.'slurpy'(1)
- not_slurpy_hash:
- if sigil != '%' goto not_slurp
- past.'named'(1)
- goto make_past
- not_slurp:
- $S0 = match['named']
- if $S0 != ':' goto not_named
- $S0 = match['param_var';'ident']
- past.'named'($S0)
- $S0 = match['quant']
- if $S0 == '!' goto not_named
- past.'viviself'('Undef')
- not_named:
- $S0 = match['quant']
- if $S0 != '?' goto make_past
- past.'viviself'('Undef')
- make_past:
- match.'!make'(past)
-.end
-
-
-## method param_var($/) {
-## make PAST::Var.new(:name(~$/),
-## :scope('parameter'),
-## :node($/) );
-## }
-.sub 'param_var' :method
- .param pmc match
- $S0 = match
- $P0 = get_hll_global ['PAST'], 'Var'
- $P1 = $P0.'new'('name'=>$S0, 'scope'=>'parameter', 'node'=>match)
- match.'!make'($P1)
-.end
-
-
-#### Terms and expressions ####
-
-## method term($/, $key) {
-## my $past := $($<noun>);
-## for $<postfix> {
-## my $term := $past;
-## $past := $($_);
-## $past.unshift($term);
-## }
-## make $past;
-## }
-.sub 'term' :method
- .param pmc match
- .param pmc key
- .local pmc past
- $P0 = match['noun']
- past = $P0.'ast'()
- $P1 = match['postfix']
- if null $P1 goto end
- .local pmc it, term
- it = iter $P1
- iter_loop:
- unless it goto end
- $P2 = shift it
- term = past
- past = $P2.'ast'()
- past.'unshift'(term)
- goto iter_loop
- end:
- match.'!make'(past)
-.end
-
-
-## method postfix($/, $key) {
-## make $($/{$key});
-## }
-.sub 'postfix' :method
- .param pmc match
- .param string key
- $P0 = match[key]
- $P1 = $P0.'ast'()
- match.'!make'($P1)
-.end
-
-
-## method methodop($/, $key) {
-## my $past := $key eq 'null'
-## ?? PAST::Op.new
-## !! $<arglist>.ast;
-## $past.name(~$<ident>);
-## $past.pasttype('callmethod');
-## $past.node($/);
-## make $past;
-## }
-.sub 'methodop' :method
- .param pmc match
- .param string key
- .local pmc past
- unless key == 'null' goto arglist
- $P0 = get_hll_global ['PAST'], 'Op'
- past = $P0.'new'()
- goto have_past
- arglist:
- $P0 = match['arglist']
- past = $P0.'ast'()
- have_past:
- $S0 = match['ident']
- past.'name'($S0)
- past.'pasttype'('callmethod')
- past.'node'(match)
- match.'!make'(past)
-.end
-
-
-## method postcircumfix($/, $key) {
-## if $key eq '( )' {
-## my $past := $($<arglist>);
-## $past.pasttype('call');
-## $past.node($/);
-## make $past;
-## }
-## elseif $key eq '< >' {
-## my $value := PAST::Val.new( :value( $($<string_literal>) ) );
-## make PAST::Var.new( $value,
-## :scope('keyed'),
-## :vivibase('Hash'),
-## :viviself('Undef'),
-## :node( $/ ) );
-## }
-## else {
-## my $vivibase := ($key eq '{ }') ?? 'Hash' !! 'ResizablePMCArray';
-## make PAST::Var.new( $($<EXPR>),
-## :scope('keyed'),
-## :vivibase($vivibase),
-## :viviself('Undef'),
-## :node($/) );
-## }
-## }
-.sub 'postcircumfix' :method
- .param pmc match
- .param string key
- .local pmc past
- if key == '( )' goto subcall
- if key == '< >' goto keyed_const
- keyed_var:
- .local string vivibase, scope
- vivibase = 'Hash'
- scope = 'keyed'
- if key != '[ ]' goto keyed_hash
- vivibase = 'ResizablePMCArray'
- scope = 'keyed_int'
- keyed_hash:
- $P0 = get_hll_global ['PAST'], 'Var'
- $P1 = match['EXPR']
- $P2 = $P1.'ast'()
- $P3 = $P0.'new'( $P2, 'scope'=>scope, 'vivibase'=>vivibase, 'viviself'=>'Undef', 'node'=>match )
- match.'!make'($P3)
- .return ()
- subcall:
- $P0 = match['arglist']
- past = $P0.'ast'()
- past.'pasttype'('call')
- past.'node'(match)
- match.'!make'(past)
- .return ()
- keyed_const:
- $P0 = get_hll_global ['PAST'], 'Val'
- $P1 = match['string_literal']
- $P2 = $P1.'ast'()
- .local pmc value
- value = $P0.'new'( 'value' => $P2, 'node'=> $P1 )
- $P0 = get_hll_global ['PAST'], 'Var'
- $P1 = $P0.'new'( value, 'scope'=>'keyed', 'vivibase'=>'Hash', 'viviself'=>'Undef', 'node'=>match)
- match.'!make'($P1)
-.end
-
-
-##method circumfix($/, $key) {
-## my $expr := $($<EXPR>[0]);
-## if $key eq '@( )' {
-## make PAST::Op.new( $expr,
-## :name('list'),
-## :pasttype('callmethod'),
-## :node($/) );
-## }
-## if $key eq '$( )' {
-## make PAST::Op.new( $expr,
-## :name('ast'),
-## :pasttype('callmethod'),
-## :node($/) );
-## }
-## make $expr;
-##}
-.sub 'circumfix' :method
- .param pmc match
- .param string key
- .local pmc past
- $P0 = match['EXPR']
- unless null $P0 goto have_expr
- $P1 = match
- goto get_past
- have_expr:
- $P1 = $P0[0]
- get_past:
- $P1 = $P1.'ast'()
- $P0 = get_hll_global ['PAST'], 'Op'
- if key == '@( )' goto list_context
- if key == '$( )' goto scalar_context
- parenthetical:
- match.'!make'($P1)
- .return ()
- list_context:
- past = $P0.'new'($P1, 'name' => 'list', 'pasttype'=>'callmethod', 'node'=>match)
- match.'!make'(past)
- .return ()
- scalar_context:
- past = $P0.'new'($P1, 'name' => 'ast', 'pasttype'=>'callmethod', 'node'=>match)
- match.'!make'(past)
-.end
-
-
-## method arglist($/) {
-## sub callarg($arg) {
-## if $arg.returns() eq 'Pair' {
-## $arg[1].named($arg[0]);
-## $arg := $arg[1];
-## }
-## return $arg;
-## }
-##
-## my $past := PAST::Op.new( :node($/) );
-## if ($<EXPR>) {
-## my $expr := $($<EXPR>[0]);
-## if ($expr.name() eq 'infix:,') {
-## for @($expr) {
-## $past.push( callarg($_) );
-## }
-## }
-## else {
-## $past.push( callarg($expr) );
-## }
-## }
-## make $past;
-## }
-.sub 'arglist' :method
- .param pmc match
- .local pmc past
- $P0 = get_hll_global ['PAST'], 'Op'
- past = $P0.'new'( 'node'=>match )
- $P1 = match['EXPR']
- if null $P1 goto end
- .local pmc expr, iter
- $P2 = $P1[0]
- expr = $P2.'ast'()
- $S0 = expr.'name'()
- if $S0 != 'infix:,' goto one_arg
- comma_arg:
- iter = expr.'iterator'()
- iter_loop:
- unless iter goto end
- $P0 = shift iter
- $P0 = 'callarg'($P0)
- past.'push'($P0)
- goto iter_loop
- one_arg:
- $P0 = 'callarg'(expr)
- past.'push'($P0)
- end:
- match.'!make'(past)
-.end
-
-.sub 'callarg'
- .param pmc arg
- $S0 = arg.'returns'()
- unless $S0 == 'Pair' goto end
- $P0 = arg[0]
- $P1 = arg[1]
- $P1.'named'($P0)
- arg = $P1
- end:
- .return (arg)
-.end
-
-
-## method noun($/, $key) {
-## if $key eq 'self' {
-## make PAST::Var.new(:name('self'), :scope('lexical'), :node($/));
-## }
-## else {
-## make $($/{$key});
-## }
-## }
-.sub 'noun' :method
- .param pmc match
- .param pmc key
-
- $P0 = match[key]
- if key == 'self' goto make_self
- $P1 = $P0.'ast'()
- match.'!make'($P1)
- .return()
- make_self:
- $P9 = get_hll_global ['PAST'], 'Var'
- $P1 = $P9.'new'('scope'=>'lexical', 'name'=>'self', 'node'=>$P0)
- match.'!make'($P1)
-.end
-
-
-## method colonpair($/) {
-## make PAST::Op.new( PAST::Val.new( :value(~$<ident>),
-## :node($<ident>)),
-## $($<EXPR>),
-## :name('infix:=>'),
-## :returns('Pair'),
-## :node($/)
-## );
-## }
-.sub 'colonpair' :method
- .param pmc match
- $S0 = match['ident']
- $P0 = match['ident']
- $P9 = get_hll_global ['PAST'], 'Val'
- $P1 = $P9.'new'('value'=>$S0, 'node'=>$P0)
- $P2 = match['EXPR']
- $P2 = $P2.'ast'()
- $P9 = get_hll_global ['PAST'], 'Op'
- $P3 = $P9.'new'($P1, $P2, 'name'=>'infix:=>', 'returns'=>'Pair', 'node'=>match)
- match.'!make'($P3)
-.end
-
-
-## method package_declarator($/, $key) {
-## my $past := $($/{$key});
-## $past.namespace($<name><ident>);
-## $past.blocktype('declaration');
-## $past.pirflags(':init :load');
-## if ($<sym> eq 'class') {
-## my $classpast :=
-## PAST::Op.new(
-## ...P6metaclass...,
-## ~$<name>,
-## :pasttype('callmethod'), :name('new_class')
-## );
-## if $<parent> {
-## $classpast.push(
-## PAST::Val.new( ~$<parent>[0] , :named('parent') )
-## );
-## }
-## $past.push($classpast);
-## }
-## make $past;
-## }
-.sub 'package_declarator' :method
- .param pmc match
- .param pmc key
- .local pmc past
- $P0 = match[key]
- past = $P0.'ast'()
- $P1 = match['name']
- $P1 = $P1['ident']
- past.'namespace'($P1)
- past.'blocktype'('declaration')
- past.'pirflags'(':init :load')
- past.'lexical'(0)
- $S0 = match['sym']
- if $S0 != 'class' goto class_done
- .local pmc classvar, classop
- $P0 = get_hll_global ['PAST'], 'Op'
- classvar = $P0.'new'( 'inline'=>'%r = get_root_global ["parrot"], "P6metaclass"' )
- $P0 = get_hll_global ['PAST'], 'Op'
- $S0 = match['name']
- classop = $P0.'new'( classvar, $S0, 'pasttype'=>'callmethod', 'name'=>'new_class')
- $P2 = past[0]
- .local pmc parent
- parent = match['parent']
- if null parent goto parent_done
- $S0 = parent[0]
- $P0 = get_hll_global ['PAST'], 'Val'
- $P1 = $P0.'new'( 'value'=>$S0, 'named'=>'parent' )
- classop.'push'($P1)
- parent_done:
- $P2.'push'(classop)
- class_done:
- match.'!make'(past)
-.end
-
-
-## method scope_declarator($/) {
-## my $past := $($<variable>);
-## my $name := $past.name();
-## our $?BLOCK;
-## unless $?BLOCK.symbol($name) {
-## $past.isdecl(1);
-## my $scope := ($<declarator> eq 'my') ? 'lexical' : 'package';
-## $?BLOCK.symbol($name, :scope($scope));
-## }
-## make $past;
-## }
-.sub 'scope_declarator' :method
- .param pmc match
- .local pmc past, block
- .local string name
- $P0 = match['variable']
- past = $P0.'ast'()
- name = past.'name'()
- block = get_global '$?BLOCK'
- $P0 = block.'symbol'(name)
- if $P0 goto end
- past.'isdecl'(1)
- .local string scope
- scope = 'package'
- $S0 = match['declarator']
- if $S0 != 'my' goto have_scope
- scope = 'lexical'
- have_scope:
- block.'symbol'(name, 'scope'=>scope)
- end:
- match.'!make'(past)
-.end
-
-
-## method variable($/, $key) {
-## if ($key eq '$< >') {
-## make PAST::Var.new(
-## PAST::Var.new(:scope('lexical'), :name('$/') ),
-## PAST::Val.new(:value(~$/[0])),
-## :scope('keyed'),
-## :viviself('Undef') );
-## }
-## else {
-## make PAST::Var.new( :node($/), :name(~$/) )
-## }
-## }
-.sub 'variable' :method
- .param pmc match
- .param pmc key
- if key != '$< >' goto past_var
- past_match_keyed:
- $P0 = get_hll_global ['PAST'], 'Var'
- $P1 = $P0.'new'('scope'=>'lexical', 'name'=>'$/')
- $P2 = get_hll_global ['PAST'], 'Val'
- $S0 = match[0]
- $P3 = $P2.'new'('value'=>$S0)
- $P4 = $P0.'new'($P1, $P3, 'scope'=>'keyed', 'viviself'=>'Undef')
- match.'!make'($P4)
- .return ()
- past_var:
- $S0 = match
- $S1 = match['sigil']
- $S2 = 'Undef'
- if $S1 != '%' goto past_sigil_is_array
- $S2 = 'Hash'
- goto past_sigil
- past_sigil_is_array:
- if $S1 != '@' goto past_sigil
- $S2 = 'ResizablePMCArray'
- goto past_sigil
- past_sigil:
- $P0 = get_hll_global ['PAST'], 'Var'
- $P1 = $P0.'new'('node'=>match, 'name'=>$S0, 'viviself'=>$S2)
- match.'!make'($P1)
-.end
-
-
-## method value($/, $key) {
-## make $($/{$key});
-## }
-.sub 'value' :method
- .param pmc match
- .param pmc key
- $P0 = match[key]
- $P1 = $P0.'ast'()
- match.'!make'($P1)
-.end
-
-
-## method quote($/, $key) {
-## if $key eq 'PIR' {
-## make PAST::Op.new( :node($/), :inline(~($[0])) );
-## }
-## else {
-## make PAST::Val.new( :node($/), :value(~($<string_literal>)) );
-## }
-## }
-.sub 'quote' :method
- .param pmc match
- .param pmc key :optional
- .local string value
- unless key == 'PIR' goto quote_string
- quote_pir:
- $S0 = match[0]
- $P0 = get_hll_global ['PAST'], 'Op'
- $P1 = $P0.'new'('node'=>match, 'inline'=>$S0)
- goto end
- quote_string:
- $P0 = match['string_literal']
- value = $P0.'ast'()
- $P0 = get_hll_global ['PAST'], 'Val'
- $P1 = $P0.'new'('node'=>match, 'value'=>value)
- end:
- match.'!make'($P1)
-.end
-
-
-## method typename($/, $key) {
-## my $ns := $<name><ident>.clone();
-## my $name := $ns.pop();
-## make PAST::Var.new( :node($/),
-## :scope('package'),
-## :name($name),
-## :namespace($ns)
-## );
-## }
-.sub 'typename' :method
- .param pmc match
- .param pmc key
- .local pmc ns, name
- $P0 = match['name']
- $P0 = $P0['ident']
- ns = clone $P0
- name = pop ns
- $P0 = get_hll_global ['PAST'], 'Var'
- $P1 = $P0.'new'('node'=>match, 'scope'=>'package', 'name'=>name, 'namespace'=>ns)
- match.'!make'($P1)
-.end
-
-
-## method number($/, $key?) {
-## make PAST::Val.new( :node($/), :name(~$/), :returns("Integer") );
-## }
-.sub 'number' :method
- .param pmc match
- .param pmc key :optional
- .local pmc past
- $I0 = match
- $P0 = get_hll_global ['PAST'], 'Val'
- past = $P0.'new'('node'=>match, 'value'=>$I0)
- match.'!make'(past)
-.end
-
-
-## method subcall($/, $key?) {
-## my $past := $($<arglist>);
-## $past.name(~$<ident>);
-## $past.pasttype('call');
-## $past.node($/);
-## make $past;
-## }
-.sub 'subcall' :method
- .param pmc match
- .param pmc key :optional
- .local pmc past
- $P0 = match['arglist']
- past = $P0.'ast'()
- $S0 = match['ident']
- past.'name'($S0)
- past.'pasttype'('call')
- past.'node'(match)
- match.'!make'(past)
-.end
-
-
-#### Expressions and operators ####
-
-## method EXPR($/, $key) {
-## if ($key eq 'end') { make $($<expr>); }
-## my $past := PAST::Op.new( :node($/),
-## :name($<type>),
-## :opattr($<top>),
-## );
-## for @($/) {
-## $past.push($($_));
-## }
-## make $past;
-## }
-.sub 'EXPR' :method
- .param pmc match
- .param pmc key
- if key != 'end' goto expr_reduce
- expr_end:
- $P0 = match['expr']
- $P1 = $P0.'ast'()
- match.'!make'($P1)
- .return ()
- expr_reduce:
- .local pmc past, opattr
- .local string name
- name = match['type']
- opattr = match['top']
- $P0 = get_hll_global ['PAST'], 'Op'
- past = $P0.'new'('node'=>match, 'name'=>name, 'opattr'=>opattr)
- $P1 = match.'list'()
- if null $P1 goto iter_end
- .local pmc it
- it = iter $P1
- iter_loop:
- unless it goto iter_end
- $P2 = shift it
- $I0 = $P2.'from'()
- $I1 = $P2.'to'()
- if $I0 == $I1 goto iter_loop
- $P2 = $P2.'ast'()
- past.'push'($P2)
- goto iter_loop
- iter_end:
- match.'!make'(past)
-.end
-
-# Local Variables:
-# mode: pir
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
Deleted: trunk/compilers/nqp/src/builtins.pir
==============================================================================
--- trunk/compilers/nqp/src/builtins.pir Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,156 +0,0 @@
-# Copyright (C) 2007-2009, Parrot Foundation.
-# $Id$
-
-.namespace []
-
-=over 4
-
-=item C<print(...)>
-
-Implementing a Perl 6 style print statement.
-
-=cut
-
-.sub 'print'
- .param pmc list :slurpy
- .local pmc it
-
- it = iter list
- iter_loop:
- unless it goto iter_end
- $P0 = shift it
- print $P0
- goto iter_loop
- iter_end:
- .return (1)
-.end
-
-
-=item C<say(...)>
-
-Implementing a Perl 6 style say statement, which automatically appends
-a newline to the end of what is printed.
-
-=cut
-
-.sub 'say'
- .param pmc list :slurpy
- .tailcall 'print'(list :flat, "\n")
-.end
-
-
-=item C<infix:,>
-
-Build a list from the arguments sent to the operator.
-
-=cut
-
-.sub 'infix:,'
- .param pmc args :slurpy
- .local pmc list
- list = new 'ResizablePMCArray'
- args_loop:
- unless args goto end
- $P0 = shift args
- push list, $P0
- goto args_loop
- end:
- .return (list)
-.end
-
-=item C<ok(...)>
-
-Internal implementation of the Test::More 'ok'. It increments
-the internal test counter and handles making test output.
-
-=cut
-
-.sub 'ok'
- .param pmc condition
- .param string description :optional
- .param int has_desc :opt_flag
- if condition goto it_was_ok
- print "not "
- it_was_ok:
- print "ok "
- $P0 = get_global "$test_counter"
- $P0 += 1
- print $P0
- unless has_desc goto no_description
- print " # "
- print description
- no_description:
- print "\n"
- .return (1)
-.end
-
-
-=item C<plan(...)>
-
-Internal implementation of the Test::More 'plan'. It sets the internal
-test counter to 0 and outputs the TAP plan line.
-
-=cut
-
-.sub 'plan'
- .param int quantity
- $P0 = new 'Integer'
- $P0 = 0
- set_global "$test_counter", $P0
- print "1.."
- print quantity
- print "\n"
-.end
-
-.sub 'onload' :init :load
- #Initialize on load, in case they do not call plan.
- $P0 = new 'Integer'
- $P0 = 0
- set_global "$test_counter", $P0
-.end
-
-=item C<load_bytecode(string)>
-
-=cut
-
-.sub 'load_bytecode'
- .param string str
- load_bytecode str
- .return ()
-.end
-
-=item C<sleep(sec)>
-
-=cut
-
-.sub 'sleep'
- .param int sec
- sleep sec
- .return ()
-.end
-
-=item C<eval(lang,code)>
-
-=cut
-
-.sub 'eval'
- .param string text
- .param string lang
- .local pmc c, code
- lang = downcase lang
- load_language lang
- c = compreg lang
- code = c.'compile'(text)
- $P0 = code()
- .return ($P0)
-.end
-
-=back
-
-=cut
-
-# Local Variables:
-# mode: pir
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
Deleted: trunk/compilers/nqp/t/01-literals.t
==============================================================================
--- trunk/compilers/nqp/t/01-literals.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,18 +0,0 @@
-# check literals
-
-say('1..8');
-
-print("ok ");
-print(1);
-print("\n");
-
-print('ok ');
-say(2);
-
-print("ok 3\n");
-say('ok 4');
-say("ok 5");
-say(q<ok 6>);
-say(q <ok 7>);
-
-say("\x6f\x6b 8");
Deleted: trunk/compilers/nqp/t/02-if-else.t
==============================================================================
--- trunk/compilers/nqp/t/02-if-else.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,130 +0,0 @@
-# check control structure 'if ... else'
-
-say('1..14');
-
-if 1 { say("ok 1 # on one line with else"); } else { say("not ok 1 # on one line with else")}
-
-say("ok 2 # statements following if with else are okay");
-
-if 1 {
- print("ok 3");
-}
-else {
- print("not ok 3");
-}
-say(" # multi-line if with else");
-
-if 0 {
- print("not ok 4");
-}
-else {
- print("ok 4");
-}
-say(" # multi-line if, else branch");
-
-if 0 {
-}
-else {
- print("ok 5");
-}
-say(" # empty if-block");
-
-if 0 {
- print("not ok 6");
-}
-else {
-}
-print("ok 6");
-say(" # empty else-block");
-
-if 0 {
-}
-else {
-}
-print("ok 7");
-say(" # empty if- and else-block");
-
-if 0 {
-}
-elsif 0 {
-}
-elsif 0 {
-}
-else {
-}
-print("ok 8");
-say(" # empty if-, elsif-, and else-block");
-
-if 1 {
- print("ok 9");
-}
-elsif 0 {
- print("not ok 9 # elsif 1");
-}
-elsif 0 {
- print("not ok 9 # elsif 2");
-}
-else {
- print("not ok 9 # else");
-}
-say(" # if expr true in if/elsif/elsif/else");
-
-if 0 {
- print("not ok 10 # if");
-}
-elsif 1 {
- print("ok 10");
-}
-elsif 0 {
- print("not ok 10 # elsif 2");
-}
-else {
- print("not ok 10 # else");
-}
-say(" # first elsif expr true in if/elsif/elsif/else");
-
-if 0 {
- print("not ok 11 # if");
-}
-elsif 0 {
- print("not ok 11 # elsif 1");
-}
-elsif 1 {
- print("ok 11");
-}
-else {
- print("not ok 11 # else");
-}
-say(" # second elsif expr true in if/elsif/elsif/else");
-
-if 0 {
- print("not ok 12 # if");
-}
-elsif 1 {
- print("ok 12");
-}
-elsif 1 {
- print("not ok 12 # elsif 2");
-}
-else {
- print("not ok 12 # else");
-}
-say(" # first and second elsif expr true in if/elsif/elsif/else");
-
-if 0 {
- print("not ok 13 # if");
-}
-elsif 0 {
- print("not ok 13 # elsif 1");
-}
-elsif 0 {
- print("not ok 13 # elsif 2");
-}
-else {
- print("ok 13");
-}
-say(" # else expr true in if/elsif/elsif/else");
-
-if 0 { } elsif 0 { }
-print("ok 14");
-say(" # no else block in if/elsif")
Deleted: trunk/compilers/nqp/t/02-if.t
==============================================================================
--- trunk/compilers/nqp/t/02-if.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,16 +0,0 @@
-# check control structure 'if'
-
-say('1..4');
-
-if 1 { say("ok 1 # on one line"); }
-
-say("ok 2 # statements following if are okay");
-
-if 1 {
- say("ok 3 # multi-line if");
-}
-
-if 0 {
- print("not ");
-}
-say("ok 4 # multi-line if, false condition causes block not to execute");
Deleted: trunk/compilers/nqp/t/03-unless.t
==============================================================================
--- trunk/compilers/nqp/t/03-unless.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,16 +0,0 @@
-# check control structure 'unless'
-
-say('1..4');
-
-unless 0 { say("ok 1 # on one line"); }
-
-say("ok 2 # statements following unless are okay");
-
-unless 0 {
- say("ok 3 # multi-line unless");
-}
-
-unless 1 {
- print("not ");
-}
-say("ok 4 # testing conditional");
Deleted: trunk/compilers/nqp/t/04-comments.t
==============================================================================
--- trunk/compilers/nqp/t/04-comments.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,11 +0,0 @@
-# check comments
-
-say('1..2');
-
-#Comment preceding
-say("ok 1");
-
-say("ok 2"); #Comment following
-
-#say("not ok 3");
-# say("not ok 4");
Deleted: trunk/compilers/nqp/t/05-pod.t
==============================================================================
--- trunk/compilers/nqp/t/05-pod.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,25 +0,0 @@
-# check pod
-
-say('1..4');
-
-say("ok 1");
-
-=head1 POD comment
-
-This next line should not be executed because it is inside
-of a valid pod statement.
-
-print("not ");
-
-=cut
-
-say("ok 2 # POD comments end");
-
-=for comment
-
-say("ok 3 # = for terminated by a new line");
-
-=for comment
-print("not ");
-
-say("ok 4 # actually comment out something");
Deleted: trunk/compilers/nqp/t/06-args-pos.t
==============================================================================
--- trunk/compilers/nqp/t/06-args-pos.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,8 +0,0 @@
-# positional arguments
-
-say('1..2');
-
-say("ok ", 1);
-
-print('o', 'k', ' ', 2, "\n");
-
Deleted: trunk/compilers/nqp/t/07-boolean.t
==============================================================================
--- trunk/compilers/nqp/t/07-boolean.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,25 +0,0 @@
-# Testing boolean context operators, ! and ?
-
-plan(8);
-
-##Negation
-ok(!0, 'prefix negation on integer 0');
-ok(!"0", 'prefix negation on string 0');
-
-if !1 {
- print("not");
-}
-ok(1, "negating integer 1");
-
-ok(!!1, 'double negation on 1');
-
-##Boolean context
-ok(?1, 'prefix negation on integer 1');
-ok(?"10", 'prefix negation on string 10');
-
-if ?0 {
- print("not");
-}
-ok(1, "boolean integer 0");
-
-ok(!?!?1, 'spaghetti chaining');
Deleted: trunk/compilers/nqp/t/08-blocks.t
==============================================================================
--- trunk/compilers/nqp/t/08-blocks.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,31 +0,0 @@
-# check blocks and statement enders
-
-say('1..7');
-
-{
- say("ok 1 # blocks are okay");
-}
-
-{
- print("ok ");
- say("2 # last statement in a block does not need a semi-colon")
-}
-
-
-{
- say("ok 3 # statements can precede blocks");
- {
- say("ok 4 # blocks can nest");
- }
- say("ok 5 # statements can follow blocks");
-}
-
-
-{ print("ok ") }; { say("6 # multiple blocks on one line need a semi-colon") }
-
-{
- print("ok ")
-}; {
- say("7 # blocks following an end brace must be separated by a semicolon")
-}
-
Deleted: trunk/compilers/nqp/t/09-var.t
==============================================================================
--- trunk/compilers/nqp/t/09-var.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,82 +0,0 @@
-# check variables
-
-say('1..14');
-
-my $o1 := 'ok 1'; print($o1); say(" # direct binding and scoping");
-
-my $o2; $o2 := 'ok 2'; print($o2); say(" # first scope and declare, then bind");
-
-my $o3 := 'ok 3';
-my $p3 := $o3;
-print($p3); say(" # bind to another variable");
-
-my $o4 := 'ok 4';
-my $p4 := $o4;
-$o4 := 'not ok 4';
-print($p4); say(" # rebind the original, the bound one does not change");
-
-my $o5 := 'ok 5';
-my $p5 := $o5;
-my $o5 := 'not ok 5';
-unless $p5 {
- print("not ");
-}
-say("ok 5 # rebind and redeclare the original. The value is lost");
-
-my $r1 := 'not ok 6';
-my $r2 := 'ok 6';
-my $r3;
-$r3 := $r1;
-$r3 := $r2;
-print($r3); say(' # variables can be rebound');
-
-my $b1 := 'ok 8';
-
-{
- my $b1 := 'ok 7';
- print($b1); say(' # my scoping works inside a block');
-}
-
-print($b1); say(' # block does not stomp on out scope');
-
-my $b2 := 'ok 9';
-
-{
- print($b2); say(' # variables scoped outside of block persists inside the block');
-}
-
-my $b3;
-{
- my $b4 := 'ok 10';
- $b3 := $b4;
-}
-print($b3); say(' # variable is bound to the value, not the symbol in the block');
-
-my $b5 := '';
-{
- my $b5 := 'not ';
-}
-print($b5);say('ok 11 # $b5, defined inside block, does not exist outside');
-
-{
- our $m1 := 'ok 12 ';
-}
-
-our $m1;
-unless $m1 {
- print('not ');
-}
-say('ok 12 # our variables have package scope, exists outside of block');
-
-our $m2;
-$m2 := 'ok 13';
-{
- print($m2); say(' # our variables exist inside blocks');
-}
-
-our $m3;
-$m3 := 'not ok 14';
-{
- $m3 := 'ok 14';
-}
-print($m3); say(' # our variables written inside block keep their values outside');
Deleted: trunk/compilers/nqp/t/10-sub.t
==============================================================================
--- trunk/compilers/nqp/t/10-sub.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,74 +0,0 @@
-# check subs
-
-say('1..11');
-
-sub one ( ) {
- say("ok 1 # sub def and call");
-}
-
-one();
-
-{
- sub two ( ) {
- say("ok 2 # sub def and call inside block");
- }
- two();
-}
-
-sub three ( ) { say("ok 3 # sub def; sub call on same line"); }; three();
-
-sub four_five ($arg1) {
- say($arg1);
-}
-four_five('ok 4 # passed in 1 arg');
-
-{
- four_five('ok 5 # calling sub in outer scope');
-}
-
-{
- sub six ( ) {
- say("ok 6 # def in inner scope, called from outer scope");
- }
-}
-six();
-
-sub seven () {
- "ok 7 # return string literal from sub";
-}
-
-say(seven());
-
-sub eight () {
- "ok 8 # bind sub return to variable";
-}
-
-my $retVal := eight();
-
-unless $retVal {
- print("not ");
-}
-say($retVal);
-
-sub add_stomp ($first, $last) {
- my $sum := $first + $last;
- $first := $last - $first;
- $sum;
-}
-
-print("ok "); print(add_stomp(3,6)); say(" # returning the result of operating on arguments");
-
-my $five := 5;
-my $seven := 7;
-
-add_stomp($five, $seven);
-
-if $five != 5 {
- print("not ");
-}
-say("ok 10 # subroutines that operate on args do not affect the original arg outside the sub");
-
-sub eleven ($arg) {
- say("ok 11 # parameter with a trailing comma");
-}
-eleven( 'dummy', );
Deleted: trunk/compilers/nqp/t/11-cmp.t
==============================================================================
--- trunk/compilers/nqp/t/11-cmp.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,96 +0,0 @@
-# check comparisons
-
-say('1..19');
-
-##Integers, positive and negative
-
-if 1 == 1 { say("ok 1 # numeric equality, integers"); }
-
-unless 1 == 2 {
- say("ok 2 # numeric equality, integers, not equal");
-}
-
-if -3 == -3 { say("ok 3 # numeric equality, negative integers"); }
-
-if 1 != 2 { say("ok 4 # numeric inequality, integers"); }
-
-unless 1 != 1 {
- say("ok 5 # numeric inequality, equal, integers");
-}
-
-unless -2 != -2 {
- say("ok 6 # numeric inequality, equal, negative integers");
-}
-
-##Strings
-
-if "eq" eq "eq" { say("ok 7 # string equality"); }
-
-unless "one" eq "two" {
- say("ok 8 # string equality, not equal");
-}
-
-if "ONE" ne "TWO" { say("ok 9 # string inequality"); }
-
-unless "STRING" ne "STRING" {
- say("ok 10 # string inequality, equal");
-}
-
-##Coerce strings into integers
-
-if "11" ne ~11 {
- print("not ");
-}
-say("ok 11 # coerce integer 11 into string eleven");
-
-if "-12" ne ~-12 {
- print("not ");
-}
-say("ok 12 # coerce integer -12 into string twelve");
-
-##Coerce integers into strings
-
-if 13 ne +"13" {
- print("not ");
-}
-say("ok 13 # coerce string 13 into an integer");
-
-if -14 ne +"-14" {
- print("not ");
-}
-say("ok 14 # coerce string -14 into an integer");
-
-##Containers
-
-if (1,2) =:= (1,2) {
- print("not ");
-}
-say("ok 15 # container equality, unnamed arrays");
-
-my @a := (1, 2);
-
-unless @a =:= @a {
- print("not ");
-}
-say("ok 16 # container equality, self");
-
-my @b := @a;
-
-unless @a =:= @b {
- print("not ");
-}
-say("ok 17 # container equality, named arrays");
-
-my $x := 'foo';
-my $y := $x;
-my $z := 'foo';
-
-unless $x =:= $y {
- print("not ");
-}
-say("ok 18 # container equality, string binding");
-
-if $x =:= $z {
- print("not ");
-}
-say("ok 19 # container equality, string value");
Deleted: trunk/compilers/nqp/t/12-list.t
==============================================================================
--- trunk/compilers/nqp/t/12-list.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,10 +0,0 @@
-# lists and for
-
-plan(3);
-
-my $list := (1,2,3);
-my $indexer := 0;
-
-for $list {
- print("ok "); print($_); say(" checking loop via indices");
-}
Deleted: trunk/compilers/nqp/t/13-logical.t
==============================================================================
--- trunk/compilers/nqp/t/13-logical.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,19 +0,0 @@
-# check '||' and '&&'
-
-plan(4);
-
-my $or_no_branch := 1;
-$or_no_branch || ( $or_no_branch := 0 );
-ok($or_no_branch, "logical || shortcuts, branch not taken");
-
-my $or_branch := 0;
-0 || ( $or_branch := 1 );
-ok($or_branch, "logical || shortcuts, branch taken");
-
-my $and_no_branch := 0;
-$and_no_branch && ( $and_no_branch := 1 );
-ok(!$and_no_branch, "logical && shortcuts, branch not taken");
-
-my $and_branch := 0;
-1 && ( $and_branch := 1 );
-ok($and_branch, "logicl && shortcuts, branch taken");
Deleted: trunk/compilers/nqp/t/14-op.t
==============================================================================
--- trunk/compilers/nqp/t/14-op.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,46 +0,0 @@
-# checking basic operands and circumfix:( )
-
-plan(29);
-
-##Additive operators
-ok( 1+2 == 3, 'Checking addition 1+2');
-ok( 10-9 == 1, 'Checking subtraction 10-9');
-ok( 10-3+2 == 9, 'Checking compound statements 10-3+2');
-ok( 10-(3+2) == 5, 'Checking parenthesized statement 10-(3+2)');
-
-##Multiplicative operators
-ok( 6*7 == 42, 'Checking multiplication 6*7');
-ok( 36/6 == 6, 'Checking division 36/6');
-ok( 4*3+5 == 17, 'Checking compound statements 4*3+5');
-ok( 4*(3+5) == 32, 'Checking parenthesized statements 4*(3+5)');
-ok( 12/4*3 == 9, 'Checking compound statements 12/4*3');
-ok( 12/(4*3) == 1, 'Checking compound statements 12/(4*3)');
-ok( 5-3*2 == -1, 'Checking compound statements 5-3*2');
-
-##Modulo operator
-ok( 8%3 == 2, 'Checking modulo 8%3');
-ok( 8%3+2 == 4, 'Checking compound statement 8%3+2');
-ok( 8%(3+2) == 3, 'Checking compound statement 8%(3+2)');
-
-##Concatenation operator
-ok( 'a' ~ 'b' eq 'ab', 'Checking concatenation "a" ~ "b"');
-ok( 1 ~ 'b' eq '1b', 'Checking concatenation 1 ~ "b"');
-ok( 'a' ~ 2 eq 'a2', 'Checking concatenation "a" ~ 2 ');
-
-##Postfix operators
-my $x := 0;
-ok( $x++ == 0 );
-ok( $x == 1 );
-ok( $x-- == 1 );
-ok( $x == 0 );
-
-##Relational operators
-ok( ?(1 < 2) );
-ok( !(2 < 1) );
-ok( ?(2 <= 2) );
-ok( !(3 <= 2) );
-ok( ?(2 > 1) );
-ok( !(2 > 3) );
-ok( ?(2 >= 1) );
-ok( !(2 >= 3) );
-
Deleted: trunk/compilers/nqp/t/15-module.t
==============================================================================
--- trunk/compilers/nqp/t/15-module.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,16 +0,0 @@
-# check module
-
-XYZ::sayfoo();
-XYZ::foo('ok 3');
-XYZ::sayfoo();
-
-module XYZ {
- our $value := 'ok 1';
- sub foo($x) { $value := $x; }
- sub sayfoo() { say($value); }
- say('1..3');
- sayfoo();
- foo('ok 2');
-}
-
-
Deleted: trunk/compilers/nqp/t/16-while.t
==============================================================================
--- trunk/compilers/nqp/t/16-while.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,61 +0,0 @@
-# while, until statements
-
-plan(8);
-
-my $a; my $sum;
-
-$a := 1; $sum := 0;
-while $a != 10 {
- $sum := $sum + $a;
- $a := $a + 1;
-}
-ok($sum == 45, 'basic while loop test');
-
-$a := 1; $sum := 0;
-until $a == 10 {
- $sum := $sum + $a;
- $a := $a + 1;
-}
-ok($sum == 45, 'basic until loop test');
-
-$a := 1; $sum := 0;
-while $a != 1 {
- $sum := 99;
- $a := 1;
-}
-ok($sum == 0, 'while loop exits initial false immediately');
-
-$a := 1; $sum := 0;
-until $a == 1 {
- $sum := 99;
- $a := 1;
-}
-ok($sum == 0, 'until loop exits initial true immediately');
-
-$a := 1; $sum := 0;
-repeat {
- $sum := $sum + $a;
- $a := $a + 1;
-} while $a != 10;
-ok($sum == 45, 'basic repeat_while loop');
-
-$a := 1; $sum := 0;
-repeat {
- $sum := $sum + $a;
- $a := $a + 1;
-} until $a == 10;
-ok($sum == 45, 'basic repeat_until loop');
-
-$a := 1; $sum := 0;
-repeat {
- $sum := 99;
-} while $a != 1;
-ok($sum == 99, 'repeat_while always executes at least once');
-
-$a := 1; $sum := 0;
-repeat {
- $sum := 99;
-} until $a == 1;
-ok($sum == 99, 'repeat_until always executes at least once');
-
-
Deleted: trunk/compilers/nqp/t/17-class.t
==============================================================================
--- trunk/compilers/nqp/t/17-class.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,14 +0,0 @@
-# class
-
-plan(1);
-
-class XYZ {
- method foo($x) {
- say($x);
- }
-}
-
-
-my $xyz := XYZ.new();
-
-$xyz.foo('ok 1');
Deleted: trunk/compilers/nqp/t/18-inline.t
==============================================================================
--- trunk/compilers/nqp/t/18-inline.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,22 +0,0 @@
-# inline
-
-plan(7);
-
-PIR q< say 'ok 1' >;
-PIR q:to:'OK2';
- say 'ok 2'
-OK2
-
-PIR q:to:<OK4>;
- say 'ok 3'
- say 'ok 4'
- OK4
-
-PIR q:to:"OK5";
- say 'ok 5'
-OK5
-
-Q:PIR { say 'ok 6' };
-my $x := Q:PIR { %r = box 'ok 7' };
-say($x);
-
Deleted: trunk/compilers/nqp/t/19-hash_access.t
==============================================================================
--- trunk/compilers/nqp/t/19-hash_access.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,25 +0,0 @@
-# check hash access methods
-
-plan(7);
-
-my %h;
-
-%h<a> := 1;
-say("ok 1 # hash assignment with numeric value works");
-
-say('ok ', %h<a> + 1, ' # hash access to numeric value');
-
-%h<a> := 'ok 3';
-say(%h<a>, ' # hash access to string value');
-
-%h{1} := '4';
-say('ok ', %h{1}, ' # numeric hash access');
-
-say('ok ', %h<1> + 1, ' # numbers stringify');
-
-%h{'b'} := 'ok 6 # curly braces and single quotes work';
-say(%h{'b'});
-
-%h{"foo"} := "ok 7 # curly braces and double quotes work";
-say(%h{"foo"});
-
Deleted: trunk/compilers/nqp/t/20-list_access.t
==============================================================================
--- trunk/compilers/nqp/t/20-list_access.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,21 +0,0 @@
-# check list access methods
-
-plan(7);
-
-my @l := (1,2,3,4,5);
-
-say("ok 1 # list assignment didn't barf");
-say('ok ', @l[1], ' # numeric subscript');
-say('ok ', @l['2'], ' # string subscript');
-
-my $idx := 3;
-
-say('ok ', @l[$idx], ' # variable subscript');
-say('ok ', @l[$idx + 1], ' # expression in subscript');
-
- at l[0] := 'ok 6 # string array element';
-say(@l[0]);
-
- at l[10] := 'ok 7 # automatic expansion';
-say(@l[10]);
-
Deleted: trunk/compilers/nqp/t/22-optional_args.t
==============================================================================
--- trunk/compilers/nqp/t/22-optional_args.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,28 +0,0 @@
-# test optional arguments and parameters
-
-plan(3);
-
-sub f1 ($x, $y!, $z?) {
- $x;
-}
-say('ok ', f1(1, 2), ' # optional args ignorable');
-say('ok ', f1(2, 2, 2), ' # optional args passable');
-
-sub f2 ($x?, $y?) { 'ok 3 # only optional args'; }
-say(f2());
-
-# TODO we can't parse .defined() yet - jg
-#sub f3 ($x, $y?, $text?) {
-# if ! $y.defined() && ! $text.defined() {
-# say('ok 4 # unpassed optional args are undef');
-# } else {
-# say('ok ', $x - $y, $text);
-# }
-#}
-#f3(2);
-#f3(8, 3, ' # optional args get passed values');
-#f3(8, :text(' # optional args specifiable by name'), :y(2));
-
-# XXX: need to be able to test that the following is illegal
-#sub f4 ($x?, $y) { $y; }
-
Deleted: trunk/compilers/nqp/t/23-named_args.t
==============================================================================
--- trunk/compilers/nqp/t/23-named_args.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,18 +0,0 @@
-# test named parameters and arguments
-
-plan(4);
-
-sub f1 ($x, :$y) { $x - $y; }
-say('ok ', f1(2, :y(1)), ' # named args passable');
-
-sub f2 ($x, :$y) { $x; }
-say('ok ', f2(2), ' # named args ignorable');
-
-sub f3 (:$x, :$y) { $x - $y; }
-say('ok ', f3(:y(2), :x(5)), ' # args reorderable');
-
-sub f4 ($w, $x, :$y, :$z) { $w + $x + $y + $z; }
-say('ok ', f4(:z(2), -3, :y(1), 4), ' # named/positional intermixable');
-
-
-# XXX: test mandatory named args are actually mandatory
Deleted: trunk/compilers/nqp/t/24-scalar_context.t
==============================================================================
--- trunk/compilers/nqp/t/24-scalar_context.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,14 +0,0 @@
-# scalar context
-
-plan(1);
-
-class XYZ {
- method ast() {
- 'ok 1';
- }
-}
-
-
-my $xyz := XYZ.new();
-
-say( $( $xyz ) );
Deleted: trunk/compilers/nqp/t/25-list_context.t
==============================================================================
--- trunk/compilers/nqp/t/25-list_context.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,17 +0,0 @@
-# list context
-
-plan(1);
-
-class XYZ {
- method list() {
- 'ok ', '1';
- }
-}
-
-
-my $xyz := XYZ.new();
-
-for @( $xyz ) {
- print( $_ );
-}
-print( "\n" );
Deleted: trunk/compilers/nqp/t/26-method_ops.t
==============================================================================
--- trunk/compilers/nqp/t/26-method_ops.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,28 +0,0 @@
-# method ops (just method calls for now)
-
-plan(3);
-
-class Foo {
- method blarg() {
- 'ok 1 # method calls work';
- }
- method blargless() {
- 'ok 3 # argument-less method calls work'
- }
-}
-
-class Bar {
- method blarg() {
- 'not ok 1';
- }
-}
-
-sub blarg() {
- 'ok 2 # regular subs aren\'t confused with methods';
-}
-
-my $foo := Foo.new();
-
-say($foo.blarg());
-say(blarg());
-say($foo.blargless);
Deleted: trunk/compilers/nqp/t/27-ternary.t
==============================================================================
--- trunk/compilers/nqp/t/27-ternary.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,21 +0,0 @@
-# the ternary ?? !! operator
-
-plan(8);
-
-ok( 1 ?? 1 !! 0 );
-ok( 0 ?? 0 !! 1 );
-
-my $a := 1 ?? 'yes' !! 'no';
-ok( $a eq 'yes' );
-
-my $b := 0 ?? 'yes' !! 'no';
-ok( $b eq 'no' );
-
-my $c := 1 ?? 'yes' !! ( $a := 'no' );
-ok( $c eq 'yes' );
-ok( $a eq 'yes' );
-
-my $d := 0 ?? ( $a := 'no' ) !! 'yes';
-ok( $d eq 'yes' );
-ok( $a eq 'yes' );
-
Deleted: trunk/compilers/nqp/t/28-return.t
==============================================================================
--- trunk/compilers/nqp/t/28-return.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,21 +0,0 @@
-# implicit and explicit returns from subs
-
-plan(3);
-
-sub foo() { 1; }
-
-
-sub bar() {
- return 2;
- 0;
-}
-
-sub baz() {
- if (1) { return 3; }
- 0;
-}
-
-ok( foo() == 1 , 'last value in block' );
-ok( bar() == 2 , 'explicit return value in block');
-ok( baz() == 3 , 'explicit return from nested block');
-
Deleted: trunk/compilers/nqp/t/29-self.t
==============================================================================
--- trunk/compilers/nqp/t/29-self.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,26 +0,0 @@
-plan(3);
-
-class Foo {
- method foo() { 1 };
-
- method uno() {
- self.foo();
- };
-
- method des() {
- if 1 {
- self.foo();
- }
- };
-
- method tres($a) {
- if 1 {
- self.foo();
- }
- };
-};
-
-ok(Foo.new.uno, "Can access self within method");
-ok(Foo.new.des, "Can access self within sub-block");
-ok(Foo.new.tres(42), "Can access self within method with signature");
-
Deleted: trunk/compilers/nqp/t/30-subclass.t
==============================================================================
--- trunk/compilers/nqp/t/30-subclass.t Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,32 +0,0 @@
-# class inheritance
-
-plan(6);
-
-class ABC {
- method foo() {
- say('ok 1');
- }
-
- method bar() {
- say('ok 3');
- }
-}
-
-class XYZ is ABC {
- method foo() {
- say('ok 2');
- }
-}
-
-
-my $abc := ABC.new();
-my $xyz := XYZ.new();
-
-$abc.foo();
-$xyz.foo();
-$xyz.bar();
-my $xyzhow := $xyz.HOW;
-if $xyzhow.isa($xyz, ABC) { say('ok 4') }
-if $xyzhow.isa($xyz, XYZ) { say('ok 5') }
-say( $xyzhow.isa($abc, XYZ) ?? 'not ok 6' !! 'ok 6' );
-
Deleted: trunk/compilers/nqp/t/harness
==============================================================================
--- trunk/compilers/nqp/t/harness Sat Apr 24 02:23:42 2010 (r45952)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,13 +0,0 @@
-#! perl
-
-# $Id$
-
-use FindBin;
-use lib qw( . lib ../lib ../../lib ../../../lib );
-use Parrot::Test::Harness
- language => 'nqp',
- exec => [ './parrot', 'compilers/nqp/nqp.pbc' ],
- files => [ 'compilers/nqp/t/*.t' ];
-
- #arguments => [ '--files' ],
- #verbosity => 1,
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in Sat Apr 24 01:26:30 2010 (r45952)
+++ trunk/config/gen/makefiles/root.in Sat Apr 24 02:23:42 2010 (r45953)
@@ -118,7 +118,6 @@
include compilers/imcc/Defines.mak
include compilers/pirc/Defines.mak
include compilers/tge/Defines.mak
-include compilers/nqp/Defines.mak
include compilers/pge/Defines.mak
include compilers/pct/Defines.mak
include ext/nqp-rx/Defines.mak
@@ -1676,16 +1675,12 @@
# integrating them in a single run is difficult.
# Normal test package
-test : test_core nqp_test
+test : test_core
# Test Parrot core.
test_core: test_prep
$(PERL) t/harness $(EXTRA_TEST_ARGS)
-# Test the NQP compiler
-nqp_test : test_prep compilers/nqp/nqp.pbc
- $(PERL) compilers/nqp/t/harness
-
# run the test suite, create a TAP archive and send it off to smolder
smolder_test : test_prep
$(PERL) t/harness $(EXTRA_TEST_ARGS) --archive --send-to-smolder
@@ -1714,7 +1709,6 @@
buildtools_tests \
perl_tests \
library_tests \
- nqp_test \
codetest \
benchmark_tests \
manifest_tests \
@@ -2274,7 +2268,6 @@
cover-run \
cover-perl \
cover-extra \
- cover-nqp \
cover-codingstd \
cover-benchmark \
cover-manifest \
@@ -2321,9 +2314,6 @@
cover-extra: cover.dummy
- at make@ library_tests
-cover-nqp: cover.dummy
- - at make@ nqp_test
-
cover-codingstd: cover.dummy
- at make@ codingstd_tests
@@ -2531,7 +2521,6 @@
include runtime/parrot/library/Rules.mak
include compilers/imcc/Rules.mak
include compilers/pirc/Rules.mak
-include compilers/nqp/Rules.mak
include compilers/pge/Rules.mak
include compilers/pct/Rules.mak
include compilers/tge/Rules.mak
More information about the parrot-commits
mailing list