Noeud « Next »: , Noeud « Up »: Tiger Language Reference Manual



1.1 Lexical Specifications

Keywords
array, if, then, else, while, for, to, do, let, in, end, of, break, nil, function, var, and type
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, and \r\n, and \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. 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.
\\
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.

Comments
Like C comments, but can be nested:
          Code
          /* Comment
             /* Nested comment */
             Comment */
          Code
     

Identifiers
Identifiers start with a letter, followed by any number of alphanumeric characters plus the underscore. Case sensitive.
          id ::= 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
          digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
     

Numbers
There are only integers in Tiger.
          integer ::= digit { digit }
          op ::= + | - | * | / | = | <> | > | < | >= | <= | & | |
     

Invalid characters
Any other character is invalid.