Yacc: Yet Another Compiler-Compiler
Yacc: Yet Another Compiler-Compiler
Introduction
Yacc provides a general tool for describing the input to a
computer program.
1. Phototypesetter language,
WORKING OF YACC
Yacc provides a general tool for imposing structure on the
input to a computer program.
July 4, 1776
might be matched by the above rule.
BASIC SPECIFICATIONS:
Names refer to either tokens or nonterminal symbols.
Every specification file consists of three sections:
the declarations,
programs.
declarations
%%
rules
%%
programs
%%
rules
Blanks, tabs, and newlines are ignored except that they may
not appear in names or multi-character reserved symbols.
Comments may appear wherever a name is legal; they are
enclosed in /* . . . */, as in C and PL/I
'\n' newline
'\r' return
'\'' single quote ``'''
'\\' backslash ``\''
'\t' tab
'\b' backspace
'\f' form feed
'\xxx' ``xxx'' in octal
The NULL character ('\0' or 0) should never be used in grammar
rules.
empty : ;
Names representing tokens must be declared as
The vertical bar ``|'' can be used to avoid rewriting the left
hand side.