Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!nerds-end From: George Neuner Newsgroups: comp.compilers Subject: Re: Ignore break line sometimes Date: Sat, 11 Feb 2012 12:59:57 -0500 Organization: A noiseless patient Spider Lines: 28 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <12-02-012@comp.compilers> References: <12-02-010@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1329027403 64101 64.57.183.58 (12 Feb 2012 06:16:43 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sun, 12 Feb 2012 06:16:43 +0000 (UTC) Keywords: parse, design Posted-Date: 12 Feb 2012 01:16:43 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: x330-a1.tempe.blueboxinc.net comp.compilers:452 On Sat, 11 Feb 2012 06:56:17 -0800 (PST), Geovani de Souza 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'. > >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. George