▼ |  | Parser Tools: lex and yacc-style Parsing

1 | Lexers
2 | LALR(1) Parsers
3 | Context-Free Parsers
4 | Converting yacc or bison Grammars
| Index

On this page:

cfg-parser

top ← prev up next →

### 3`` Context-Free Parsers

(require parser-tools/cfg-parser)
| package: parser-tools-lib

The parser-tools/cfg-parser library provides a parser generator that is an alternative to that of parser-tools/yacc.

> syntax (cfg-parser clause ...)
> clause |  | = |  |
> (grammar (non-terminal-id
> ((grammar-id ...) maybe-prec expr)
> ...)
> ...)
> |  | | |  | (tokens group-id ...)
> |  | | |  | (start non-terminal-id ...)
> |  | | |  | (end token-id ...)
> |  | | |  | (error expr)
> |  | | |  | (src-pos)

Creates a parser similar to that of parser. Unlike parser, cfg-parser, can consume arbitrary and potentially ambiguous context-free grammars. Its interface is a subset of parser-tools/yacc, with the following differences:

- (start non-terminal-id)

  Unlike parser, cfg-parser only allows for a single non-terminal-id.

- The cfg-parser form does not support the precs, suppress, debug, or yacc-output options of parser.

top ← prev up next →