Syntax Definition Formalism
From Wikipedia, the free encyclopedia
The Syntax Definition Formalism (SDF for short) is a metasyntax used to define context-free grammars: that is, a formal way to describe formal languages. It can express the entire range of context-free grammars. Its current version is SDF2. A parser and parser generator for SDF specifications are provided as part of the free ASF+SDF Meta Environment. These operate using the SGLR (Scannerless GLR parser). An SDF parser outputs parse trees or, in the case of ambiguities, parse forests.
Contents |
[edit] Overview
Features of SDF:
- Supports the entire range of context-free languages
- Allows modular syntax definitions (grammars can import subgrammars) which enables reuse
- Supports annotations
[edit] Examples
The following example defines a simple Boolean expression syntax:
module basic/Booleans
exports
sorts Boolean
context-free start-symbols Boolean
context-free syntax
"true" -> Boolean
"false" -> Boolean
lhs:Boolean "|" rhs:Boolean -> Boolean {left}
lhs:Boolean "&" rhs:Boolean -> Boolean {left}
"not" "(" Boolean ")" -> Boolean
"(" Boolean ")" -> Boolean
context-free priorities
Boolean "&" Boolean -> Boolean >
Boolean "|" Boolean -> Boolean
[edit] Program analysis and transformation systems using SDF
- ASF+SDF Meta Environment provides SDF
- Stratego/XT
- Strafunski
[edit] See also
- GNU bison
- ANTLR
- Grammar Deployment Kit
- SdfMetz computes metrics for SDF grammars
[edit] External links
- Download SDF from the ASF+SDF Meta Environment homepage

