- Table of Contents
- Next Chapter

# Chapter 1: Introduction

Bisonc++ is a general-purpose parser generator converting grammar descriptions for LALR(1) context-free grammars into C++ classes whose members can parse such grammars. Once you are a proficient bisonc++ user, you may use it to develop a wide range of language parsers, from those used in simple desk calculators to complex programming languages.

Bisonc++ is highly comparable to the program bison++, written by Alain Coetmeur: all properly-written bison++ grammars ought to be convertible to bisonc++ grammars requiring very little or no modifications. Anyone familiar with bison++ or its precursor, bison, should quickly be able to use bisonc++ as well. Bisonc++ generates C++ code, rather than C code, and so a fair knowledge of the C++ programming language is required before bisonc++ can profitably be used.

This manual closely resembles bison(1)'s userguide. In fact, many sections of that manual were copied straight into this manual. With bisonc++ distributions (both the full source distribution and the binary `.deb` distributions) bison's orginal manual is included in both PostScript and (converted from the `texi` format) `HTML` format. Where necessary sections of the original manual were adapted to bisonc++'s characteristics. Some sections were removed, and some new sections were added to the current manual. Expect upgrades of the manual to appear without further notice. Upgrades will be announced in the manual's title.

The current manual starts with tutorial chapters that explain the basic concepts of using bisonc++ and use three examples illustrating some of the core issues of LALR(1) grammars, each example building on the previous example (where available). If you don't know bisonc++, bison++ or bison, start by reading these chapters. Reference chapters follow describing specific aspects of bisonc++ in detail.

Bisonc++ was designed and built by Frank B. Brokken. The program's first version was constructed between November 2004 and May 2005.

## 1.1: What's new in version 6.04.00

If you're new to bisonc++, you can safely skip this section. If you used bisonc++ before, please note the following new and modified features:

- Starting with version 6.02.00 bisonc++ reserved identifiers no longer end in two underscore characters, but in one. This modification was necessary because according to the C++ standard identifiers having two or more consecutive underscore characters are reserved by the language. In practice this could require some minor modifications of existing source files using bisonc++'s facilities, most likely limited to changing `Tokens__` into `Tokens_` and changing `Meta__` into `Meta_`.

  The complete list of affected names is:

  Enums:

  > DebugMode_, ErrorRecovery_, Return_, Tag_, Tokens_

  Enums values:

  > PARSE_ABORT_, PARSE_ACCEPT_, UNEXPECTED_TOKEN_, sizeofTag_

  Type / namespace designators:

  > Meta_, PI_, STYPE_

  Member functions:

  > clearin_, errorRecovery_, errorVerbose_, executeAction_, lex_, lookup_, nextCycle_, nextToken_, popToken_, pop_, print_, pushToken_, push_, recovery_, redoToken_, reduce_, savedToken_, shift_, stackSize_, startRecovery_, state_, token_, top_, vs_,

  Protected data members:

  > d_acceptedTokens_, d_actionCases_, d_debug_, d_nErrors_, d_requiredTokens_, d_val_, idOfTag_, s_nErrors_

- The generated code was redesigned. Large parts of the protected interface of the parser's base class and names of `parse()`-related members in the generated parser class were modified. The names of all accessible members in `parserbase.h` and `parser.h` now end in a trailing underscore character. Predefined members in `parser.ih` no longer have trailing underscores, and can be redefined (but must be available). The traditional `error(char const *)` member in fact never uses its argument (and bisonc++ only passes the default "Syntax error" argument). Its prototype now no longer defines a parameter. Here's an overview of modified member names/signatures:

  > Before 6.00.00 |  | Starting with 6.00.00
  > `void error(char const *)` |  | `void error()`
  > `void exceptionHandler_(...)` |  | `void exceptionHandler(...)`
  > `void errorRecovery()` |  | `void errorRecovery_()`
  > `void executeAction(int)` |  | `void executeAction_(int)`
  > `void nextToken()` |  | `void nextToken_()`
  > |  | added:
  > |  | `void nextCycle_()`
  > |  | remove:
  > |  | `int lookup(bool)`

  When re-generating parsers generated by bisonc++ before version 6.00.00, the signatures of the above functions in the file parser.h must be hand-modified to reflect the above changes. In addition, the implementations of error and exceptionHandler (default implementations were provided in parser.ih) must be adapted to their new signatures.

- Added a warning to `skeletons/binsonc++.h` that until the `#undef` instruction the parser class name will be read as the parser's base class name.

- With Polymorphic semantic values a tag mismatch is not considered fatal anymore if errors were already encountered. In that case the semantic value showing a tag mismatch is replaced by the default value of the semantic value of the expected polymorphic type.

  Starting with version 6.03.00 assignment to polymorphic semantic values is not anymore implemented through templates. The main reason is that inferred types may not be defined as a polymorphic semantic value type. Refer to section 4.6.1 for details.

- Added option and directive `--prompt` (`%prompt`): when debug-code is active, the generated parser shows a ?-prompt at each cycle when processing its input (which should not be provided on the standard input stream).

- Option `--thread-safe` can now also be specified as a directive (`%thread-safe`).

- Members that should not be modified by the parser class were moved to the parser's base class's private section. Accessor members are now available in the parser's base class, allowing user code to read, e.g., the currently active token and parsing state.

- Table of Contents
- Next Chapter