Skip to content

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 (AST), and to provide syntax highlighting.

Through the use of templates, SDF3 can also be used to define a pretty-printer.

SDF3 was originally called "The Template Language".

Syntax

TemplateLang.sdf3

The syntax of SDF3 is defined in SDF3 itself.

This example demonstrates generation of a hyperlinked twin from a bootstrapped meta-language definition.

Name binding

names.nab

The name binding of SDF3 is specified in NaBL for use in Spoofax 2.

main.stx

The name binding of SDF3 is specified in Statix for use in Spoofax 3.