Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.lightlink.com!usenet.osg.ufl.edu!usenet.stanford.edu!news.iecc.com!nerds-end From: Joshua Cranmer Newsgroups: comp.compilers Subject: Re: Ignore break line sometimes Date: Sun, 12 Feb 2012 12:03:13 -0600 Organization: Compilers Central Lines: 24 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <12-02-017@comp.compilers> References: <12-02-010@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1329081308 18613 64.57.183.58 (12 Feb 2012 21:15:08 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sun, 12 Feb 2012 21:15:08 +0000 (UTC) Keywords: parse Posted-Date: 12 Feb 2012 16:15:08 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:457 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. 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