Re: lex question

"toby" <>
8 Dec 2005 22:09:27 -0500

          From comp.compilers

Related articles
lex question (Mina Doroudi) (2005-12-02)
Re: lex question (Nathan Moore) (2005-12-08)
Re: lex question (toby) (2005-12-08)
lex question (Antonio Linares) (1999-03-23)
Re: lex question (Alejandro Dobniewski) (1999-03-28)
Re: lex question (1999-04-01)
Re: lex question (Chris F Clark) (1999-04-03)
| List of all articles for this month |

From: "toby" <>
Newsgroups: comp.compilers
Date: 8 Dec 2005 22:09:27 -0500
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
[\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.