5.0 Introduction

5.1 Metalanguage

5.2 LR-Family Parsing

5.3 Error Handling

5.4 Compaction of Tables

5.5 Yacc

5.6 Summary

Web References

Exercises

5.5.2 Functionality of YACC

The C code generated by YACC can be altered before compiling and executing. The generated parser "rules the show" in that it calls the function yylex() when it needs a token. Figure 3 shows a similar picture to that of LEX in Figure 3 of Chapter 3.

The metalanguage input is in a file called translate.y; the output of YACC is in a file called y.tab.c.

the input to the executable a.out program is again the source program because the a.out file contains the included scanner from LEX or the user-written scanner, yylex().

YACC produces a LALR(1) parser. The generated parser produces no output when presented with a correct source program unless the user-written actions contain ouput statements.

Send questions and comments to: Karen Lemone