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
Copy file name to clipboardExpand all lines: src/main/scala/scala/util/parsing/combinator/Parsers.scala
+30
Original file line number
Diff line number
Diff line change
@@ -314,6 +314,36 @@ trait Parsers {
314
314
def~! [U](p: =>Parser[U]):Parser[~[T, U]]
315
315
=OnceParser{ (for(a <-this; b <- commit(p)) yieldnew~(a,b)).named("~!") }
316
316
317
+
318
+
/** A parser combinator for non-back-tracking sequential composition which only keeps the right result.
319
+
*
320
+
* `p ~>! q` succeeds if `p` succeds and `q` succeds on the input left over by `p`.
321
+
* In case of failure, no back-tracking is performed (in an earlier parser produced by the `|` combinator).
322
+
*
323
+
* @paramq a parser that will be executed after `p` (this parser) succeeds -- evaluated at most once, and only when necessary
324
+
* @return a `Parser` that -- on success -- reutrns the result of `q`.
325
+
* The resulting parser fails if either `p` or `q` fails, this failure is fatal.
326
+
*/
327
+
@migration("The call-by-name argument is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.", "2.9.0")
OnceParser { (for(a <-this; b <- commit(p)) yield b).named("~>!") }
330
+
}
331
+
332
+
/** A parser combinator for non-back-tracking sequential composition which only keeps the left result.
333
+
*
334
+
* `p <~! q` succeeds if `p` succeds and `q` succeds on the input left over by `p`.
335
+
* In case of failure, no back-tracking is performed (in an earlier parser produced by the `|` combinator).
336
+
*
337
+
* @paramq a parser that will be executed after `p` (this parser) succeeds -- evaluated at most once, and only when necessary
338
+
* @return a `Parser` that -- on success -- reutrns the result of `p`.
339
+
* The resulting parser fails if either `p` or `q` fails, this failure is fatal.
340
+
*/
341
+
@migration("The call-by-name argument is evaluated at most once per constructed Parser object, instead of on every need that arises during parsing.", "2.9.0")
0 commit comments