Permalink
Browse files

Perlito5 - parser: fix a bug caused by incorrect is_term state

  • Loading branch information...
1 parent 87604df commit dd7a160520ddda2d95b5d022b9cf9aa2294d753b @fglock committed Apr 20, 2012
Showing with 10 additions and 6 deletions.
  1. +4 −5 TODO-perlito5
  2. +1 −0 html/perlito5.js
  3. +2 −1 lib5/Perlito5/Precedence.pm
  4. +3 −0 src5/lib/Perlito5/Precedence.pm
View
@@ -44,11 +44,6 @@ TODO list for Perlito5
the several "end_tables" in Expression.pm are duplicating the function of
$Precedence in Precedence.pm - Expression.pm should use $Precedence directly.
--- bug: ' $step++ < $steps '
- Can't find string terminator '>' anywhere before EOF
- This seems to be because there are 2 different places where "last_is_term" is tracked;
- Precedence.pm is right, Expression.pm is wrong.
-
-- bug: ' $$x [$y] '
parses as ${$x}->[$y];
@@ -96,10 +91,14 @@ TODO list for Perlito5
parses correctly
This seems to be because there is a rule that \w followed by '(' is a function call;
this needs more testing: ' ... and(2) '
+ Test: redefine 'and', 'not' and check what works.
' $s111++ + $s222 '
parses as (+$s222)++
+ ' $step++ < $steps '
+ Can't find string terminator '>' anywhere before EOF
+
* Perl5 backend
View
@@ -3716,6 +3716,7 @@ var p5100 = p5pkg['main'];
((v_token || (v_token = new p5ArrayRef([])))._array_[p5idx((v_token || (v_token = new p5ArrayRef([])))._array_,0)] = 'postfix');
};
p5pkg["Perlito5::Precedence"].unshift([(v_op_stack || (v_op_stack = new p5ArrayRef([])))._array_, [v_token]], null);
+ (v_token_is_term = (1));
})();
}
else {
@@ -321,7 +321,8 @@ sub Perlito5::Precedence::precedence_parse {
if (($token->[0] ne 'postfix_or_term')) {
($token->[0] = 'postfix')
};
- unshift(@{$op_stack}, $token)
+ unshift(@{$op_stack}, $token);
+ ($token_is_term = 1)
}
else {
if ($token_is_term) {
@@ -434,6 +434,9 @@ sub precedence_parse {
$token->[0] = 'postfix';
}
unshift( @$op_stack, $token);
+ # note: from the point of view os the tokenizer, a postfix is a term:
+ # '$step++ < $steps', there is a term before '<'
+ $token_is_term = 1;
}
elsif ($token_is_term) {
if ($last_is_term) {

0 comments on commit dd7a160

Please sign in to comment.