Re: requiring balanced parens in a regexp?

haberg@math.su.se (Hans Aberg)
10 Nov 2006 18:38:25 -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: haberg@math.su.se (Hans Aberg)
Newsgroups: comp.compilers
Date: 10 Nov 2006 18:38:25 -0500
Organization: Mathematics
References: 06-11-039
Keywords: lex
Posted-Date: 10 Nov 2006 18:38:25 EST

"Peter Michaux" <petermichaux@gmail.com> wrote:


> In the following string I would like to find the word that comes after
> "test" as long as test is not inside parenthesis. In this example the
> match would be "two".
>
> "the (test one) test two"


In a lexer generator, like Flex, one can use an integer variable that is
increased for each '(' and decreased for each ')'. Then a negative number
implies a parenthesis mismatch, and top level = 0. Useful for example when
implementing nested comments, which normally should not be passed to the
parser.


--
    Hans Aberg


Post a followup to this message

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