| Imp |
Copyright (c) 1998-1999 Redshift
Software Inc. All Rights Reserved
|
1 |
Lexical |
||
| The IMP compiler operates in several distinct phases. First, a stream based preprocessor with a syntax similar to IMP itself expands the source file; removing comments, doing macroexpansion, and substitution. Next, the IMP parser transforms the resulting IMP code into assembly. Then an assembly preprocessor expands any references remaining from assembly code embedded in the IMP source. Finally, the resulting assembly is passed to an assembler for conversion into executable code and then passed to a linker. |
|||
1.1 |
Tokens |
||
The compiler classifies tokens as: identifiers, reserved words, constants, and operators. Tokens are separated by white space, which is ignored in the source except as needed to separate sequences of tokens which would otherwise be ambiguous. |
|||
1.2 |
Reserved Words |
|||||||||||||||||||||||||||||||||||
The following keywords are reserved by the language and may not be used as identifiers:
|
||||||||||||||||||||||||||||||||||||
1.3 |
Grouping |
||||||||
IMP uses the following tokens for grouping:
|
|||||||||
1.4 |
Delimitors |
|||||
IMP uses the following tokens as delimitors:
|
||||||
1.5 |
Operators |
|||||||||||||||||||
IMP uses the following tokens as operators:
|
||||||||||||||||||||
1.6 |
Special |
||||||||
IMP uses the following tokens for special purposes:
|
|||||||||
1.7 |
Identifiers |
||
An identifier can be either a simple identifier or a qualified identifier. A simple identifier is any sequence of alpha-numeric characters and the underscore character _. Simple identifiers may not start with a digit. Simple identifiers are case sensitive. A qualified identifier consists of two or more simple identifiers joined by periods e.g. 'identifier1.identifier2' . |
|||
1.8 |
Constants |
||||||||
|
A number constant is signed natural number in base 10. For example, 7.0, -35, +5.5 are all signed natural numbers. Number constants have the type number. A base constant is a signed natural number in a specified base. The form of a base constant is as follows: the base reserved word followed by an open paren, the specific base, the number, and a close paren. For example, 17 in base 2 would be written base(2,1001). Base constants have the type number. A character constant contains one or more characters surrounded by single quote marks '. If the constant contains two or more characters the first must be the escape character \. The following table shows valid characters after an escape and the value of the constant:
Character constants have the type character. A string constant is a sequence of characters between double quote marks ". A string has the type `constant array of character'. The size operator applied to a string constant yields the size in characters. A logical constant can have one of two values; true or false.
|
|||||||||
Reference |
|||||||
|
|
1 Lexical |
2 Programs |
3 Declarations |
4 Expressions |
5 Statements |
6 Preprocessor |
7 EBNF |