All of the parsing and lexical analysis in AMC is done by one common section of code within the compiler. Not only does this make AMC smaller and easier to maintain and it requires a developer using AMC to become familiar with only one set of lexical conventions.
Comments begin with a /* and end with a */,
just like in ANSI-C. Comments are equivilant to whitespace and have no
effect on the input. Unlike ANSI-C,
however, comments can nest.
Example:
/* Hello /* from AMC! */ */
Strings can be delimited by either a single quote (') or a
double quote (") character. All characters following the initial
quote character until the next quote character matching the one that opened
the string are part of the string. Strings can contain quoted characters
like in C (using the \ character
like in C):
Note: Unlike C, the ASCII NUL character (value 0) is not permissable in a string.
It is also possible to represent extremely long strings by following them together, for example:
"This is a very long " "string that talks about a clock " "that went ding dong " "as I tried to talk."
will be treated by AMC as a single string that is a concatenation of the various string components.
An integer constant can be either signed or unsigned determined by the context in which the integer is required. A signed integer may be preceeded by a minus sign. Integer constants can be represented in three bases (as in C):
0x<hex digits>0<octal digits>Where:
Any of the following characters: 0123456789ABCDEFabcdef.
Any of the following characters: 01234567.
Any of the following characters: 0123456789.
Identifiers can begin with an alphabetic or underscore character (_) and
may contain alphabetic, numeric, or the underscore characters for the second
and subsequent characters. An alphabetic character is defined as
A through
Z and a through z (case is always significant).
Because AMC is a preprocessor for other source languages it is necessary to be able to construct identifiers out of any character (because the host language might support them). In order to do this, AMC allows an identifier to be constructed from a string literal:
id("This is my identifier")