riffraff / shakespeare-parrot

A Parrot based interpreter for the Shakespeare programming language

commit 76: 027d2fa8c216
parent 75: 9a0e643b17ab
branch: default
merge comparisons
riffraff
14 months ago

Changed (Δ101 bytes):

raw changeset »

src/parser/actions.pm (2 lines added, 8 lines removed)

src/parser/grammar.pg (4 lines added, 4 lines removed)

Up to file-list src/parser/actions.pm:

@@ -92,14 +92,8 @@ method value($/, $key) {
92
92
  make $( $/{$key} );
93
93
}
94
94
95
method question($/, $k) {
96
  my $res;
97
  if $k eq 'eq' {
98
    $res := mkcall0( 'equal' );
99
  }
100
  else {
101
    $res := $($<comparison>);
102
  }
95
method question($/) {
96
  my  $res := $($<comparison>);
103
97
  for $<value> {
104
98
    $res.push( $( $_ ));
105
99
  }

Up to file-list src/parser/grammar.pg:

@@ -88,17 +88,17 @@ rule branch {
88
88
}
89
89
90
90
rule question {
91
  | <be> <value> <comparison> 'than' <value>{*} #= diseq
92
  | <be> <value> 'as' <adjective> 'as' <value>{*} #= eq
91
  <be> <value> <comparison> <value>{*}
93
92
}
94
93
95
94
rule comparison {
96
95
  | ['more' <negative_adjective> 
97
96
    |'less' <positive_adjective>
98
    |<negative_comparative>] {*} #= worse
97
    |<negative_comparative>] 'than' {*} #= worse
99
98
  | ['more' <positive_adjective>
100
99
    |'less' <negative_adjective> 
101
    |<positive_comparative>] {*} #= better
100
    |<positive_comparative>] 'than' {*} #= better
101
  | 'as' <adjective> 'as' {*} #= equal
102
102
}
103
103
rule test {
104
104
  | 'if so,' <sentence>  {*} #= if