In this appendix the lexical structure of CLEAN is given. It describes the kind of tokens recognised by the scanner/parser. In particular it summarizes the keywords, symbols and characters which have a special meaning in the language.
In this Section the lexical structure of CLEAN is given. It describes the kind of tokens recognised by the scanner/parser. In particular it summarizes the keywords, symbols and characters which have a special meaning in the language.
LexProgram | = | { Lexeme | {Whitespace}+ } | ||||
Lexeme | = | ReservedKeywordOrSymbol | // see Section B.5 | |||
| | ReservedChar | // see Section B.4 | ||||
| | Literal | |||||
| | Identifier | |||||
Identifier | = | LowerCaseId | // see A.9 | |||
| | UpperCaseId | // see A.9 | ||||
| | SymbolId | // see A.9 | ||||
Literal | = | IntDenotation | // see B.4 | |||
| | RealDenotation | // see B.4 | ||||
| | BoolDenotation | // see B.4 | ||||
| | CharDenotation | // see B.4 | ||||
| | CharsDenotation | // see B.4 | ||||
| | StringDenotation | // see B.4 |
Whitespace | = | space | // a space character | |||
| | tab | // a horizontal tab | ||||
| | newline | // a newline char | ||||
| | formfeed | // a formfeed | ||||
| | verttab | // a vertical tab | ||||
| | Comment | // see Section B.2 |
Comment | = | // AnythingTillNL newline | ||||
| | /* AnythingTill/* Comment | // comments may be nested | ||||
AnythingTill*/ */ | ||||||
| | /* AnythingTill*/ */ | |||||
AnythingTillNL | = | {AnyChar/ newline} | // no newline | |||
AnythingTill/* | = | {AnyChar/ /*} | // no "/*" | |||
AnythingTill*/ | = | {AnyChar/ */} | // no "*/" | |||
AnyChar | = | IdChar | // see A.9 | |||
| | ReservedChar | |||||
| | SpecialChar |
LowerCaseId | = | LowerCaseChar{IdChar} | ||
UpperCaseId | = | UpperCaseChar{IdChar} | ||
SymbolId | = | {SymbolChar}+ |
QLowerCaseId | = | [ModuleQualifier]LowerCaseId | ||
QUpperCaseId | = | [ModuleQualifier]UpperCaseId | ||
QSymbolId | = | [ModuleQualifier space]SymbolId | ||
ModuleQualifier | = | 'ModuleName'. |
LowerCaseChar | = | a | | | b | | | c | | | d | | | e | | | f | | | g | | | h | | | i | | | j | | | k | | | l | | | m | ||||||||||||||||||||||||||
| | n | | | o | | | p | | | q | | | r | | | s | | | t | | | u | | | v | | | w | | | x | | | y | | | z | |||||||||||||||||||||||||||
UpperCaseChar | = | A | | | B | | | C | | | D | | | E | | | F | | | G | | | H | | | I | | | J | | | K | | | L | | | M | ||||||||||||||||||||||||||
| | N | | | O | | | P | | | Q | | | R | | | S | | | T | | | U | | | V | | | W | | | X | | | Y | | | Z | |||||||||||||||||||||||||||
SymbolChar | = | ~ | | | @ | | | # | | | $ | | | % | | | ^ | | | ? | | | ! | | | : | ||||||||||||||||||||||||||||||||||
| | + | | | - | | | * | | | < | | | > | | | \ | | | / | | | | | | | & | | | = | |||||||||||||||||||||||||||||||||
IdChar | = | LowerCaseChar | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | UpperCaseChar | |||||||||||||||||||||||||||||||||||||||||||||||||||
| | Digit | // see B.4 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | _ | | | ` |
IntDenotation | = | [Sign]{Digit}+ | // decimal number | |||
| | [Sign]0{OctDigit}+ | // octal number | ||||
| | [Sign]0x{HexDigit}+ | // hexadecimal number | ||||
Sign | = | + | - | ||||
RealDenotation | = | [Sign]{Digit}+.{Digit}+[E[Sign]{Digit}+] | ||||
BoolDenotation | = | True | False | ||||
CharDenotation | = | CharDel AnyChar/CharDel CharDel | ||||
StringDenotation | = | StringDel{AnyChar/StringDel}StringDel | ||||
CharsDenotation | = | CharDel {AnyChar/CharDel}+ CharDel |
AnyChar | = | IdChar | ReservedChar | SpecialChar | ||||||||||||||||||||||||||||||||||||||||||||||
ReservedChar | = | ( | | | ) | | | { | | | } | | | [ | | | ] | | | ; | | | , | | | . | ||||||||||||||||||||||||||||||
SpecialChar | = | \n | | | \r | | | \f | | | \b | // newline,return,formf,backspace | |||||||||||||||||||||||||||||||||||||||
| | \t | | | \\ | | | \CharDel | // tab,backslash,character delimiter | ||||||||||||||||||||||||||||||||||||||||||
| | \StringDel | // string delimiter | ||||||||||||||||||||||||||||||||||||||||||||||
| | \{OctDigit}+ | // octal number | ||||||||||||||||||||||||||||||||||||||||||||||
| | \x{HexDigit}+ | // hexadecimal number | ||||||||||||||||||||||||||||||||||||||||||||||
| | \IdChar | // escape any other character |
Digit | = | 0 | | | 1 | | | 2 | | | 3 | | | 4 | | | 5 | | | 6 | | | 7 | | | 8 | | | 9 | ||||||||||||||||||||
OctDigit | = | 0 | | | 1 | | | 2 | | | 3 | | | 4 | | | 5 | | | 6 | | | 7 | ||||||||||||||||||||||||
HexDigit | = | 0 | | | 1 | | | 2 | | | 3 | | | 4 | | | 5 | | | 6 | | | 7 | | | 8 | | | 9 | ||||||||||||||||||||
| | A | | | B | | | C | | | D | | | E | | | F | |||||||||||||||||||||||||||||
| | a | | | b | | | c | | | d | | | e | | | f |
CharDel | = | ' | ||
StringDel | = | " |
Below the keywords and symbols are listed which have a special meaning in the language. Some symbols only have a special meaning in a certain context. Outside this context they can be freely used if they are not a reserved character (see B.4). In the comment it is indicated for which context (name space) the symbol is predefined.
ReservedKeywordOrSymbol | = | |||||
// in all contexts: | /* | // begin of comment block | ||||
| | */ | // end of comment block | ||||
| | // | // rest of line is comment | ||||
| | :: | // begin of a type definition | ||||
| | :== | // in a type synonym or macro definition | ||||
| | = | // in a function, graph, alg type, rec field, case, lambda | ||||
| | =: | // labeling a graph definition | ||||
| | => | // in a function definition | ||||
| | ; | // end of a definition (if no layout rule) | ||||
| | foreign | // begin of foreign export |
// in global definitions: | | | from | // begin of symbol list for imports | |||
| | definition | // begin of definition module, | ||||
| | implementation | // begin of implementation module | ||||
| | import | // begin of import list | ||||
| | module | // in module header | ||||
| | system | // begin of system module |
// in function definitions: | | | -> | // in a case expression, lambda abstraction | |||
| | [ | // begin of a list | ||||
| | : | // cons node | ||||
| | ] | // end of a list | ||||
| | \\ | // begin of list or array comprehension | ||||
| | <- | // list gen. in list or array comprehension | ||||
| | <-: | // array gen. in list or array comprehension | ||||
| | { | // begin of a record or array, begin of a scope | ||||
| | } | // end of a record or array, end of a scope | ||||
| | . | // a record or array selector | ||||
| | ! | // a record or array selector (for unique objects) | ||||
| | & | // an update of a record or array, zipping gener. | ||||
| | case | // begin of case expression | ||||
| | code | // begin code block in a syst impl. module | ||||
| | if | // begin of a conditional expression | ||||
| | in | // end of (strict) let expression | ||||
| | let | // begin of let expression | ||||
| | # | // begin of let expression (for a guard) | ||||
| | #! | // begin of strict let expression (for a guard) | ||||
| | of | // in case expression | ||||
| | where | // begin of local def of a function alternative | ||||
| | with | // begin of local def in a rule alternative |
// in type specifications: | | | ! | // strict type | |||
| | . | // uniqueness type variable | ||||
| | # | // unboxed type | ||||
| | * | // unique type | ||||
| | : | // in a uniqueness type variable definition | ||||
| | -> | // function type constructor | ||||
| | [],[!],[!!],[#],[#!] | // lazy list, head strict, strict, unboxed, unboxed strict | ||||
| | [|] | // overloaded list | ||||
| | (,),(,,),(,,,),... | // tuple type constructors | ||||
| | {},{!},{#} | // lazy, strict, unboxed array type constr. | ||||
| | infix | // infix indication in operator definition | ||||
| | infixl | // infix left indication in operator definition | ||||
| | infixr | // infix right indication in operator definition | ||||
| | special | // to create a specialized instance | ||||
| | Bool | // type Boolean | ||||
| | Char | // type character | ||||
| | File | // type file | ||||
| | Int | // type integer | ||||
| | Real | // type real | ||||
| | World | // type world |
// in class definitions: | | | class | // begin of type class definition | |||
| | instance | // def of instance of a type class | ||||
| | derive | // derive instance of generic function |