Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
112 lines (83 sloc) 2.92 KB

Extended YAML Schema for Syntax Definitions

The syntax definition for Wolfram Language is very complicated. It is hard to write such a big JSON file with expansibility and maintainability, so I use YAML to define all the syntaxes and use some special tags to simplify the writing process. This page will tell you how the extended schema works.

All the source files can be found under directory build/types.


Every tag has its own environment and parameter type. In this schema, there are 4 environments and 3 parameter types.

Tag Environments

  1. regex: used under match, begin and end.
  2. capture: used under captures, beginCaptures and endCaptures.
  3. rule: used as a wrapper of a rule under a list of patterns.
  4. context: used under patterns or as the root of a context.

Tag Parameter Types

  1. scalar: parameters are written in a line separated by whitespaces after the tag name.
  2. sequence: parameters are witten in a list under the tag name.
  3. mapping: parameters are witten in an object under the tag name.

Basic Types

There are some basic types in the schema. These types are all very simple and easy to use. src/syntaxes/simplest.yaml only uses tags from this category so it may serves as a perfect example of how to use these tags.


(capture/mapping) It traverses all the captures and turn every string value into objects. For example:

endCaptures: !raw
  1: '#function-identifier'

will be transpiled into

  "endCaptures": {
    "1": { "patterns": [{ "include": "#function-identifier" }] },
    "2": { "name": "" }


(capture/scalar) It turns the parameter into the only capture of the regex. For Example:

beginCaptures: !all

will be transpiled into

  "beginCaptures": {
    "0": { "name": "" }


(context/scalar) It turns the parameter into the only rule of the context. The parameter will serves as the include target. For Example:

patterns: !push expressions

will be transpiled into

  "patterns": [{ "include": "#expressions" }]


(rule/scalar) It generates a rule for bracketing by the name of bracket given by the parameter. For Example:

- !bracket association

will be transpiled into

  "begin": "<\\|",
  "beginCaptures": {
    "0": { "name": "punctuation.section.association.begin.wolfram" }
  "end": "\\|>",
  "endCaptures": {
    "0": { "name": "punctuation.section.association.end.wolfram" }
  "name": "meta.association.wolfram",
  "patterns": [{ "include": "#expressions" }]

General Types





Type-Inference Types

See type inference.

You can’t perform that action at this time.