I know the difference between def
and val
and lazy val
in general, but I'm not sure about their repercussions when it comes to Parser Combinators. All examples I have seen contain code like this:
def statement: Parser[Statement] =
ifStatement |
whileStatement |
expressionStatement | ...
From a few experiments I have done, it seems val
and lazy val
work as well, but I'm not sure if there are cases where they wouldn't work anymore, like recursion or positioned parsers or whatnot.
Please enlighten me!