Wherever it is possible, we use also EBNF for description of lexical
symbols through ASCII set characters. Otherwise, we will use natural
language sentences in <
and >
. Lexical symbols are
identifiers, numbers, character constants, strings, operators,
delimiters, and comments. White characters (blanks and line breaks)
must not occur within the symbols (except in comments, and blanks in
strings). White characters are ignored unless they are essential to
separate two consecutive lexical symbols. Upper- and lower-case
letters are considered to be distinct.
Ident = Letter {Letter | Digit}
Letter = "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"
| "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"
| "_"
OctalDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7"
Digit = OctalDigit | "8" | "9"
Examples:
line line2 next_line NextLine
.
or an exponent in the number.
Number = Integer | FloatingPointNumber
Integer = Digit {Digit}
FloatingPointNumber = Digit {Digit} "." { Digit } [Exponent]
| Digit {Digit} [Exponent]
Exponent = ("e" | "E") [ "+" | "-" ] Digit { Digit }
Examples:
10
100.
1e2
100.0E+0
\a -
ASCII character alert\b -
ASCII character backspace\f -
ASCII character form feed\n -
ASCII character new line\r -
ASCII character carriage return\t -
ASCII character horizontal tab\v -
ASCII character vertical tab\code -
ASCII character with given octal code\char -
ASCII character char for all remaining characters\'
.
The double quote mark can be represented either by \"
or simply by "
. To represent a backslash inside the
character constant, use two consecutive ASCII backslashes.
Character = "'" Char "'"
Char = <any ASCII character except for the single quote ',
backslash \, or line break>
| SimpleEscapeSeq
| OctalEscapeSeq
SimpleEscapeSeq = <one of \' \" \\ \a \b \f \n \r \t \v>
OctalEscapeSeq = "\" OctalDigit [ OctalDigit [ OctalDigit ] ]
Examples:
'a' '\'' '\\' '\12' '"'
\"
. The
single quote mark can be represented either by \'
or
simply by '
. To represent a backslash inside the
character constant, use two consecutive ASCII backslashes.
String = '"' {Char} '"'
Examples:
"This is Dino" "Don't worry\n"
OperatorOrDelimeter = "?" | ":" | "|" | "||" | "&" | "&&" | "^"
| "==" | "!=" | "===" | "!==" | "<" | ">"
| "<=" | ">=" | "<<" | ">>" | ">>>" | "@"
| "+" | "-" | "/" | "*" | "%" | "!" | "+"
| "-" | "~" | "#" | "(" | ")" | "[" | "]"
| "{" | "}" | "." | "," | ";" | "="
| "*=" | "/=" | "%=" | "+=" | "-="
| "@=" | "<<=" | ">>=" | ">>>=" | "&="
| "^=" | "|=" | "++" | "--" | "..." | "<=>"
| Keyword
Keyword = "break" | "catch" | "char" | "class" | "continue"
| "else" | "ext" | "extern"
| "final" | "float" | "for" | "friend" | "func"
| "hide" | "hideblock" | "if" | "in" | "int"
| "new" | "nil" | "public" | "private" | "return"
| "table" | "thread" | "throw" | "try" | "type"
| "var" | "vector" | "wait"
/*
and finishing with */
. The second
type of comment starts with //
and finishes with the
first line break or with the end of file.
Comment = "/*" <arbitrary char. sequence not containing pair */> "*/"
| "//" <arbitrary char. sequence finishing on line break>