# Lexical Specifications¶

Keywords

`array`, `if`, `then`, `else`, `while`, `for`, `to`, `do`, `let`, `in`, `end`, `of`, `break`, `nil`, `function`, `var`, `type`, `import` and `primitive`

Object-related keywords

The keywords `class`, `extends`, `method` and `new` are reserved for object-related constructions. They are valid keywords when the object extension of the language is enabled, and reserved words if this extension is disabled (i.e. they cannot be used as identifiers in object-less syntax).

Symbols

`,`, `:`, `;`, `(`, `)`, `[`, `]`, `{`, `}`, `.`, `+`, `-`, `*`, `/`, `=`, `<>`, `<`, `<=`, `>`, `>=`, `&`, `|`, and `:=`

White characters

Space and tabulations are the only white space characters supported. Both count as a single character when tracking locations.

End-of-line

End of lines are `\n\r`, `\r\n`, `\r` and `\n`, freely intermixed.

Strings

The strings are ANSI-C strings: enclosed by `"`, with support for the following escapes:

`\a`, `\b`, `\f`, `\n`, `\r`, `\t`, `\v`

Control characters.

`\num`

The character which code is `num` in octal. Valid character codes belong to an extended (8-bit) ASCII set, i.e. values between 0 and 255 in decimal (0 and 377 in octal). `num` is composed of exactly three octal characters, and any invalid value is a scan error.

`\xnum`

The character which code is `num` in hexadecimal (upper case or lower case or mixed). `num` is composed of exactly 2 hexadecimal characters. Likewise, expected values belong to an extended (8-bit) ASCII set.

`\\`

A single backslash.

`\"`

A double quote.

`\character`

If no rule above applies, this is an error.

All the other characters are plain characters and are to be included in the string. In particular, multi-line strings are allowed.

Like C comments, but can be nested:

```/* Comment
/* Nested comment */
Comment */
```
Identifiers

Identifiers start with a letter, followed by any number of alphanumeric characters plus the underscore. Identifiers are case sensitive. Moreover, the special `_main` string is also accepted as a valid identifier.

```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" ;
digit  = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
id     = letter { letter | digit | "_" } | "_main" ;
```
Numbers

There are only integers in Tiger.

```integer = digit { digit } ;
```
Invalid characters

Any other character is invalid.