Path: utzoo!attcan!uunet!mcsun!ukc!strath-cs!cs.glasgow.ac.uk!kh From: kh@cs.glasgow.ac.uk (Kevin Hammond) Newsgroups: comp.lang.functional Subject: Re: "Off-side rule" Message-ID: <7534@vanuata.cs.glasgow.ac.uk> Date: 24 Jan 91 15:53:50 GMT References: <22307@rouge.usl.edu> <1991Jan10.111559.12440@odin.diku.dk> <293@smds.UUCP> <7415@vanuata.cs.glasgow.ac.uk> <2676@wn1.sci.kun.nl> Reply-To: kh@cs.glasgow.ac.uk (Kevin Hammond) Organization: Comp Sci, Glasgow Univ, Scotland Lines: 24 In article <2676@wn1.sci.kun.nl> eerke@cs.kun.nl (Eerke Boiten) writes: >In article dtarditi@CS.CMU.EDU (David Tarditi) writes: >>A significant argument against the off-side rule is that it makes >>languages difficult to parse. The modern approach to parsing is to define >>the concrete syntax of a language using BNF and regular expressions. >>The BNF for the language should be defined so that the language can >>parsed using an LALR(1) parser. [..] > >This is only important for *prototyping* implementations of functional >languages in environments where no other parser generators than YACC are >available. Anyone who implemented a functional language, care to comment? For what it's worth, the Haskell off-side rule requires very few modifications to a yacc parser (one extra rule, I think). This assumes that the lexer is counting spaces. The lexer is rather more complicated, but can still be written using lex/C without too much trouble. The only real problems are keeping track of space in strings (which may extend across lines in Haskell) and remembering to adjust the space count when backtracking. Kevin -- This Signature Intentionally Left Blank. E-mail: kh@cs.glasgow.ac.uk