<center><strong>Bisonc++</strong> (Version 1.6.1) User Guide</center>

Bisonc++ (Version 1.6.1) User Guide

Frank B. Brokken

Computing Center, University of Groningen
Nettelbosje 1,
P.O. Box 11044,
9700 CA Groningen
The Netherlands

2005-2007

Table of Contents

Chapter 1: Introduction

Chapter 2: Conditions for Using Bisonc++

2.1: The `GNU General Public License' (GPL)

Chapter 3: Bisonc++ concepts

3.1: Languages and Context-Free Grammars

3.2: From Formal Rules to Bisonc++ Input

3.3: Semantic Values

3.4: Semantic Actions

3.5: Bisonc++ output: the Parser class

3.5.1: Bisonc++: a NON-Reentrant Parser

3.6: Stages in Using Bisonc++

3.7: The Overall Layout of a Bisonc++ Grammar File

Chapter 4: Examples

4.1: rpn: a Reverse Polish Notation Calculator

4.1.1: Declarations for the `rpn' calculator
4.1.2: Grammar rules for the `rpn' calculator
4.1.2.1: Explanation of `input'
4.1.2.2: Explanation of `line'
4.1.2.3: Explanation of `expr'
4.1.3: The Lexical Scanner used by `rpn'
4.1.4: The Controlling Function `main()'
4.1.5: The error reporting member `error()'
4.1.6: Running Bisonc++ to generate the Parser
4.1.7: Constructing and running `rpn'

4.2: `calc': an Infix Notation Calculator

4.3: Basic Error Recovery

4.4: `mfcalc': a Multi-Function Calculator

4.4.1: The Declaration Section for `mfcalc'
4.4.2: Grammar Rules for `mfcalc'
4.4.3: The `mfcalc' Symbol- and Function Tables
4.4.4: The revised `lex()' member
4.4.5: Constructing `mfcalc'

4.5: Exercises

Chapter 5: Bisonc++ grammar files

5.1: Outline of a Bisonc++ Grammar File

5.2: Symbols, Terminal and Nonterminal Symbols

5.3: Syntax of Grammar Rules

5.4: Writing recursive rules

5.5: Defining Language Semantics

5.5.1: Data Types of Semantic Values
5.5.2: More Than One Value Type
5.5.3: Actions
5.5.4: Data Types of Values in Actions
5.5.5: Actions in Mid-Rule

5.6: Bisonc++ Directives

5.6.1: %token: Token Type Names
5.6.2: %left, %right, %nonassoc: Operator Precedence
5.6.3: %prec: Overruling default precedences
5.6.4: %type: Nonterminal Symbols
5.6.5: %expect: Suppressing Conflict Warnings
5.6.6: %start: The Start-Symbol
5.6.7: %class-name: Choosing the Name of the Parser Class
5.6.8: %namespace: Using a namespace
5.6.9: %negative-dollar-indices: Using constructions like $-1
5.6.10: %stype: The semantic stack type
5.6.11: %union: The Collection of Value Types
5.6.12: %lsp-needed: Using the default location type
5.6.13: %ltype: Using an existing location type
5.6.14: %locationstruct: Specifying a dedicated location struct
5.6.15: %scanner: Using a standard scanner interface
5.6.16: Directives controlling generated filenames
5.6.16.1: %baseclass-header: the Parser's Base Class header
5.6.16.2: %class-header: the Parser's Class header
5.6.16.3: %implementation-header: the Implementation Header
5.6.16.4: %parsefun-source: the parse() function's sourcefile
5.6.16.5: %filenames: the generic filenames
5.6.17: %baseclass-preinclude: header included by the baseclass
5.6.18: %debug: Adding debugging code to the `parse()' member
5.6.19: %error-verbose: (To Do) Dumping the parser stack
5.6.20: %lines: Insert `#line' directives

5.7: Basic Grammatical Constructions

5.7.1: Plain Alternatives
5.7.2: One Or More Alternatives, No Separators
5.7.3: Zero Or More Alternatives, No Separators
5.7.4: One Or More Alternatives, Using Separators
5.7.5: Zero Or More Alternatives, Using Separators
5.7.6: Nested Blocks

5.8: Multiple Parsers in the Same Program

Chapter 6: The Generated Parser Class' Members

6.1: Public Members and Types

6.2: Private Enumerations and Types

6.3: Private Member Functions

6.3.1: `lex()': the Lexical Analyzer interface

6.4: Private Data Members

6.5: Types and Variables in the Anonymous Namespace

6.5.1: Special Features for Actions

Chapter 7: The Bisonc++ Parser Algorithm

7.1: Look-Ahead Tokens

7.2: Shift/Reduce Conflicts

7.3: Operator Precedence

7.3.1: When Precedence is Needed
7.3.2: Specifying Operator Precedence
7.3.3: Precedence Examples
7.3.4: How Precedence Works

7.4: Context-Dependent Precedence

7.5: Parser States

7.6: Reduce/Reduce Conflicts

7.7: Mysterious Reduce/Reduce Conflicts

Chapter 8: Error Recovery

8.1: Syntactical Error Recovery

8.2: Semantical Error Recovery

Chapter 9: Invoking Bisonc++

9.1: Bisonc++ options

9.2: Bisonc++ usage