Zyacc
A Parser-Generator
Edition 1.0, for Zyacc Version 1.
July 1997
Adapted from The Bison Manual
Zerksis D. Umrigar
Introduction
Acknowledgements
Zyacc Enhancements
The Concepts of Zyacc
Languages and Context-Free Grammars
From Formal Rules to Zyacc Input
Semantic Values
Semantic Actions
Zyacc Output: the Parser File
Stages in Using Zyacc
The Overall Layout of a Zyacc Grammar
Examples
Reverse Polish Notation Calculator
Declarations for
rpcalc
Grammar Rules for
rpcalc
Explanation of
input
Explanation of
line
Explanation of
expr
The
rpcalc
Lexical Analyzer
The Controlling Function
The Error Reporting Routine
Running Zyacc to Make the Parser
Compiling the Parser File
Infix Notation Calculator:
calc
Simple Error Recovery
Multi-Function Calculator:
mfcalc
Declarations for
mfcalc
Grammar Rules for
mfcalc
The
mfcalc
Symbol Table
The
mfcalc
Scanner
The
mfcalc
String Space
Why a Separate String Space
The Multi Function Calculator Using a Sugared Syntax
A Multi Function Calculator Which Evaluates Polynomials
A Calculator Which Omits Some Parentheses
Exercises
Zyacc Grammar Files
Outline of a Zyacc Grammar
The C Declarations Section
The Zyacc Declarations Section
The Grammar Rules Section
The Additional C Code Section
Symbols, Terminal and Nonterminal
Syntax of Grammar Rules
Recursive Rules
Defining Language Semantics
Data Types of Semantic Values
More Than One Value Type
Actions
Data Types of Values in Actions
Actions in Mid-Rule
Named Attributes
Named Terminal Attributes
Named Nonterminal Attributes
Inherited Attributes
Inherited Attributes Notation
Attribute Flow Restrictions
Attribute Conflicts
Semantic Tests
A Prototypical Example
Semantic Test Details
Semantic Test Example
Zyacc Declarations
Token Type Names
Operator Precedence
Multi-Character Literal Tokens
The Collection of Value Types
Nonterminal Symbols
Suppressing Conflict Warnings
The Start-Symbol
Multiple Start Symbols
A Pure (Reentrant) Parser
Option Declaration
Specifying the Lookahead
Zyacc Declaration Summary
Multiple Parsers in the Same Program
Parser C-Language Interface
The Parser Function
yyparse
The Lexical Analyzer Function
yylex
Calling Convention for
yylex
Semantic Values of Tokens
Textual Positions of Tokens
Calling Conventions for Pure Parsers
The Error Reporting Function
yyerror
Special Features for Use in Actions
The Zyacc Parser Algorithm
Look-Ahead Tokens
Shift/Reduce Conflicts
Operator Precedence
When Precedence is Needed
Specifying Operator Precedence
Precedence Examples
How Precedence Works
Context-Dependent Precedence
Parser States
Reduce/Reduce Conflicts
Mysterious Reduce/Reduce Conflicts
Stack Overflow, and How to Avoid It
Error Recovery
Handling Context Dependencies
Semantic Info in Token Types
Lexical Tie-ins
Lexical Tie-ins and Error Recovery
Debugging Your Parser
Building Debugging Parsers
Compiling Debugging Parsers
Linking Debugging Parsers
Printing Token Semantics
Environmental Variables
Debugging Parsers Using a Textual Interface
Starting a Single Process Textual Debugger
Starting a Multiple Process Textual Debugger
Textual Debugger Commands
Debugging Parsers Using a Graphical User Interface
Starting a GUI Debugger as a Java Application
Starting a GUI Debugger as a Java Applet
Using the Debugger GUI
Tradeoffs between Debugging Approaches
Invoking Zyacc
Option Conventions
Option Sources
Zyacc Options
Data Search List
Known Incompatibilities with Bison
Bugs and Deficiencies
Suspicions
Bug Reports
Zyacc Symbols
Glossary
Conditions
Conditions for Using Bison
GNU GENERAL PUBLIC LICENSE
Preamble
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
How to Apply These Terms to Your New Programs
Index
This document was generated using the
texi2html
translator version 1.31.