DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
yacc

Lexical analysis

The user must supply a lexical analyzer to read the input stream and pass tokens to the parser. This analyzer may also need to associate values with the tokens and make these values known to the parser. A parser generated by yacc calls an integer-valued function called yylex to provide tokens. The function returns an integer, the ``token number'', that represents the kind of token being read. If value is associated with that token, the lexical analyzer should assign it to the external variable yylval. A parser generated by yacc is designed to look in this variable for the values of symbols that are defined as tokens. The variable yylval takes an integer value by default. It can be redefined to take on other kinds of values, as explained in ``Support for arbitrary value types''.

The parser and the lexical analyzer must agree on these token numbers before they can communicate. The numbers can be chosen by yacc or the user.


Next topic: lex and yylval
Previous topic: The yacc environment

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003