next up previous contents
Next: Strings Up: Lexical Structure Previous: Lexical Structure   Contents

Integers, Identifiers, and Special Notation

Integers are non-empty strings of digits 0-9. It is a lexer error if a literal integer constant is too big to be represented as a 32-bit signed integer. 32-bit signed integers range from -2,147,483,648 to +2,147,483,647. Cool integer constants are always non-negative, so valid integer constants range from 0 to 2,147,483,647.

Identifiers are strings (other than keywords) consisting of letters, digits, and the underscore character. Type identifiers begin with a capital letter; object identifiers begin with a lower case letter. Identifiers are case sensitive.

self and SELF_TYPE are treated specially by Cool but are not treated as keywords. self should be reported by the lexer as an identifier and SELF_TYPE should be reported by the lexer as a type. Both are case sensitive.

The special syntactic symbols (e.g., parentheses, assignment operator, etc.) are given in Figure 1.