peterson-john@cs.yale.edu (John C. Peterson) (01/15/91)
I'm not very familiar with Miranda, but I can speak up for what Haskell does with layout, which is our equivalent of the off-side rule. In Haskell a declaration list is enclosed within curly braces ({ }) and declarations in the list are separated by semicolon (;). The use of these can be avoided by using layout (proper indentation of declarations). Moreover, layout-sensitive and -insentsitive styles of coding can be freely mixed in a Haskell program. Layout is not linear (cannot be recognized by regular expressions), but it is context-free (you can write a push-down automata that recognizes the layout rule). In our Haskell compiler, we implement layout as a step between the lexer and the parser. The lexer and parser are as defined in the Haskell Report; between them is the layout processor which inserts additional delimiters into the token stream. The layout processor has to handle certain tokens differently according to the syntactic category to which they belong; in general, the layout processor must understand the matching of all delimiting pairs of tokens in the language. Haskell treats tab characters correctly. One advantage of this approach is that the fully delimited program can be viewed when layout errors occur. Finding and correcting layout problems is usually trivial. John Peterson Yale Haskell Project peterson-john@cs.yale.edu