Re: Ignore break line sometimes

Joshua Cranmer <Pidgeot18@verizon.invalid>
Sun, 12 Feb 2012 12:03:13 -0600

          From comp.compilers

Related articles
Ignore break line sometimes geovanisouza92@gmail.com (Geovani de Souza) (2012-02-11)
Re: Ignore break line sometimes DrDiettrich1@aol.com (Hans-Peter Diettrich) (2012-02-11)
Re: Ignore break line sometimes gneuner2@comcast.net (George Neuner) (2012-02-11)
Re: Ignore break line sometimes monnier@iro.umontreal.ca (Stefan Monnier) (2012-02-12)
Re: Ignore break line sometimes Pidgeot18@verizon.invalid (Joshua Cranmer) (2012-02-12)
Re: Ignore break line sometimes kaz@kylheku.com (Kaz Kylheku) (2012-02-13)
Re: Ignore break line sometimes bc@freeuk.com (BartC) (2012-02-14)
Re: Ignore break line sometimes genew@ocis.net (Gene Wirchenko) (2012-02-19)
Re: Ignore break line sometimes gah@ugcs.caltech.edu (glen herrmannsfeldt) (2012-02-20)
Re: Ignore break line sometimes arnold@skeeve.com (2012-02-23)
Re: Ignore break line sometimes jthorn@astro.indiana.edu (Jonathan Thornburg) (2012-02-27)
| List of all articles for this month |
From: Joshua Cranmer <Pidgeot18@verizon.invalid>
Newsgroups: comp.compilers
Date: Sun, 12 Feb 2012 12:03:13 -0600
Organization: Compilers Central
References: 12-02-010
Keywords: parse
Posted-Date: 12 Feb 2012 16:15:08 EST

On 2/11/2012 8:56 AM, Geovani de Souza wrote:
> Hi all!
>
> I'm trying write an parser to my compiler, and I'm interessed to
> ignore the break line (\n) sometimes. E.g:
>
> if true then [\n] foo(); [\n] end; [\n]
>
> So, in the first line, the '\n' after 'then' isn't important, but in
> the second "foo();" could replace the need of the semicolon to
> conclude the statement, or still, in the 'end'.


It sounds like you want something like ECMAScript's magic
you-don't-always-need-a-semicolon feature.
<http://bclary.com/2004/11/07/#a-7.9> describes how it works in detail.
The thrust of it is that "if you see an invalid token, but you saw a
newline before, automatically insert a semicolon to fix things."


There are more than a few people who believe that this feature should
not have been implemented.


--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth


Post a followup to this message

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