You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in scala.util.parsing.combinator.Parsers never returns error. So if first or p parser returns error this error is not propagated further.
It is almost obvious from code of this method:
defrep1[T](first: =>Parser[T], p: =>Parser[T]):Parser[List[T]] =Parser{ in0 =>valxs=new scala.collection.mutable.ListBuffer[T]
varin= in0
varres= first(in)
while(res.successful) {
xs += res.get
in = res.next
res = p(in)
}
// assert(res.isInstanceOf[NoSuccess])if (!xs.isEmpty) {
// the next parser should start parsing where p failed, // since `!p(in).successful', the next input to be consumed is `in'Success(xs.toList, in) // TODO: I don't think in == res.next holds
}
else {
Failure(res.asInstanceOf[NoSuccess].msg, in0)
}
}
Suppose that after while finished res is an Error. This error is not propagated further - the result of rep1 depends only on emptiness of list xs!
res should be tested. The implementation of this method should be changed to something like this:
defrep1[T](first: =>Parser[T], p: =>Parser[T]):Parser[List[T]] =Parser{ in0 =>valxs=new scala.collection.mutable.ListBuffer[T]
varin= in0
varres= first(in)
while(res.successful) {
xs += res.get
in = res.next
res = p(in)
}
res match {
casee: Error=> e
case _ =>if (!xs.isEmpty) Success(xs.toList, in) elseFailure(res.asInstanceOf[NoSuccess].msg, in0)
}
}
As a result of incorrect rep1, combinators * and + work also incorrectly (they finally call mentioned method).
The text was updated successfully, but these errors were encountered:
@adriaanm said:
ouch! sorry... fixed in r15555 (btw: how can I change the status of the ticket from the commit message? I thought "fixed SI-1100" would do the trick...
Parser generator
in scala.util.parsing.combinator.Parsers never returns error. So if first or p parser returns error this error is not propagated further.
It is almost obvious from code of this method:
Suppose that after while finished res is an Error. This error is not propagated further - the result of rep1 depends only on emptiness of list xs!
res should be tested. The implementation of this method should be changed to something like this:
As a result of incorrect rep1, combinators * and + work also incorrectly (they finally call mentioned method).
The text was updated successfully, but these errors were encountered: