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
All the derived specializations of bracket aren't actually lazy in their argument when the generated parser is finally applied to some string. This prevents me from writing mutually recursive parsers that make use of any of these specializations of bracket as they will promptly enter an infinite loop when asked to parse any string.
import atto._
import Atto._
def dummyParser: Parser[Char] = {println("activate!"); char('a')}
// Prints activate!
parens(dummyParser).parseOnly("notparentheses")
def myParens[A](p: => Parser[A]): Parser[A] =
bracket(char('('), p, char(')')) // Notice the absence of named
// Does not print anything
myParens(dummyParser).parseOnly("notparentheses")
The text was updated successfully, but these errors were encountered:
changlinli
changed the title
parens, squareBrackets, braces, envelopes, bananas are not actually lazyparens, squareBrackets, braces, envelopes, bananas are not actually lazy when parsing an input string
Sep 20, 2018
FWIW I'm pretty sure the evaluation here is "accidental" in the sense that what's being forced is ultimately the toString method rather than the parsing itself.
All the derived specializations of
bracket
aren't actually lazy in their argument when the generated parser is finally applied to some string. This prevents me from writing mutually recursive parsers that make use of any of these specializations ofbracket
as they will promptly enter an infinite loop when asked to parse any string.The text was updated successfully, but these errors were encountered: