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
{{ message }}
This repository was archived by the owner on Feb 23, 2018. It is now read-only.
closes #3446 and improves parsing speed by encoding lazy arguments using CBN args and lazy vals.
should avoid needlessly recomputing parsers
review by plocinic (so you can include a version that uses the direct support for lazy args in your branch)
git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@24422 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
// TODO: better error handling (labelling like parsec's <?>)
17
18
@@ -204,8 +205,10 @@ trait Parsers {
204
205
205
206
// no filter yet, dealing with zero is tricky!
206
207
207
-
defappend[U>:T](p: =>Parser[U]):Parser[U]
208
-
=Parser{ in =>this(in) append p(in)}
208
+
@migration(2, 9, "As of 2.9, the call-by-name argument is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.")
@migration(2, 9, "As of 2.9, the call-by-name argument is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.")
@migration(2, 9, "As of 2.9, the call-by-name argument is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.")
@migration(2, 9, "As of 2.9, the call-by-name argument is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.")
@migration(2, 9, "As of 2.9, the call-by-name argument is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.")
/** A parser combinator that changes a successful result into the specified value.
334
+
*
335
+
* <p>`p ^^^ v' succeeds if `p' succeeds; discards its result, and returns `v` instead.</p>
336
+
* @paramv The new result for the parser, evaluated at most once (if `p` succeeds), not evaluated at all if `p` fails.
337
+
* @return a parser that has the same behaviour as the current parser, but whose successful result is `v`
338
+
*/
339
+
@migration(2, 9, "As of 2.9, the call-by-name argument is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.")
/** A parser combinator for partial function application
322
346
*
@@ -556,11 +580,13 @@ trait Parsers {
556
580
* (the result is a `List' of the consecutive results of `f' and `p')</p>
557
581
*
558
582
* @paramfirst a `Parser' that parses the first piece of input
559
-
* @paramp a `Parser' that is to be applied successively to the rest of the input (if any)
583
+
* @paramp0 a `Parser' that is to be applied successively to the rest of the input (if any) -- evaluated at most once, and only when necessary
560
584
* @return A parser that returns a list of results produced by first applying `f' and then
561
585
* repeatedly `p' to the input (it only succeeds if `f' matches).
562
586
*/
563
-
defrep1[T](first: =>Parser[T], p: =>Parser[T]):Parser[List[T]] =Parser { in =>
587
+
@migration(2, 9, "As of 2.9, the p0 call-by-name arguments is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.")
588
+
defrep1[T](first: =>Parser[T], p0: =>Parser[T]):Parser[List[T]] =Parser { in =>
0 commit comments