Calling the code

The code produced by lex and yacc only constitutes part of a program. For example, it does not include a main routine. At the very minimum, therefore, you need to create a main routine of the form:
main()
{
    return yyparse();
}
This calls yyparse(), which then goes on to read and process the input, calling on yylex() to break the input into tokens. yyparse() terminates when it reaches end-of-file, when it encounters some construct that marks the logical end of input, or when it finds an error that it is not prepared to handle. The value returned by yyparse() is returned as the status of the whole program. This main routine is available in a yacc library, as shown later.

Obviously, the main routine may have to be much more complex It may also be necessary to write a number of functions that are called by yylex() to help analyze the input, or by yyparse() to help process it.