|Ignore break line sometimes firstname.lastname@example.org (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 email@example.com (George Neuner) (2012-02-11)|
|Re: Ignore break line sometimes firstname.lastname@example.org (Stefan Monnier) (2012-02-12)|
|Re: Ignore break line sometimes Pidgeot18@verizon.invalid (Joshua Cranmer) (2012-02-12)|
|Re: Ignore break line sometimes email@example.com (Kaz Kylheku) (2012-02-13)|
|Re: Ignore break line sometimes firstname.lastname@example.org (BartC) (2012-02-14)|
|Re: Ignore break line sometimes email@example.com (Gene Wirchenko) (2012-02-19)|
|Re: Ignore break line sometimes firstname.lastname@example.org (glen herrmannsfeldt) (2012-02-20)|
|[2 later articles]|
|From:||George Neuner <email@example.com>|
|Date:||Sat, 11 Feb 2012 12:59:57 -0500|
|Organization:||A noiseless patient Spider|
|Posted-Date:||12 Feb 2012 01:16:43 EST|
On Sat, 11 Feb 2012 06:56:17 -0800 (PST), Geovani de Souza
>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]
>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'.
>Too ignore '\n' in the white lines.
>How can I do this?
IMO making the newlines significant is a really bad idea ... but
leaving that aside I believe the most effective way would be to have
your lexer return a special "end-of-line" code for either semicolon or
newline and make the end-of-line code optional where it need not be.
You don't say whether your parser is handwritten or tool generated (or
which tools) ... so I can't really give an example.
Return to the
Search the comp.compilers archives again.