Re: lex question



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.

I don't think that there is any automatic way to do what you want unless
you can use

{X} ACTION_FOR_X
..+ ACTION_FOR_EVERYTHING_ELSE

which is not likely to work unless you are trying to match the entire
input as either X or Y.
I had to do something similar for C style comments and ended up just
drawing out several DFAs for them and then converting those to
regular expressions. It was a lot of work, and I had to go back and
fix things that I messed up a lot, but it did work.
There are things about "match anything but" for anything that is not
simply character or character class that are a lot more complicated
to compute than you would think. It's really that lex can't really
always tell what you might want it to match.
>
> 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])
> any Idea how to parse text with Oct?
Just to be clear -- You are trying to match the characters whose values
are between 1 and 6, right? Well I don't know how to do that. Very
interesting. It would be trivial to actually do, but I just don't know
the syntax or even if there is a syntax to do it b/c they all have no
short escape like \n, \a, ....
You could do:
((\001)|(\002)|(\003)|(\004)|(\005)|(\006))
It's ugly (esp since I used a bunch of extra () so that you could use it
in the middle of something else if you wanted to.
> -Mina Doroudi (dormina@xxxxxxxxxxxxx)
I wish I was at GA Tech, but I'm down the road in Macon.

Hope I was some help,
Nathan
.



Relevant Pages

  • Re: New symbolic/numeric/dynamic/intuitive programming language
    ... Furthermore lex uses regular expressions, not BNF. ... I can't tell from 'man yacc' what format it uses for the syntax ...
    (sci.math)
  • Re: Great Brain Robbery
    ... Possibly, but assuming they'd go with a Big 7 character, let's look at the ... Lex would wreak havoc with the ring, but John would catch on to what's ... Could've been a fun episode due to the opposite personalities and ... Lex getting to show what Superman cutting loose would be like. ...
    (rec.arts.comics.dc.universe)
  • Re: New symbolic/numeric/dynamic/intuitive programming language
    ... Are you saying that lex and yacc fail this test? ... Furthermore lex uses regular expressions, not BNF. ... I can't tell from 'man yacc' what format it uses for the syntax ...
    (sci.math)
  • Re: Great Brain Robbery
    ... Possibly, but assuming they'd go with a Big 7 character, let's look at the ... Lex would wreak havoc with the ring, but John would catch on to what's ... Lex getting to show what Superman cutting loose would be like. ... and Flash. ...
    (rec.arts.comics.dc.universe)
  • Re: Lex/Yacc and multiple input files
    ... # I am using lex and yacc to write a vhdl to systemc converter. ... or yacc might recognise it and send back to the character input commands ...
    (comp.lang.c)