Files
bison/examples/c/bistromathic
Akim Demaille 4b802d6417 bistromathic: beware of portability issues with readline
In some cases readline emits a trailing spaces after the last
suggestion, which results in errors such as:

```
-(       -       atan    cos     exp     ln      number  sin     sqrt$
+(       -       atan    cos     exp     ln      number  sin     sqrt    $
```

Reported by Christopher Nielsen <mascguy@github.com>.
<https://trac.macports.org/ticket/59927#comment:48>
<https://trac.macports.org/attachment/ticket/59927/bison-3.7.6-test-10.13.test-suite.log>

* examples/test (run): Add support for -t.
* examples/c/bistromathic/bistromathic.test: Use it.
2021-08-08 08:08:04 +02:00
..
2021-01-29 13:48:43 -08:00
2021-01-16 16:11:17 +01:00

bistromathic - all the bells and whistles

This example demonstrates best practices when using Bison.

  • Its hand-written scanner tracks locations.
  • Its interface is pure.
  • It uses %params to pass user information to the parser and scanner.
  • Its scanner uses the error token to signal lexical errors and enter error recovery.
  • Its interface is "incremental", well suited for interaction: it uses the push-parser API to feed the parser with the incoming tokens.
  • It features an interactive command line with completion based on the parser state, based on yyexpected_tokens.
  • It uses Bison's standard catalog for internationalization of generated messages.
  • It uses a custom syntax error with location, lookahead correction and token internationalization.
  • Error messages quote the source with squiggles that underline the error:
> 123 456
1.5-7: syntax error: expected end of file or + or - or * or / or ^ before number
    1 | 123 456
      |     ^~~
  • It supports debug traces with semantic values.
  • It uses named references instead of the traditional $1, $2, etc.

To customize the interaction with bistromathic, see the GNU Readline user manual (see info rluserman).