Skip to content

parens, squareBrackets, braces, envelopes, bananas are not actually lazy when parsing an input string #90

@changlinli

Description

@changlinli

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions