Re: language design tradeoffs

bromage@mullauna.cs.mu.OZ.AU (Andrew Bromage)
Thu, 17 Sep 1992 04:29:58 GMT

          From comp.compilers

Related articles
[6 earlier articles]
Re: language design tradeoffs tmb@arolla.idiap.ch (1992-09-14)
Re: language design tradeoffs macrakis@osf.org (1992-09-15)
Re: language design tradeoffs jlg@cochiti.lanl.gov (1992-09-15)
Re: language design tradeoffs anw@maths.nott.ac.uk (1992-09-16)
Re: language design tradeoffs drw@euclid.mit.edu (1992-09-16)
Re: language design tradeoffs rob@guinness.eng.ohio-state.edu (1992-09-17)
Re: language design tradeoffs bromage@mullauna.cs.mu.OZ.AU (1992-09-17)
Re: language design tradeoffs jch@rdg.dec.com (1992-09-17)
Re: language design tradeoffs firth@sei.cmu.edu (1992-09-17)
Re: language design tradeoffs nickh@CS.CMU.EDU (1992-09-17)
Re: language design tradeoffs norvell@csri.toronto.edu (1992-09-17)
Re: language design tradeoffs jlg@cochiti.lanl.gov (1992-09-17)
Re: language design tradeoffs bks@s27w007.pswfs.gov (1992-09-17)
[22 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers,comp.human-factors
From: bromage@mullauna.cs.mu.OZ.AU (Andrew Bromage)
Organization: Computer Science, University of Melbourne, Australia
Date: Thu, 17 Sep 1992 04:29:58 GMT
References: 92-09-048 92-09-082
Keywords: design, comment

macrakis@osf.org (Stavros Macrakis) writes:
>There are other possible conventions, as used in, e.g., Ada:


>1) Use "end X" where X is the name of the opening delimiter, e.g. "end
> loop;", "end record;" etc.


>2) Use "end X" where X is the name of the named unit (e.g. function,
> module, ...).


The problem here is that you end up with an amazingly verbose language
like Pascal, which is a pain to type in.


Someone also mentioned Miranda's use of EOL. I might also mention other
functional languages which use the same idea, and Occam which uses
indenting to show blocks which are to be executed in sequence and
parallel.


My favourite solution comes from BASIC, where the statement terminator :
is an _extension_ to the normal business of using EOL do terminate a
statement. More modern versions of similar ideas can be found in languages
like Turing.


This brings me to the next point, and this is at the risk of starting
a new thread:


How do you allow the omission of the semicolon in languages like this at
the end of a line? It's easy using a predictive parser because the end of
the statement can be predicted. Does anyone have a "best way" of doing
this with an LR parser?


I can think of the most obvious ways:


1. Introduce a new nonterminal which kludges the lexical analyser into
returning a semicolon.


statement : statement_body eos ';' ;
eos : { eoscheck = 1 } ;


yylex () {
if (eoscheck)
{
eoscheck = 0;
if (EOL)
return ';';
}


/* Rest of lex analyser */
}


You get the general idea.


The problem is that this assumes that the lex analyser and syntax analyser
are in the same pass, which may not always be the case. Also, this
prevents the possibility of backtracking in other types of parser.


2. Getting the lexical analyser to return _all_ EOLs and ignore the ones
that aren't needed. As far as I can see, hand modification of the parser
is required here.


Are there any better ways?


Andrew Bromage
[I'd do it all in the lexer -- return an EOL token at the end of the line,
but don't if there's a continuation flag before the EOL. Seems easy enough
to me. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.