Alan Grammars

How to read grammars

The documentation for the Alan languages describes the syntax of those languages in the form of an Alan grammar, often accompanied by a description and/or examples. An Alan grammar describes what you can write in an Alan file: the keywords to use, values to provide, and options to choose from.

Keywords

The orange literals between square brackets indicate required keywords. A comma indicates if keywords go before or after a property value. For example:

'name' [ & ] text     // means: & before a text value: &"Alice"
'name' [ & , * ] text // means: & before and * after a text value: &"Alice"*
'name' [ , * ] text   // means: * after a text value: "Alice"*

Properties

For example, take the following extract from the grammar of the application language:

'node' { [ { , } ]                       // curly braces wrap a node type
	'attributes' dictionary {            // an attribute starts with a key, followed by
		'type': [ : ] stategroup (       // a chosen type, preceded by keyword :
			'text' { [ text ] }          // 'text' requires keyword text
			'number' { [ number ] }      // 'number' requires keyword number
		)
	}
}

then a valid model is:

// application.alan (your model file)
{
	'A': text
	'B': number
}

Note that properties with an =-sign like stategroup = do not require your input, as the compiler derives them for you.

Typical quirks of the Alan compiler