The following notations are used to described the grammar of Keli (for more info, lookup EBNF):
Notation | Meaning |
[ pattern ] | optional |
{ pattern } | repetition |
( pattern ) | grouping |
pattern1 | pattern2 | choice |
pattern1 | difference; elements of pattern1 except those of pattern2 |
| terminal syntax in typewriter font |
The following abbreviations will be used to describe the lexical structure of Keli.
Abbreviation | Meaning |
id | identifier |
op | operator |
alnum | alphanumeric |
Term | Definition |
program | { lexeme | whitespace } |
lexeme | id | literal | reservedOp |
id | alnumId | symbolicId |
alnumId | ( |
operator | ( |
alphabet |
|
digit |
|
literal | integer | float | string |
integer | decimal |
float | decimal |
decimal | digit { digit } |
string |
|
reservedOp |
|
whitespace | whitestuff { whitestuff } |
whitestuff | whitechar | comment |
whitechar | newline | vertab | space | tab | unicodeWhitespace |
newline | return linefeed | return | linefeed | formfeed |
return | a carriage return |
linefeed | a line feed |
vertab | a vertical tab |
formfeed | a form feed |
space | a space |
tab | horizontal tab |
unicodeWhitespace | any Unicode character defined as whitespace |
comment | slashes [ nonnewline { nonnewline }] newline |
slashes |
|
Comments are actually whitespaces. Comments starts with 2 slahses and extends until before the following newline. For example:
// this is a comment
A constant identifier is any sequences of characters that satisfy the following grammar:
( $
| _
| alphabet ) { alphabet | digit | -
| _
}
For example:
Term | Validity |
| Valid |
| Valid |
| Valid |
| Valid |
| Valid |
| Valid |
| Valid |
| Valid |
| Invalid |
Constant identifiers are used for identifying:
Function parameter
Type
Object property
Type variable
Function identifiers are used for identifying functions, they can be any sequences of characters that satisfy the following grammar:
​constId | ({operator }) <reservedOp>
In layman term, a function identifier can be a constant identifiers OR a sequences of symbols that are not reserved operator.
Examples of function identifiers:
Term | Validity |
| Valid |
| Valid |
| Valid |
| Valid |
| Valid |
| Invalid, reserved operator |