Question about Haskell lexer and parser.

Hello haskell-cafe, Question is really about layout rules. If the first lexeme of a module is not a "module" keyword, we insert {n}, where n is the indentation of first lexeme. Then we apply function L to the list of lexemes and stack of layouts: L ({n}:lexemes) [] One of first case definitions of L covers this situation: L ({n}:ts) [] | n>0 = {:L ts [n] -- n>0 means that layout isn't explicit. It's obvious that after our first {n} comes usual lexeme, like Var. This situaiton is covered in the following L rule: L (t:ts) (m:ms) | m /= 0 = }:L (t:ts) ms -- Haskell Report says that we here -- should recognize parsing errors -- but how we can do that in lexer? So we finally get {:}:...lexemes... Is it right? I think this situation is wrong. -------------------------- What I do. I just try to entertain and educate myself trying to implement Haskell interpreter or compiler (what will come first). My approach is to get highly modular and declarative structure of a system (current Haskell lexer uses monads, which I found unsatisfable). -- Best regards, Serguey mailto:sz@uc.ru
participants (1)
-
Serguey Zefirov