Lexical
Previous: <Parser Function=>ParserFunc> * Next: <Error Reporting=>ErrorRepor> * Up: <Interface=>Interface>

#Wrap on
{fH3}The Lexical Analyzer Function {fCode}yylex{f}{f}

The {fUnderline}lexical analyzer{f} function, {fCode}yylex{f}, recognizes tokens from
the input stream and returns them to the parser.  Bison does not create
this function automatically; you must write it so that {fCode}yyparse{f} can
call it.  The function is sometimes referred to as a lexical scanner.

In simple programs, {fCode}yylex{f} is often defined at the end of the Bison
grammar file.  If {fCode}yylex{f} is defined in a separate source file, you
need to arrange for the token-type macro definitions to be available there.
To do this, use the {fEmphasis}-d{f} option when you run Bison, so that it will
write these macro definitions into a separate header file
{fCite}{fStrong}name{f}.tab.h{f} which you can include in the other source files
that need it.  \*Note <Invocation=>Invocation>: Invoking Bison.

#Wrap off
<Calling Convention=>CallingCon>:  How {fCode}yyparse{f} calls {fCode}yylex{f}.
<Token Values=>TokenValue>:      How {fCode}yylex{f} must return the semantic value
                        of the token it has read.
<Token Positions=>TokenPosit>:   How {fCode}yylex{f} must return the text position
                        (line number, etc.) of the token, if the
                        actions want that.
<Pure Calling=>PureCallin>:      How the calling convention differs
                        in a pure parser (\*Note <Pure Decl=>PureDecl>: A Pure (Reentrant) Parser).
#Wrap on

