Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!elroy!cit-vax!ucla-cs!lanai!gast From: gast@lanai.cs.ucla.edu (David Gast) Newsgroups: comp.lang.misc Subject: Re: Block Closure (was Re: FOR loops) Message-ID: <11532@shemp.CS.UCLA.EDU> Date: 22 Apr 88 22:36:43 GMT References: <918@rlgvax.UUCP> <2400015@otter.hple.hp.com> Sender: news@CS.UCLA.EDU Reply-To: gast@lanai.UUCP (David Gast) Organization: UCLA Computer Science Department Lines: 32 In article <2400015@otter.hple.hp.com> esh@otter.hple.hp.com (Sean Hayes) writes: > >>The problem with the idea mentioned in other postings about using indentation >>to represent the control structure is that it does not have a clean formalism >>to describe the parser. Many languages that are in use can be described with >>LR derived parsing specifications and thus the syntax of the language can >>be dealt with formally. I don't think that using whitespace as part of the >>syntax of the language will be easy to parse. Problems include: handling >>of multi line expressions and defining default tab stops. > >Although it is exteremely convenient to be able to specify a language formally, >Surely context free grammars aren't the last word in formal description methods. 1) Declaration before use cannot be represented by context free grammars, but many languages reguire declaration before use. The same could be done with indentation. 2) There are other grammar formalisms besides CFGs. For example, vW or two level grammars. While the typical reader may not want to read a vW grammar, the language could be defined with a vW grammar so that compiler writers could check their compilers. The user could be told about indentation. It might also be possible, to use the Grammar Rule Notation, a la Prolog to describe the indentation levels. I do not know (because I have not really considered it). The GNR is more powerful than a CFG. An extra argument to the grammar rules could indicate the level of indentation. David Gast gast@cs.ucla.edu {ucbvax,rutgers}!ucla-cs!gast