What is YYText() ? and where/how it is defined ?

4,413 views
Skip to first unread message

Viewon01

unread,
Mar 10, 2011, 5:41:49 AM3/10/11
to OSL Developers
Hi,

I'm looking at the parser and would like to know where is the YYText()
method ? Is it auto-generated ?

I'm unable to find it !

Thx

Larry Gritz

unread,
Mar 11, 2011, 5:14:30 PM3/11/11
to osl...@googlegroups.com


YYText() is supplied by flex, which auto-generates the lexical analyzer from our description in osllex.l. The return value of YYText() is the single token that was just recognized.

To review: lexical analysis is the stage that breaks up the raw character stream into "tokens". For example,

float foo[3];

gets split into 6 tokens: typename "float", identifier: "foo", open bracket "[", integer "3", close bracket "]", and semicolon ";".

The next stage is parsing, which takes that token list and realizes that it's a variable declaration statement.

My favorite intro to such things (including lex and yacc, which are the precursors to flex and bison) is Aho, Sethi, and Ullman's book "Compilers: Principles, Techniques, and Tools" (also called the "Dragon Book"), the 1986 edition (I don't like the newer one nearly as much).

-- lg

--
Larry Gritz
l...@imageworks.com


Reply all
Reply to author
Forward
0 new messages