|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)|
|Date:||Tue, 14 Feb 2012 00:25:04 -0000|
|Organization:||A noiseless patient Spider|
|Posted-Date:||13 Feb 2012 19:42:15 EST|
"Geovani de Souza" <firstname.lastname@example.org> wrote
> 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'.
> To ignore '\n' in the white lines.
I've tried a few schemes. One just converts a newline to a semicolon,
*unless* the last symbol was (for example) a comma.
This requires some sort of continuation symbol for when a semicolon would be
And it helps if the grammar is tolerant of extra semicolons, otherwise the
source code could be full of continuation symbols! (After 'then' for
Whatever scheme you choose, you'll know it works well when you have
thousands of lines of code without a single semicolon, and hardly any
continuations. And that is perfectly clear to read.
Return to the
Search the comp.compilers archives again.