Re: requiring balanced parens in a regexp?

Alex Colvin <alexc@TheWorld.com>
10 Nov 2006 18:38:36 -0500

          From comp.compilers

Related articles
requiring balanced parens in a regexp? petermichaux@gmail.com (Peter Michaux) (2006-11-10)
Re: requiring balanced parens in a regexp? petermichaux@gmail.com (Peter Michaux) (2006-11-10)
Re: requiring balanced parens in a regexp? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-11-10)
Re: requiring balanced parens in a regexp? martin@gkc.org.uk (Martin Ward) (2006-11-10)
Re: requiring balanced parens in a regexp? haberg@math.su.se (2006-11-10)
Re: requiring balanced parens in a regexp? alexc@TheWorld.com (Alex Colvin) (2006-11-10)
Re: requiring balanced parens in a regexp? cfc@shell01.TheWorld.com (Chris F Clark) (2006-11-10)
| List of all articles for this month |

From: Alex Colvin <alexc@TheWorld.com>
Newsgroups: comp.compilers
Date: 10 Nov 2006 18:38:36 -0500
Organization: The World : www.TheWorld.com : Since 1989
References: 06-11-039 06-11-040
Keywords: lex
Posted-Date: 10 Nov 2006 18:38:36 EST

>Thanks for the info. My problem is even bigger as there might be mixed
>quotes with various balance in relation to the parens.


>I think that I will need to write a real tokenizer and parser to get my
>job done properly. I haven't done that before and it is something I
>have always wanted to do but it seems like a *big* task.


You may not really need a tokenizer and parser, but you probably do need
a stack. How about keeping a stack of things that must be matched
(paremtheses, quotes, ...) to get you back to the part you need to test.
Just chew up input characters, pushing and popping this stack as
necessary, and doing your test where it's empty.




--
mac the naf



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.