|Ignore break line sometimes email@example.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 firstname.lastname@example.org (George Neuner) (2012-02-11)|
|Re: Ignore break line sometimes email@example.com (Stefan Monnier) (2012-02-12)|
|Re: Ignore break line sometimes Pidgeot18@verizon.invalid (Joshua Cranmer) (2012-02-12)|
|Re: Ignore break line sometimes firstname.lastname@example.org (Kaz Kylheku) (2012-02-13)|
|Re: Ignore break line sometimes email@example.com (BartC) (2012-02-14)|
|Re: Ignore break line sometimes firstname.lastname@example.org (Gene Wirchenko) (2012-02-19)|
|Re: Ignore break line sometimes email@example.com (glen herrmannsfeldt) (2012-02-20)|
|Re: Ignore break line sometimes firstname.lastname@example.org (2012-02-23)|
|Re: Ignore break line sometimes email@example.com (Jonathan Thornburg) (2012-02-27)|
|From:||Joshua Cranmer <Pidgeot18@verizon.invalid>|
|Date:||Sun, 12 Feb 2012 12:03:13 -0600|
|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
<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
Return to the
Search the comp.compilers archives again.