Closed safinaskar closed 3 years ago
Yes, should be OK. There's special support to handle many
, without which it would need to be implemented with a recursive rule
.
Thanks. I just checked that hand-written many
will not work (i. e. many2 x = ((:) <$> x <*> many2 x) <|> empty
)
Is it normal to use Alternative's
many
? For example,x1 <- rule $ many x2
? Is it normal to heavily use techniques known from Applicative parsing world, for example, to write something like the following code?The code above is modified version of https://github.com/ollef/Earley/blob/e7de8b77b63e1ee889d98cb6dfc2994178f23e6d/examples/Expr.hs and I hope they are semantically equivalent. I tested my version and it works.
My question is not about performance. It is about semantics. I. e. is code above correct or it works simply by chance?