Next: , Previous: Top, Up: Top

1 Overview

semantic version 2 introduced a new grammar framework to provide a clean and consistent view into parser writing.

All grammars are specified in a common rule based language derived from the input grammar language used by the GNU parser generator Bison. The main differences are that:

Nevertheless, for those who are familiar with the Bison grammar syntax, and have some knowledge of Emacs Lisp, writing semantic grammars won't prove too hard. Moreover, the grammar framework provides Emacs goodies (indentation, syntax coloring, etc.) to help edit grammars.

Grammars written in the common rule based language must be translated into Emacs Lisp code so a semantic parser can use it. The framework defines a reusable and flexible API that simplifies the implementation of grammar-to-lisp translators.

The abstract major mode semantic-grammar-mode provides the core functionalities to edit and translate input grammars.

Concrete grammar modes, derived from semantic-grammar-mode, implement the common API that translates the input grammar format into Emacs Lisp code understandable by a particular parser. An unique file extension associates input grammars to a concrete grammar mode, that is to a particular translator and parser.

semantic provides these concrete grammar modes:

The following diagram presents a global view of the framework: