SDF3 — Syntax Definition Formalism¶
SDF3 is the third version of the Syntax Definition Formalism meta-language in Spoofax for defining the syntax of a language, which is used for both parsing an input into an Abstract Syntax Tree, and to provide syntax highlighting. Through the use of templates SDF3 can also be used to define a pretty-printer.
An SDF3 syntax definition is structured as a collection of modules, which may import each other. Each module defines a number of symbols, which are the building blocks of productions. Productions are defined for lexical, context-free, or kernel syntax. Start symbols indicate the entry point of a syntax definition.
Grammars can be disambiguated by means of rejects, priorities, associativity, and restrictions, and permissive grammars are automatically generated for error-recovery parsing. Handwritten recovery rules can be added to tweak recovery behavior.
Several aspects related to syntax definition and parsing can be configured.
The sources of the SDF3 language can be found at:
- template.lang: SDF3 language specification
Created: September 15, 2023