Anonymous avatar Anonymous committed a5b154f

comparisons improved

Comments (0)

Files changed (5)

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.
 

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]
 
+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.
 

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(

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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.