Re: lex question

"toby" <toby@telegraphics.com.au>
8 Dec 2005 22:09:27 -0500

          From comp.compilers

Related articles
lex question dormina@winnipeg-lnx.cc.gatech.edu (Mina Doroudi) (2005-12-02)
Re: lex question nathan.moore@cox.net (Nathan Moore) (2005-12-08)
Re: lex question toby@telegraphics.com.au (toby) (2005-12-08)
lex question alinares@fivetech.com (Antonio Linares) (1999-03-23)
Re: lex question adobni@itron.com.ar (Alejandro Dobniewski) (1999-03-28)
Re: lex question rkrayhawk@aol.com (1999-04-01)
Re: lex question cfc@world.std.com (Chris F Clark) (1999-04-03)
| List of all articles for this month |
From: "toby" <toby@telegraphics.com.au>
Newsgroups: comp.compilers
Date: 8 Dec 2005 22:09:27 -0500
Organization: http://groups.google.com
References: 05-12-008
Keywords: lex, comment
Posted-Date: 08 Dec 2005 22:09:27 EST

Mina Doroudi wrote:
> I am writing a parser with lex. I have some problems:
> In the definition section I define a whole bunch of stuff and I also
> used them to define other things.
> So I have
> X [something]
> and I want Y to be anything but X so when I define it like:
> Y [^{X}] it only exclude the characters '{' , '}' ,and X
> I can't find a way to exclude the definitions and use them in
> other definitions.


You're right, the obvious way doesn't work:
[{X}] actionX();
[^{X}] actionNotX();


As Nathan says, the solution is straightforward if you have only two
tokens - X and not-X. If that's not your problem, then I think more
context is required for me (at least) to help.


> Also I'm trying to set rules for Oct, but lex doesn't let me logical ORs them
> together. and I can't do ranging either ([\001-\006])


As Nathan implies, the following patterns all work with flex (I
checked):
[\1-\6] action();
[\1\2\3] action();
"\1"|"\2"|"\3" action();


> any Idea how to parse text with Oct?


I'm not familiar with Oct. Can you point me to a URL?
[Octal characters, I thought. -John]


Post a followup to this message

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