Re: [Flex-help] Problems analyzing VRML source
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Aaron S. <aa...@se...> - 2007-04-10 18:49:22
|
On Tue, Apr 10, 2007, Rob Quill <rob...@gm...> said: > On 10/04/07, Tamas Nagy <ng...@ya...> wrote: >> Hi! >> >> I'm using yacc too. >> I think i have to do something in flex too. > > It is my understanding that Flex is just used for describing the > regular expressions you want to use to match against text to find > tokens. That's not very well written, but by example, in YACC/Bison: > > node: NODE L_BRACE children R_BRACE node > | ; > > children: CHILDREN L_BRACKET node R_BRACKET > > > Were NODE, L_BRACE, R_BRACE, CHILDREN, L_BRACKET and R_BRACKET are the > tokens returned by Flex. > > Does that make any more sense? Sorry if I've missed the point and over > simplified the problem. Exactly correct, take a look at section 3.2 of this document for a really great visualization of what flex does: http://ds9a.nl/lex-yacc/cvs/lex-yacc-howto.html Even in the case that you are "passing a string" from flex to bison, you're really not! yylex will return some token value (which you would probably call STRING to remind yourself of what's happening) and in the bison action, you'd have code that knows that when it sees STRING that there's more data in yylval that actually has a pointer to those bytes. Aaron |