Commits

gabriele renzi  committed a5b154f

comparisons improved

  • Participants
  • Parent commits bbc309c

Comments (0)

Files changed (5)

File example/fibonacci2.spl

 Macbeth, a poor insulted lady making but a small appearance.
 
 
+                    Act I: The search for Fibonacci.
 
                     Scene I: The taunting of Macbeth.
 
 Romeo:
  Speak your mind!
 
-[Exeunt ophelia and romeo]
+[Exeunt]
 
                     Scene IV: Juliet has second thoughts.
 

File example/hello.spl

 Hamlet, the flatterer of Andersen Insulting A/S.
 
 
+                    Act I: Hamlet's insults and flattery.
 
                     Scene I: The insulting of Romeo.
 
  hero and thyself! Speak your mind!
 
  You are as brave as the sum of your fat little stuffed misused dusty
- old rotten codpiece and a beautiful fair warm peaceful sunny summer day. 
-  You are as healthy as the difference between the sum of the
+ old rotten codpiece and a beautiful fair warm peaceful sunny summer's
+ day. You are as healthy as the difference between the sum of the
  sweetest reddest rose and my father and yourself! Speak your mind!
 
  You are as cowardly as the sum of yourself and the difference
 [Exeunt Ophelia and Hamlet]
 
 
+                    Act II: Behind Hamlet's back.
 
-                    Scene IV: Romeo and Juliet's conversation.
+                    Scene I: Romeo and Juliet's conversation.
 
 [Enter Romeo and Juliet]
 
 
 [Exit Romeo]
 
-                    Scene V: Juliet and Ophelia's conversation.
+                    Scene II: Juliet and Ophelia's conversation.
 
 [Enter Ophelia]
 

File example/sum2.spl

+Calculations of the sum of two numbers.
 
 Romeo, A character to store the sum.
 Juliet, An admirer who helps to calculate the sum.
 
+  Act I: a summing pair.
 
   Scene I: Juliet's conversation with Romeo.
 

File src/parser/actions.pm

   make $( $/{$key} );
 }
 
-method question($/, $key) {
-  my $res := mkcall0( $key );
+method question($/, $k) {
+  my $res;
+  if $k eq 'eq' {
+    $res := mkcall0( 'equal' );
+  }
+  else {
+    $res := $($<comparison>);
+  }
   for $<value> {
     $res.push( $( $_ ));
   }
   make $res;
 }
 
+method comparison($/,$k) {
+    make mkcall0( $k );
+}
+
 method reference($/, $k) {
   if $k eq 'named_ref' {
   make mkcall( PAST::Val.new(

File src/parser/grammar.pg

 }
 
 rule question {
-  | <be> <value> <positive_comparative> 'than' <value>{*} #= better
-  | <be> <value> <negative_comparative> 'than' <value>{*} #= worse
-  | 'is' <value> 'as' <adjective> 'as' <value>{*} #= equal
+  | <be> <value> <comparison> 'than' <value>{*} #= diseq
+  | <be> <value> 'as' <adjective> 'as' <value>{*} #= eq
+}
+
+rule comparison {
+  | 'more' <negative_adjective> {*} #= worse
+  | 'less' <negative_adjective> {*} #= better
+  | 'more' <positive_adjective> {*} #= better
+  | 'less' <positive_adjective> {*} #= worse
+  | <positive_comparative> {*} #= better
+  | <negative_comparative> {*} #= worse
 }
 rule test {
   | 'if so,' <branch>  {*} #= if