Tokens for the language ICPL
Reserved Words
-
program
-
identifier
-
begin
-
end
-
integer
-
if
-
then
-
elseif
-
else
-
loop
-
when
-
exit
-
get
-
put
-
putln
-
not
-
and note: not a token
-
or note: not a token
-
mod note: not a token
Operators (according to precidence level, highest first)
-
exp_op ^
-
mult_op * | /
-
add_op + | -
-
rel_op = | < | >
| <= | >= | #
-
bool_op and | or
Symbol tokens
; , :=
( )
Constants
let char-d be the set of all ASCII characters except a double quote.
let char-s be the set of all ASCII characters except a single quote.
let digit be the set of digits from 0 to 9.
-
str_const = ' char-s* ' | " char-d* " note:
a string constant may not extend beyond a line. Thus if a string
constant that is started and not terminated prior to the end of a
line is considered to be in error.
-
int_const = digit digit* note: while a digit may be
of any length, if it causes an overflow it will be considered to be in
error. An int_const will be terminated with an operator, a symbol
or a space. It may not be terminated with a letter.
Identifiers
let letter be the 52 letters of the alphabet (upper or lower case letters
will be considered distinct)
let digit be the 10 digits
-
identifier = letter (letter | digit)* note: an identifier
can have any length. However, only the first 63 are to be significant.
An identifier will be terminated with an operator, a symbol or a space.
Comments and Spaces
Blank characters, tab characters, and end of line characters will all be
considered to be spaces. Two or more consecutive spaces are to be
considered as a single space. Spaces are not tokens, but may separate
tokens. No token may contain an embedded space, thus a space will
terminate any token.
A comment may take on either of the following forms:
-
line comment: '--' will start a line comment. The end of the
line will terminate the comment.
-
block comment: '{' will start a block comment. '}' or the end of
the file will end a block comment. Block comments may extend over
any number of lines. Block comments may not be nested.
A comment, either line or block, will be treated as a single space.