[svn:parrot] r39919 - in branches/ops_pct/compilers/opsc: . compiler

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Jul 7 11:04:00 UTC 2009


Author: bacek
Date: Tue Jul  7 11:03:59 2009
New Revision: 39919
URL: https://trac.parrot.org/parrot/changeset/39919

Log:
[opsc] Initial version of Actions.

Modified:
   branches/ops_pct/compilers/opsc/compiler/actions.pm
   branches/ops_pct/compilers/opsc/compiler/grammar.pg
   branches/ops_pct/compilers/opsc/opsc.pir

Modified: branches/ops_pct/compilers/opsc/compiler/actions.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/compiler/actions.pm	Tue Jul  7 10:54:34 2009	(r39918)
+++ branches/ops_pct/compilers/opsc/compiler/actions.pm	Tue Jul  7 11:03:59 2009	(r39919)
@@ -0,0 +1,49 @@
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+class Ops::Grammar::Actions;
+
+method TOP($/) {
+    make $<ops>.ast;
+}
+
+method ops($/) {
+    # Brr.. We need something more tasty here.
+    my $past := PAST::Stmts.new(
+        :node($/)
+    );
+
+    for $<op> {
+        $past.push($_.ast);
+    }
+
+    make $past;
+}
+
+method op($/) {
+    my $past := PAST::Block.new(
+        :name(~$<op_name>),
+        :node($/),
+
+        $<op_body>.ast
+    );
+
+    #$past<parameters> := $<op_params>.ast;
+
+    make $past;
+}
+
+method op_body($/) {
+    # Single big chunk
+    make PAST::Op.new(
+        :node($/),
+        :pasttype('inline'),
+        :inline(~$/)
+    );
+}
+
+# Local Variables:
+#   mode: perl6
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Modified: branches/ops_pct/compilers/opsc/compiler/grammar.pg
==============================================================================
--- branches/ops_pct/compilers/opsc/compiler/grammar.pg	Tue Jul  7 10:54:34 2009	(r39918)
+++ branches/ops_pct/compilers/opsc/compiler/grammar.pg	Tue Jul  7 11:03:59 2009	(r39919)
@@ -11,13 +11,14 @@
 }
 
 rule ops {
-    <op>*
+    <op>* {*}
 }
 
 rule op {
-    <op_type> 'op' <op_name=identifier> '(' <op_params>? ')' <op_flag>* 
+    <op_type>? 'op' <op_name=identifier> '(' <op_params>? ')' <op_flag>* 
     ::
     [ <op_body> || <panic: "Fail to parse op body"> ]
+    {*}
 }
 
 token op_type {
@@ -46,7 +47,7 @@
 
 # OpBody starts with '{' and ends with single '}' on line.
 token op_body {
-    '{' <op_body_chunk>* '}'
+    '{' <op_body_chunk>* '}' {*}
 }
 
 token op_body_chunk {

Modified: branches/ops_pct/compilers/opsc/opsc.pir
==============================================================================
--- branches/ops_pct/compilers/opsc/opsc.pir	Tue Jul  7 10:54:34 2009	(r39918)
+++ branches/ops_pct/compilers/opsc/opsc.pir	Tue Jul  7 11:03:59 2009	(r39919)
@@ -16,7 +16,7 @@
     $P0 = new [ 'Ops';'Compiler' ]
     $P0.'language'('Ops')
     $P0.'parsegrammar'('Ops::Grammar')
-    #$P0.'parseactions'('Ops::Grammar::Actions')
+    $P0.'parseactions'('Ops::Grammar::Actions')
 
     #these stages aren't currently used, although generate_files exits before
     #they can be called anyway


More information about the parrot-commits mailing list