Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #455
| From | "Karsten Nyblad" <uu3kw29sb7@snkmail.com> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | RE: Ignore break line sometimes |
| Date | 2012-02-12 09:21 +0100 |
| Organization | Compilers Central |
| Message-ID | <12-02-015@comp.compilers> (permalink) |
| References | <12-02-010@comp.compilers> |
> 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] One option is to write a recursive descendent parser, and have two ways of calling the lexer: One that return line ends and one that does not. An other option is to base your parsing on a parser generator like bison, and modify the code that drives the automaton. That code is modified such that when the lexer returns a line feed token, you copy the stack of states, and on the copy you simulate the actions that the parser would have taken. When the simulation stacks the line feed, you throw away the copy and resume parsing on the real stack with the line feed in the window. When the simulation encounters an error, you throw away the simulation AND the line feed and call the lexer again. If you chose the second option, it is important that you chose the right parser generator, because some parser generators already generate code that can help you. Many LR parser generators, e.g., bison, include facilities for generalised LR parsing, and many LL parser generators include facilities for backtracking. That might help you. Karsten Nyblad
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
Ignore break line sometimes Geovani de Souza <geovanisouza92@gmail.com> - 2012-02-11 06:56 -0800
Re: Ignore break line sometimes Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2012-02-11 17:28 +0100
Re: Ignore break line sometimes George Neuner <gneuner2@comcast.net> - 2012-02-11 12:59 -0500
RE: Ignore break line sometimes "Karsten Nyblad" <uu3kw29sb7@snkmail.com> - 2012-02-12 09:21 +0100
Re: Ignore break line sometimes Kaz Kylheku <kaz@kylheku.com> - 2012-02-13 00:16 +0000
Re: Ignore break line sometimes Stefan Monnier <monnier@iro.umontreal.ca> - 2012-02-12 10:48 -0500
Re: Ignore break line sometimes Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-02-12 12:03 -0600
Re: Ignore break line sometimes Gene Wirchenko <genew@ocis.net> - 2012-02-19 20:57 -0800
Re: Ignore break line sometimes glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-02-20 08:09 +0000
Re: Ignore break line sometimes arnold@skeeve.com (Aharon Robbins) - 2012-02-23 21:51 +0000
Re: Ignore break line sometimes "Jonathan Thornburg" <jthorn@astro.indiana.edu> - 2012-02-27 03:49 +0000
Re: Ignore break line sometimes "BartC" <bc@freeuk.com> - 2012-02-14 00:25 +0000
csiph-web