1. riffraff
  2. shakespeare-parrot

Commits

gabriele renzi  committed 8aa35a3

library implementation of char declaration

  • Participants
  • Parent commits e05c49b
  • Branches default

Comments (0)

Files changed (11)

File src/builtins/say.pir

View file
     .return ()
 .end
 
+.sub 'declare'
+    .param string char
+    $P0 = new 'Hash'
+    set_global char, $P0
+.end
 
 .sub 'enter'
     .param string char
     print "enter: "
     print char
     print "\n"
+    get_global $P0, char
+    $P0['active'] = 1
     .return ()
 .end
 .sub 'exit'
     print "exit: "
     print char
     print "\n"
+    get_global $P0, char
+    $P0['active'] = 0
     .return ()
 .end
 .sub 'say2'

File src/parser/actions.pm

View file
     :scope('package'),
     :node( $/ ) );
   $past.push($tc);
+  for $<chardef> {
+=begin
+    $past.push(PAST::Var.new(
+      :name($_<character>),
+      :isdecl(1),
+      :scope('package'),
+      :viviself('Hash'),
+      :node($_))
+    ) 
+=cut 
+    $past.push(
+     PAST::Op.new(
+       PAST::Val.new( :value($_<character>),
+         :returns('String'),
+         :node($/)),
+       :name('declare'),
+       :pasttype('call'),
+       :node($/))
+    ) ;
+  }
   for $<scene> {
     $past.push( $( $_ ) );
   }

File src/parser/grammar.pg

View file
 grammar z2::Grammar is PCT::Grammar;
 
 rule TOP {
-    <scene>* {*}
+  <chardef>*
+  <scene>* 
+  {*}
 }
 
 rule scene {
   | <exits> {*}  #= exits
 }
 
+rule chardef {
+  <character> ',' <description> <end>
+  {*}
+}
 rule line {
  <character> ':' [<sentence> <end>]+
   {*}

File t/01.t

View file
+romeo, a cool guy.
+juliet, a pretty girl.
 scene i: foo.
 romeo: plan a pretty king! 
 juliet: proove a horse.

File t/02.t

View file
+romeo, a nice one.
+othello, a lor.
+juliet, someont.
+
 scene i: foo.
 
 [enter romeo and juliet]

File t/03-ops.t

View file
-scene i: foo.
+romeo, a nice one.
+othello, a lor.
+juliet, someont.
+
+        scene i: foo.
 
 [enter romeo and juliet]
 

File t/04-unless.t

View file
+romeo, a nice one.
+othello, a lor.
+juliet, someont.
+
 Scene I : no special characters. 
 [ENTER romeo and juliet]
 othello: plan a pretty pretty king .

File t/05-if.t

View file
+romeo, someont.
+othello, someont.
+juliet, someont.
+
 Scene I : no special characters. 
 [ENTER romeo and juliet]
 

File t/06-assignment.tno

View file
+juliet: smo.
+hamlet: smo.
+ophelia: smo.
+romeo: smo.
                     Scene I: The insulting of Romeo.
 
 [Enter Hamlet and Romeo]

File t/06-enter.t

View file
+hamlet, godoad.
+romeo, mnkn.
+ophelia, csmamalm.
                     Scene I: The insulting of Romeo.
 
 [Enter Hamlet and Romeo]

File t/07-exit.t

View file
+Hamlet, vgofof.
+Romeo,nnlknvsd.
+ophelia,mnknkl.
                     Scene I: The insulting of Romeo.
 
 [Enter Hamlet and Romeo]