Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Work on Sixish

  • Loading branch information...
commit c10661fa3445c5f378ea0905cef27badcffdfe25 1 parent bdf2ebd
- authored
3  target/Own_Rules.pm
@@ -32,7 +32,8 @@ $rules = [
32 32 'rhs' => [
33 33 '<concatenation>'
34 34 ],
35   - 'lhs' => '<rhs>'
  35 + 'lhs' => '<rhs>',
  36 + 'action' => 'do_arg0'
36 37 },
37 38 {
38 39 'rhs' => [],
29 target/do_sixish.pm
@@ -151,7 +151,7 @@ sub Marpa::R2::Sixish::Action::do_arg0 {
151 151 }
152 152
153 153 sub Marpa::R2::Sixish::Action::do_arg1 {
154   - return $_[1];
  154 + return $_[2];
155 155 }
156 156
157 157 sub Marpa::R2::Sixish::Action::do_undef {
@@ -177,10 +177,17 @@ sub Marpa::R2::Sixish::Action::do_self {
177 177 }
178 178
179 179 sub Marpa::R2::Sixish::Action::do_short_rule {
180   - shift;
  180 + my ($eval_object, $rhs) = @_;
  181 + my $lhs = '<TOP><6>';
  182 + for my $self_occurrence (@{$eval_object->{self_occurrences}}) {
  183 + my ($rule, $ix) = @{$self_occurrence};
  184 + my $rhs = $rule->{rhs};
  185 + $rhs->[$ix] = $lhs;
  186 + }
  187 + $eval_object->{self_occurrences} = [];
181 188 return {
182   - lhs => '<TOP><6>',
183   - rhs => [ $_[0] ],
  189 + lhs => $lhs,
  190 + rhs => $rhs
184 191 };
185 192 } ## end sub do_short_rule
186 193
@@ -189,6 +196,7 @@ sub Marpa::R2::Sixish::Action::do_quantification {
189 196 my ( $object_var, $atom, undef, $quantifier ) = @_;
190 197 my $symbol_hash = $object_var->{symbol_hash};
191 198 my $rules = $object_var->{rules};
  199 + my $self_occurrences = $object_var->{self_occurrences};
192 200 my $i = 0;
193 201 my $quantified_lhs;
194 202 GEN_SYMBOL_NAME: while (1) {
@@ -202,14 +210,14 @@ sub Marpa::R2::Sixish::Action::do_quantification {
202 210 }
203 211 $i++;
204 212 } ## end GEN_SYMBOL_NAME: while (1)
205   - push @{$rules},
206   - [
  213 + my $side_effect_rule =
207 214 { lhs => $quantified_lhs,
208 215 min => 0,
209 216 rhs => $atom
210   - }
211   - ];
212   - return [$quantified_lhs];
  217 + } ;
  218 + push @{$self_occurrences}, [$side_effect_rule, 0];
  219 + push @{$rules}, $side_effect_rule;
  220 + return $quantified_lhs;
213 221 } ## end sub Marpa::R2::Sixish::Action::do_quantifier
214 222
215 223 sub sixish_child_new {
@@ -277,7 +285,8 @@ sub sixish_child_new {
277 285
278 286 my @stack = ();
279 287 my $actions = [];
280   - my $evaluation_object = { rules => [] };
  288 + my $evaluation_object =
  289 + { rules => [], symbol_hash => {}, self_occurrences => [] };
281 290 {
282 291 # Where to do this? Once actions are finally known, but where
283 292 # is that?
2  target/write_sixish_rules.pl
@@ -12,7 +12,7 @@
12 12 <first rule> ::= <short rule> :action<do_array>
13 13 <more rules> ::= :action<do_empty_array>
14 14 <short rule> ::= <rhs> :action<do_short_rule>
15   - <rhs> ::= <concatenation>
  15 + <rhs> ::= <concatenation> :action<do_arg0>
16 16 <concatenation> ::=
17 17 <concatenation> ::= <concatenation> <opt ws> <quantified atom> :action<do_concatenation>
18 18 <opt ws> ::= :action<do_undef>

0 comments on commit c10661f

Please sign in to comment.
Something went wrong with that request. Please try again.