Appendix A MAL syntax summary
The MAL syntax is summarized below in extended BNF.
Alternative constructs are seperated by | and grouped
by parenthesis.
Optional parts are marked with square brackets.
A repetition is marked with either '+' or '*' to
indicate at least once and many times, respectively.
Lexical tokens are illustrated in small capitals.
| program
| : (statement ';') *
| | statement
| : moduleStmt [helpinfo] | definition [helpinfo]
| | | includeStmt | stmt
| | moduleStmt
| : module ident | atom ident [':'ident]
| | includeStmt
| : include identifier
| include string_literal
| | definition
| : command header address identifier
| | | pattern header address identifier
| | | function header statement* end identifier
| | | factory header statement* end identifier
| | helpinfo
| : comment string_literal
| | header
| : [ moduelName '.'] name '(' params ')' result
| | result
| : paramType | '(' params ')'
| | params
| : binding [',' binding]*
| | binding
| : identifier typeName [ props ]
| | typeName
| : scalarType | collectionType
| ':' any ['_' digit]
| | scalarType
| : ':' identifier
| | collectionType
| : ':' bat ['[' colType ',' colType ']']
| | colType
| : scalarType | anyType
| | props
| : '{' property [ ',' property]* '}'
| | property
| : identifier [ compare literal]
| | compare
| : '=' | '<' | '<=' | '>' | '>=' | '!='
| | stmt
| : [tag] varlist [':=' expr ]
| | tag
| | return | barrier | catch
| leave | redo | raise
| | varlist
| : variable
| '(' variable [',' variable ] * ')'
| | variable
| : identifier [ props ]
| | expr
| : fcncall | [factor operator] factor
| | factor
| : literal_constant | nil | var
| | fcncall
| : moduleName '.' name '(' [args] ')'
| | args
| : factor [',' factor]*
|
|