[svn:parrot] r43107 - in trunk: . examples/languages/abc examples/languages/abc/config examples/languages/abc/src/parser lib/Parrot
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Wed Dec 16 15:12:02 UTC 2009
Author: fperrad
Date: Wed Dec 16 15:12:00 2009
New Revision: 43107
URL: https://trac.parrot.org/parrot/changeset/43107
Log:
[abc] update infrastructure with setup.pir (distutils)
Added:
trunk/examples/languages/abc/setup.pir (contents, props changed)
trunk/examples/languages/abc/src/parser/actions.nqp
- copied unchanged from r43091, trunk/examples/languages/abc/src/parser/actions.pm
trunk/examples/languages/abc/src/parser/grammar.nqp
- copied unchanged from r43091, trunk/examples/languages/abc/src/parser/grammar.pg
Deleted:
trunk/examples/languages/abc/Configure.pl
trunk/examples/languages/abc/config/
trunk/examples/languages/abc/src/parser/actions.pm
trunk/examples/languages/abc/src/parser/grammar.pg
Modified:
trunk/MANIFEST
trunk/MANIFEST.SKIP
trunk/examples/languages/abc/ (props changed)
trunk/examples/languages/abc/abc.pir
trunk/lib/Parrot/Distribution.pm
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST Wed Dec 16 14:31:55 2009 (r43106)
+++ trunk/MANIFEST Wed Dec 16 15:12:00 2009 (r43107)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Dec 16 14:11:03 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Wed Dec 16 15:01:30 2009 UT
#
# See below for documentation on the format of this file.
#
@@ -668,15 +668,14 @@
examples/japh/japh5.pasm [examples]
examples/json/postalcodes.pir [examples]
examples/json/test.pir [examples]
-examples/languages/abc/Configure.pl [examples]
examples/languages/abc/MAINTAINER [examples]
examples/languages/abc/README []doc
examples/languages/abc/TODO [examples]
examples/languages/abc/abc.pir [examples]
-examples/languages/abc/config/makefiles/root.in [examples]
+examples/languages/abc/setup.pir [examples]
examples/languages/abc/src/builtins/all.pir [examples]
-examples/languages/abc/src/parser/actions.pm [examples]
-examples/languages/abc/src/parser/grammar.pg [examples]
+examples/languages/abc/src/parser/actions.nqp [examples]
+examples/languages/abc/src/parser/grammar.nqp [examples]
examples/languages/abc/t/01-tests.t [examples]
examples/languages/abc/t/abc_basic [examples]
examples/languages/abc/t/abc_functions [examples]
Modified: trunk/MANIFEST.SKIP
==============================================================================
--- trunk/MANIFEST.SKIP Wed Dec 16 14:31:55 2009 (r43106)
+++ trunk/MANIFEST.SKIP Wed Dec 16 15:12:00 2009 (r43107)
@@ -1,6 +1,6 @@
# ex: set ro:
# $Id$
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Dec 16 14:11:03 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Wed Dec 16 15:01:30 2009 UT
#
# This file should contain a transcript of the svn:ignore properties
# of the directories in the Parrot subversion repository. (Needed for
@@ -315,8 +315,8 @@
^examples/languages/abc/.*\.obj/
^examples/languages/abc/.*\.pbc$
^examples/languages/abc/.*\.pbc/
-^examples/languages/abc/Makefile$
-^examples/languages/abc/Makefile/
+^examples/languages/abc/MANIFEST$
+^examples/languages/abc/MANIFEST/
^examples/languages/abc/abc$
^examples/languages/abc/abc/
^examples/languages/abc/installable_abc$
Deleted: trunk/examples/languages/abc/Configure.pl
==============================================================================
--- trunk/examples/languages/abc/Configure.pl Wed Dec 16 15:12:00 2009 (r43106)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,31 +0,0 @@
-# Copyright (C) 2009, Parrot Foundation.
-# $Id$
-
-use strict;
-use warnings;
-use 5.008;
-
-create_makefiles();
-
-sub create_makefiles {
- my %makefiles = (
- 'config/makefiles/root.in' => 'Makefile',
-# 'config/makefiles/pmc.in' => 'src/pmc/Makefile',
-# 'config/makefiles/ops.in' => 'src/ops/Makefile',
- );
- my $build_tool = '../../../tools/dev/gen_makefile.pl';
-
- foreach my $template (keys %makefiles) {
- my $makefile = $makefiles{$template};
- print "Creating $makefile\n";
- system('perl', $build_tool, $template, $makefile);
- }
-}
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
-
Modified: trunk/examples/languages/abc/abc.pir
==============================================================================
--- trunk/examples/languages/abc/abc.pir Wed Dec 16 14:31:55 2009 (r43106)
+++ trunk/examples/languages/abc/abc.pir Wed Dec 16 15:12:00 2009 (r43107)
@@ -70,7 +70,7 @@
.end
.namespace []
-.include 'src/gen_builtins.pir'
+.include 'src/builtins/all.pir'
=item main(args :slurpy) :main
Added: trunk/examples/languages/abc/setup.pir
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/examples/languages/abc/setup.pir Wed Dec 16 15:12:00 2009 (r43107)
@@ -0,0 +1,72 @@
+#! /usr/local/bin/parrot
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+setup.pir - Python distutils style
+
+=head1 DESCRIPTION
+
+No Configure step, no Makefile generated.
+
+See F<runtime/library/distutils.pir>.
+
+=head1 USAGE
+
+ $ parrot setup.pir
+ $ parrot setup.pir test
+ $ sudo parrot setup.pir install
+
+=cut
+
+.sub 'main' :main
+ .param pmc args
+ $S0 = shift args
+ load_bytecode 'distutils.pbc'
+
+ $P0 = new 'Hash'
+ $P0['name'] = 'abc'
+ $P0['abstract'] = 'a basic calculator'
+ $P0['description'] = 'This is an implementation of the basic calculator using the Parrot compiler tools.'
+ $P0['license_type'] = 'Artistic License 2.0'
+ $P0['license_uri'] = 'http://www.perlfoundation.org/artistic_license_2_0'
+ $P0['copyright_holder'] = 'Parrot Foundation'
+ $P0['checkout_uri'] = 'https://svn.parrot.org/parrot/trunk/examples/languages/abc'
+ $P0['browser_uri'] = 'http://trac.parrot.org/parrot/browser/trunk/examples/languages/abc'
+ $P0['project_uri'] = 'http://trac.parrot.org/parrot/browser/trunk/examples/languages/abc'
+
+ # build
+ $P1 = new 'Hash'
+ $P1['src/gen_grammar.pir'] = 'src/parser/grammar.nqp'
+ $P1['src/gen_actions.pir'] = 'src/parser/actions.nqp'
+ $P0['pir_nqp-rx'] = $P1
+
+ $P2 = new 'Hash'
+ $P3 = split "\n", <<'SOURCES'
+abc.pir
+src/gen_actions.pir
+src/gen_grammar.pir
+src/builtins/all.pir
+SOURCES
+ $S0 = pop $P3
+ $P2['abc.pbc'] = $P3
+ $P0['pbc_pir'] = $P2
+
+ $P4 = new 'Hash'
+ $P4['parrot-abc'] = 'abc.pbc'
+ $P0['exe_pbc'] = $P4
+ $P0['installable_pbc'] = $P4
+
+ # dist
+ $P4 = glob('t/abc_*')
+ $P0['manifest_includes'] = $P4
+
+ .tailcall setup(args :flat, $P0 :flat :named)
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
Copied: trunk/examples/languages/abc/src/parser/actions.nqp (from r43091, trunk/examples/languages/abc/src/parser/actions.pm)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/examples/languages/abc/src/parser/actions.nqp Wed Dec 16 15:12:00 2009 (r43107, copy of r43091, trunk/examples/languages/abc/src/parser/actions.pm)
@@ -0,0 +1,219 @@
+# Copyright (C) 2007, Parrot Foundation.
+# $Id$
+
+=begin overview
+
+abc::Grammar::Actions - ast transformations for abc
+
+This file contains the methods that are used by the parse
+grammar to build the PAST representation of an abc program.
+Each method below corresponds to a rule in F<grammar.pg>,
+and is invoked at the point where C<{*}> appears in the rule,
+with the current match object as the first argument. If the
+line containing C<{*}> also has a C<#= key> comment, then the
+value of the comment is passed as the second argument to the
+method.
+
+Some hopefully helpful hints for reading this file:
+
+It often helps to refer to the rules in F<grammar.pg> when
+looking at the corresponding methods here.
+
+Within a method, C<< $<foo> >> refers to the named capture C<foo>
+within the C< $/ > match object. Normally this is either another
+match object or an array of match objects.
+
+The C<make> function and C< .ast > are used to set and retrieve
+the I<result object> for a match. Here, we use the result object
+to hold the ast representation of any given match. So, in the
+code below, whenever you see an expression like C<< $<foo>.ast >>,
+we're really saying "the ast of C<< <foo> >>".
+
+=end overview
+
+class abc::Grammar::Actions is HLL::Actions;
+
+## The ast of the entire program is the ast of the
+## top-level <statement_list>.
+method TOP($/) {
+ make PAST::Block.new(
+ :blocktype('declaration'),
+ :hll('abc'),
+ $<statement_list>.ast);
+}
+
+
+## statement_list:
+## All of the individual statements are held in $<statement>
+## (which is an array). We start by creating an empty
+## PAST::Stmts node, and then loop through all of the
+## statements, adding the ast of each statement to the
+## PAST::Stmts node.
+method statement_list($/) {
+ my $past := PAST::Stmts.new( :node($/) );
+ for $<statement> {
+ $past.push( $_.ast );
+ }
+ make $past;
+}
+
+
+## statement:
+## In the parse grammar, we've set up $key to tell us the
+## name of whatever subrule was matched by this statement.
+## We can then use $key to quickly get the subrule's ast
+## with $/{$key}.ast .
+##
+## bc(1) expression statements also have special semantics
+## which we handle here. If a statement is an expression
+## other than assignment, then the value of the expression
+## is also assigned to the C<last> variable and the value
+## printed with a newline.
+## Similarly, if the statement consists of a simple string, it's
+## displayed on the output.
+method statement:sym<expr>($/) {
+ my $past := $<EXPR>.ast;
+ if pir::typeof__sp($past) ne 'PAST::Op' && ~$past.name() ne '&infix:<=>' {
+ my $last := PAST::Var.new( :name('last'),
+ :scope('package'),
+ :lvalue(1) );
+ $past := PAST::Op.new( $last,
+ $past,
+ :pasttype('bind') );
+ #PAST::Var.new( :name('saynum'), :namespace([]), :scope('package')),
+ $past := PAST::Op.new(
+ $past,
+ :name('saynum'),
+ :pasttype('call') );
+ }
+ make $past;
+}
+
+
+## if_statement:
+## After parsing an if statement, the conditional
+## expression will be in $<EXPR>, the "then"
+## statement will be in $<statement>[0], and any
+## "else" statement will be in $<statement>[1].
+## So, we just obtain the asts of these subrule
+## matches and set them as the children of a
+## PAST::Op node with a pasttype of 'if'.
+method statement:sym<if>($/) {
+ my $past := PAST::Op.new( $<EXPR>.ast,
+ $<statement>[0].ast,
+ :pasttype('if'),
+ :node( $/ ) );
+ if ( $<statement>[1] ) {
+ $past.push( $<statement>[1].ast );
+ }
+ make $past;
+}
+
+
+## while_statement:
+## This is basically the same as if_statement above, except
+## we use a pasttype of 'while'.
+method statement:sym<while>($/) {
+ make PAST::Op.new( $<EXPR>.ast,
+ $<statement>.ast,
+ :pasttype('while'),
+ :node($/) );
+}
+
+
+## for_statement:
+## A bc(1) for statement has the form
+## for( expr0 ; expr1 ; expr2 ) body;
+## We transform this into an ast structure that looks like
+## expr0; while (expr1) { body; expr2; }
+method statement:sym<for>($/) {
+ my $past := PAST::Stmts.new( :node($/) );
+
+ # add the initial "expr0;" node
+ $past.push( $<EXPR>[0].ast );
+
+ # create the "{ body; expr2; }" part
+ my $body := PAST::Stmts.new( $<statement>.ast, $<EXPR>[2].ast );
+
+ # now create the "while (expr1) { body; expr2; }" part
+ $past.push( PAST::Op.new( $<EXPR>[1].ast, $body, :pasttype('while')));
+
+ make $past;
+}
+
+
+## compound_statement:
+## A compound statement is just a list of statements, so we
+## return the ast of its embedded <statement_list>.
+method statement:sym<compound>($/) {
+ make $<statement_list>.ast;
+}
+
+
+## string:
+## The <string_literal> subrule (inherited from PCT::Grammar)
+## will have set its result object to the string representation
+## of whatever literal we found. So, we just use this as
+## the value of a PAST::Val node.
+method statement:sym<string>($/) {
+ make PAST::Op.new(
+ $<quote_EXPR>.ast,
+ :pirop('print'));
+}
+
+
+
+
+## float/integer:
+## For floating point and integer constants, we simply create
+## a PAST::Val node with the value of the constant. But, because
+## Parrot's Floats don't know how to properly stringify to ints,
+## we have to use the string representation of the value
+## and tell the compiler what type of value to return.
+method term:sym<float>($/) {
+ make PAST::Val.new( :value( ~$/ ), :returns('Float'), :node( $/ ) );
+}
+
+method term:sym<int>($/) {
+ make PAST::Val.new( :value( ~$/ ), :returns('Integer'), :node( $/ ) );
+}
+
+
+## variable:
+## The <variable> rule is used to match both simple
+## variables ("a") and unary function calls ("a(0)").
+## Once again, the $key tells us what sort of match we have.
+##
+## If it's a simple variable, we create a PAST::Var node
+## with the name of the variable and a scope of 'package'.
+## The :viviself('Float') option says that this variable
+## should be initialized as a Float if it doesn't already
+## exist.
+##
+## If it's a function call, we create a PAST::Op node
+## to call the subroutine given by $<name> and passing
+## the value of $<EXPR> as an argument. The
+## available subroutines are held in F<builtins.pir>.
+method term:sym<variable>($/) {
+ if ($<EXPR>) {
+ make PAST::Op.new( $<EXPR>[0].ast,
+ :name( ~$<name> ),
+ :pasttype('call'),
+ :node( $/ )
+ );
+ }
+ else {
+ make PAST::Var.new( :name( ~$<name> ),
+ :scope('package'),
+ :viviself('Float'),
+ :lvalue(1),
+ :node( $/ )
+ );
+ }
+}
+
+method term:sym<circumfix>($/) {
+ make $<EXPR>.ast;
+}
+
+## vim: expandtab sw=4 ft=perl6
Deleted: trunk/examples/languages/abc/src/parser/actions.pm
==============================================================================
--- trunk/examples/languages/abc/src/parser/actions.pm Wed Dec 16 15:12:00 2009 (r43106)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,219 +0,0 @@
-# Copyright (C) 2007, Parrot Foundation.
-# $Id$
-
-=begin overview
-
-abc::Grammar::Actions - ast transformations for abc
-
-This file contains the methods that are used by the parse
-grammar to build the PAST representation of an abc program.
-Each method below corresponds to a rule in F<grammar.pg>,
-and is invoked at the point where C<{*}> appears in the rule,
-with the current match object as the first argument. If the
-line containing C<{*}> also has a C<#= key> comment, then the
-value of the comment is passed as the second argument to the
-method.
-
-Some hopefully helpful hints for reading this file:
-
-It often helps to refer to the rules in F<grammar.pg> when
-looking at the corresponding methods here.
-
-Within a method, C<< $<foo> >> refers to the named capture C<foo>
-within the C< $/ > match object. Normally this is either another
-match object or an array of match objects.
-
-The C<make> function and C< .ast > are used to set and retrieve
-the I<result object> for a match. Here, we use the result object
-to hold the ast representation of any given match. So, in the
-code below, whenever you see an expression like C<< $<foo>.ast >>,
-we're really saying "the ast of C<< <foo> >>".
-
-=end overview
-
-class abc::Grammar::Actions is HLL::Actions;
-
-## The ast of the entire program is the ast of the
-## top-level <statement_list>.
-method TOP($/) {
- make PAST::Block.new(
- :blocktype('declaration'),
- :hll('abc'),
- $<statement_list>.ast);
-}
-
-
-## statement_list:
-## All of the individual statements are held in $<statement>
-## (which is an array). We start by creating an empty
-## PAST::Stmts node, and then loop through all of the
-## statements, adding the ast of each statement to the
-## PAST::Stmts node.
-method statement_list($/) {
- my $past := PAST::Stmts.new( :node($/) );
- for $<statement> {
- $past.push( $_.ast );
- }
- make $past;
-}
-
-
-## statement:
-## In the parse grammar, we've set up $key to tell us the
-## name of whatever subrule was matched by this statement.
-## We can then use $key to quickly get the subrule's ast
-## with $/{$key}.ast .
-##
-## bc(1) expression statements also have special semantics
-## which we handle here. If a statement is an expression
-## other than assignment, then the value of the expression
-## is also assigned to the C<last> variable and the value
-## printed with a newline.
-## Similarly, if the statement consists of a simple string, it's
-## displayed on the output.
-method statement:sym<expr>($/) {
- my $past := $<EXPR>.ast;
- if pir::typeof__sp($past) ne 'PAST::Op' && ~$past.name() ne '&infix:<=>' {
- my $last := PAST::Var.new( :name('last'),
- :scope('package'),
- :lvalue(1) );
- $past := PAST::Op.new( $last,
- $past,
- :pasttype('bind') );
- #PAST::Var.new( :name('saynum'), :namespace([]), :scope('package')),
- $past := PAST::Op.new(
- $past,
- :name('saynum'),
- :pasttype('call') );
- }
- make $past;
-}
-
-
-## if_statement:
-## After parsing an if statement, the conditional
-## expression will be in $<EXPR>, the "then"
-## statement will be in $<statement>[0], and any
-## "else" statement will be in $<statement>[1].
-## So, we just obtain the asts of these subrule
-## matches and set them as the children of a
-## PAST::Op node with a pasttype of 'if'.
-method statement:sym<if>($/) {
- my $past := PAST::Op.new( $<EXPR>.ast,
- $<statement>[0].ast,
- :pasttype('if'),
- :node( $/ ) );
- if ( $<statement>[1] ) {
- $past.push( $<statement>[1].ast );
- }
- make $past;
-}
-
-
-## while_statement:
-## This is basically the same as if_statement above, except
-## we use a pasttype of 'while'.
-method statement:sym<while>($/) {
- make PAST::Op.new( $<EXPR>.ast,
- $<statement>.ast,
- :pasttype('while'),
- :node($/) );
-}
-
-
-## for_statement:
-## A bc(1) for statement has the form
-## for( expr0 ; expr1 ; expr2 ) body;
-## We transform this into an ast structure that looks like
-## expr0; while (expr1) { body; expr2; }
-method statement:sym<for>($/) {
- my $past := PAST::Stmts.new( :node($/) );
-
- # add the initial "expr0;" node
- $past.push( $<EXPR>[0].ast );
-
- # create the "{ body; expr2; }" part
- my $body := PAST::Stmts.new( $<statement>.ast, $<EXPR>[2].ast );
-
- # now create the "while (expr1) { body; expr2; }" part
- $past.push( PAST::Op.new( $<EXPR>[1].ast, $body, :pasttype('while')));
-
- make $past;
-}
-
-
-## compound_statement:
-## A compound statement is just a list of statements, so we
-## return the ast of its embedded <statement_list>.
-method statement:sym<compound>($/) {
- make $<statement_list>.ast;
-}
-
-
-## string:
-## The <string_literal> subrule (inherited from PCT::Grammar)
-## will have set its result object to the string representation
-## of whatever literal we found. So, we just use this as
-## the value of a PAST::Val node.
-method statement:sym<string>($/) {
- make PAST::Op.new(
- $<quote_EXPR>.ast,
- :pirop('print'));
-}
-
-
-
-
-## float/integer:
-## For floating point and integer constants, we simply create
-## a PAST::Val node with the value of the constant. But, because
-## Parrot's Floats don't know how to properly stringify to ints,
-## we have to use the string representation of the value
-## and tell the compiler what type of value to return.
-method term:sym<float>($/) {
- make PAST::Val.new( :value( ~$/ ), :returns('Float'), :node( $/ ) );
-}
-
-method term:sym<int>($/) {
- make PAST::Val.new( :value( ~$/ ), :returns('Integer'), :node( $/ ) );
-}
-
-
-## variable:
-## The <variable> rule is used to match both simple
-## variables ("a") and unary function calls ("a(0)").
-## Once again, the $key tells us what sort of match we have.
-##
-## If it's a simple variable, we create a PAST::Var node
-## with the name of the variable and a scope of 'package'.
-## The :viviself('Float') option says that this variable
-## should be initialized as a Float if it doesn't already
-## exist.
-##
-## If it's a function call, we create a PAST::Op node
-## to call the subroutine given by $<name> and passing
-## the value of $<EXPR> as an argument. The
-## available subroutines are held in F<builtins.pir>.
-method term:sym<variable>($/) {
- if ($<EXPR>) {
- make PAST::Op.new( $<EXPR>[0].ast,
- :name( ~$<name> ),
- :pasttype('call'),
- :node( $/ )
- );
- }
- else {
- make PAST::Var.new( :name( ~$<name> ),
- :scope('package'),
- :viviself('Float'),
- :lvalue(1),
- :node( $/ )
- );
- }
-}
-
-method term:sym<circumfix>($/) {
- make $<EXPR>.ast;
-}
-
-## vim: expandtab sw=4 ft=perl6
Copied: trunk/examples/languages/abc/src/parser/grammar.nqp (from r43091, trunk/examples/languages/abc/src/parser/grammar.pg)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/examples/languages/abc/src/parser/grammar.nqp Wed Dec 16 15:12:00 2009 (r43107, copy of r43091, trunk/examples/languages/abc/src/parser/grammar.pg)
@@ -0,0 +1,133 @@
+grammar abc::Grammar is HLL::Grammar;
+
+=begin overview
+
+The following is the grammar for abc written as a sequence of
+Perl 6 rules. In each of the rules, the special notation {*}
+marks a point in the rule where the corresponding action in
+abc::Grammar::Actions is to be invoked (see grammar-actions.pl).
+These actions are then used to construct the ast nodes for
+the program.
+
+The #= markers at the ends of lines are used to distinguish
+among multiple {*} actions within a rule, by passing the value
+after the marker as a 'key' argument to the action method. Note
+that there must be space between the #= marker and the key.
+
+=end overview
+
+rule TOP {
+ ^ <statement_list>
+ [ $ || <panic: 'Syntax error'> ]
+}
+
+rule statement_list {
+ <statement>? [ ';' <statement>? ]*
+}
+
+proto token statement { <...> }
+ # 'break'
+ # 'continue'
+ # 'halt'
+ # 'return' [ '(' <EXPR> ')' ]?
+token statement:sym<expr> { <EXPR> }
+
+
+token statement:sym<if> {
+ <sym> :s '(' <EXPR> ')' <statement> [ 'else' <statement> ]?
+}
+
+
+token statement:sym<while> {
+ <sym> :s '(' <EXPR> ')' <statement>
+}
+
+
+token statement:sym<for> {
+ <sym> :s '(' <EXPR> ';' <EXPR> ';' <EXPR> ')' <statement>
+}
+
+
+token statement:sym<compound> {
+ :s '{' ~ '}' <statement_list>
+}
+
+
+token statement:sym<string> {
+ <.before \"> <quote_EXPR: ':q'>
+}
+
+
+## recognize terms
+
+proto token term { <...> }
+
+
+token term:sym<float> {
+ [
+ | \d+ '.' \d*
+ | '.' \d+
+ ]
+}
+
+token term:sym<int> { \d+ }
+
+token term:sym<variable> {
+ $<name>=[ <[a..z]> <[_a..z0..9]>* ]
+ [ '(' <EXPR> ')' ]?
+}
+
+token term:sym<circumfix> { '(' <.ws> <EXPR> ')' }
+
+# OPS
+
+## autoincrement
+token postfix:sym<++> { <sym> <O('%unary')> }
+token postfix:sym<--> { <sym> <O('%unary')> }
+token prefix:sym<++> { <sym> <O('%unary')> }
+token prefix:sym<--> { <sym> <O('%unary')> }
+
+## negation
+token prefix:sym<-> { <sym> <O('%unary, :pirop<neg>')> }
+
+## exponentiation
+token infix:sym<^> { <sym> <O('%exponentiation, :pirop<pow NN>')> }
+
+## multiplicative
+token infix:sym<*> { <sym> <O('%multiplicative, :pirop<mul>')> }
+token infix:sym</> { <sym> <O('%multiplicative, :pirop<div>')> }
+token infix:sym<%> { <sym> <O('%multiplicative, :pirop<mod>')> }
+
+## additive
+token infix:sym<+> { <sym> <O('%additive, :pirop<add>')> }
+token infix:sym<-> { <sym> <O('%additive, :pirop<sub>')> }
+
+## assignment
+token infix:sym<=> { <sym> <O('%assignment, :pasttype<bind>')> }
+
+## relational
+token infix:sym<==> { <sym> <O('%relational, :pirop<iseq INn>')> }
+token infix:sym<!=> { <sym> <O('%relational, :pirop<isne INn>')> }
+token infix:sym«<» { <sym> <O('%relational, :pirop<islt INn>')> }
+token infix:sym«<=» { <sym> <O('%relational, :pirop<isle INn>')> }
+token infix:sym«>» { <sym> <O('%relational, :pirop<isgt INn>')> }
+token infix:sym«>=» { <sym> <O('%relational, :pirop<isge INn>')> }
+
+## boolean
+token prefix:sym<!> { <sym> <O('%neg, :pirop<not>')> }
+token infix:sym<&&> { <sym> <O('%and')> }
+token infix:sym<||> { <sym> <O('%or')> }
+
+INIT {
+ NQP::Grammar.O(':prec<y=>, :assoc<unary>', '%unary');
+ NQP::Grammar.O(':prec<w=>, :assoc<left>', '%exponentiation');
+ NQP::Grammar.O(':prec<u=>, :assoc<left>', '%multiplicative');
+ NQP::Grammar.O(':prec<t=>, :assoc<left>', '%additive');
+ NQP::Grammar.O(':prec<m=>, :assoc<right>', '%assignment');
+ NQP::Grammar.O(':prec<n=>, :assoc<non>', '%relational');
+ NQP::Grammar.O(':prec<o=>, :assoc<unary>', '%neg');
+ NQP::Grammar.O(':prec<p=>, :assoc<left>', '%and');
+ NQP::Grammar.O(':prec<q=>, :assoc<left>', '%or');
+}
+
+## vim: expandtab sw=4 ft=perl6
Deleted: trunk/examples/languages/abc/src/parser/grammar.pg
==============================================================================
--- trunk/examples/languages/abc/src/parser/grammar.pg Wed Dec 16 15:12:00 2009 (r43106)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,133 +0,0 @@
-grammar abc::Grammar is HLL::Grammar;
-
-=begin overview
-
-The following is the grammar for abc written as a sequence of
-Perl 6 rules. In each of the rules, the special notation {*}
-marks a point in the rule where the corresponding action in
-abc::Grammar::Actions is to be invoked (see grammar-actions.pl).
-These actions are then used to construct the ast nodes for
-the program.
-
-The #= markers at the ends of lines are used to distinguish
-among multiple {*} actions within a rule, by passing the value
-after the marker as a 'key' argument to the action method. Note
-that there must be space between the #= marker and the key.
-
-=end overview
-
-rule TOP {
- ^ <statement_list>
- [ $ || <panic: 'Syntax error'> ]
-}
-
-rule statement_list {
- <statement>? [ ';' <statement>? ]*
-}
-
-proto token statement { <...> }
- # 'break'
- # 'continue'
- # 'halt'
- # 'return' [ '(' <EXPR> ')' ]?
-token statement:sym<expr> { <EXPR> }
-
-
-token statement:sym<if> {
- <sym> :s '(' <EXPR> ')' <statement> [ 'else' <statement> ]?
-}
-
-
-token statement:sym<while> {
- <sym> :s '(' <EXPR> ')' <statement>
-}
-
-
-token statement:sym<for> {
- <sym> :s '(' <EXPR> ';' <EXPR> ';' <EXPR> ')' <statement>
-}
-
-
-token statement:sym<compound> {
- :s '{' ~ '}' <statement_list>
-}
-
-
-token statement:sym<string> {
- <.before \"> <quote_EXPR: ':q'>
-}
-
-
-## recognize terms
-
-proto token term { <...> }
-
-
-token term:sym<float> {
- [
- | \d+ '.' \d*
- | '.' \d+
- ]
-}
-
-token term:sym<int> { \d+ }
-
-token term:sym<variable> {
- $<name>=[ <[a..z]> <[_a..z0..9]>* ]
- [ '(' <EXPR> ')' ]?
-}
-
-token term:sym<circumfix> { '(' <.ws> <EXPR> ')' }
-
-# OPS
-
-## autoincrement
-token postfix:sym<++> { <sym> <O('%unary')> }
-token postfix:sym<--> { <sym> <O('%unary')> }
-token prefix:sym<++> { <sym> <O('%unary')> }
-token prefix:sym<--> { <sym> <O('%unary')> }
-
-## negation
-token prefix:sym<-> { <sym> <O('%unary, :pirop<neg>')> }
-
-## exponentiation
-token infix:sym<^> { <sym> <O('%exponentiation, :pirop<pow NN>')> }
-
-## multiplicative
-token infix:sym<*> { <sym> <O('%multiplicative, :pirop<mul>')> }
-token infix:sym</> { <sym> <O('%multiplicative, :pirop<div>')> }
-token infix:sym<%> { <sym> <O('%multiplicative, :pirop<mod>')> }
-
-## additive
-token infix:sym<+> { <sym> <O('%additive, :pirop<add>')> }
-token infix:sym<-> { <sym> <O('%additive, :pirop<sub>')> }
-
-## assignment
-token infix:sym<=> { <sym> <O('%assignment, :pasttype<bind>')> }
-
-## relational
-token infix:sym<==> { <sym> <O('%relational, :pirop<iseq INn>')> }
-token infix:sym<!=> { <sym> <O('%relational, :pirop<isne INn>')> }
-token infix:sym«<» { <sym> <O('%relational, :pirop<islt INn>')> }
-token infix:sym«<=» { <sym> <O('%relational, :pirop<isle INn>')> }
-token infix:sym«>» { <sym> <O('%relational, :pirop<isgt INn>')> }
-token infix:sym«>=» { <sym> <O('%relational, :pirop<isge INn>')> }
-
-## boolean
-token prefix:sym<!> { <sym> <O('%neg, :pirop<not>')> }
-token infix:sym<&&> { <sym> <O('%and')> }
-token infix:sym<||> { <sym> <O('%or')> }
-
-INIT {
- NQP::Grammar.O(':prec<y=>, :assoc<unary>', '%unary');
- NQP::Grammar.O(':prec<w=>, :assoc<left>', '%exponentiation');
- NQP::Grammar.O(':prec<u=>, :assoc<left>', '%multiplicative');
- NQP::Grammar.O(':prec<t=>, :assoc<left>', '%additive');
- NQP::Grammar.O(':prec<m=>, :assoc<right>', '%assignment');
- NQP::Grammar.O(':prec<n=>, :assoc<non>', '%relational');
- NQP::Grammar.O(':prec<o=>, :assoc<unary>', '%neg');
- NQP::Grammar.O(':prec<p=>, :assoc<left>', '%and');
- NQP::Grammar.O(':prec<q=>, :assoc<left>', '%or');
-}
-
-## vim: expandtab sw=4 ft=perl6
Modified: trunk/lib/Parrot/Distribution.pm
==============================================================================
--- trunk/lib/Parrot/Distribution.pm Wed Dec 16 14:31:55 2009 (r43106)
+++ trunk/lib/Parrot/Distribution.pm Wed Dec 16 15:12:00 2009 (r43107)
@@ -505,7 +505,6 @@
compilers/nqp/
compilers/ncigen/src/parser/actions.pm
examples/sdl/
- examples/languages/abc/src/parser/actions.pm
examples/languages/squaak/src/parser/actions.pm
lib/Digest/Perl/
lib/File/
More information about the parrot-commits
mailing list