[Haskell-cafe] Re: Proving my point

Achim Schneider barsoap at web.de
Fri May 16 18:17:38 EDT 2008


Philippa Cowderoy <flippa at flippac.org> wrote:

> On Fri, 16 May 2008, Achim Schneider wrote:
> 
> > My problem is that realTopLevel = expr, and that I get into an
> > infinite recursion, never "closing" enough parens, never hitting
> > eof.
> 
> Have you run into the left-recursion trap, by any chance?
> 
> This doesn't work:
> 
> expr = do expr; ...
> 
expr =
    do {e <- parens expr; return $ Nest e}
    <|> lambda
    <|> _let
    <|> try app
    <|> atom

There's at least one token before any recursion, so I guess not. After
all, it terminates. It's my state that does not succeed in directing
the parser not to mess up, so I'm reimplementing the thing as a
two-pass but stateless parser now. Definitely the easier and clearer
thing to do: I can have an end of line token that carries the number of
trailing spaces, so I got perfect indent information without any pain
involved, at all, and don't have to make parsers fail based on state.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 



More information about the Haskell-Cafe mailing list