Contents | Prev |
Next | Index
Vocabulary and Representation
Pascal represents its terminal symbols in terms of characters using
the ASCII set. Symbols are identifiers, numbers, strings, operators, and
delimiters. Blanks and line breaks must not occur within symbols (except
for blanks in strings). They are are ignored unless they are essential to
separate two consecutive symbols. Pascal makes no distinction between upper-case
and lower-case letters for identifiers and keywords. However, Java does.
If a Pascal symbol is newly introduced for the first time, e.g. in a declaration,
Java uses its case sensitive spelling for future references, while Pascal
can later reference that symbol in a case insensitive manner.
Here is how the terminal symbols are defined:
-
Identifiers
are sequences of letters and digits. The first character must not be a digit.
This compiler also accepts underscore ('_') characters in an identifier
sequence.
-
Numbers are unsigned
integer or real constants. The type of an integer constant is the minimal
type to which the constant value belongs (see
basic types). If the constant is specified
with the prefix '$', the representation is hexadecimal; otherwise it is
decimal.
A real number always contains a decimal point or a scale factor. The letter
'E' or 'e' introduces the scale factor portion and means "times ten to the
power of". A real number is of SINGLE
type, unless a bigger scale factor or mantissa requires it to be of type
DOUBLE.
number = integer | real
integer = digit {digit} |
"$" hex_digit {hex_digit}
real = digit {digit} fraction {scale_factor} |
digit {digit} {fraction} scale_factor
fraction = "." digit {digit}
scale_factor = ("E"|"e") ["+"|"-"] digit {digit}
hex_digit = digit |
"A"|"B"|"C"|"D"|"E"|"F" |
"a"|"b"|"c"|"d"|"e"|"f"
digit = "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
Examples:
1991 |
WORD or SMALLINT |
1991 |
$DH |
BYTE or SHORTINT |
13 |
12.3 |
SINGLE |
12.3 |
4.567E8 |
SINGLE |
456700000 |
-
Character
constants are denoted by the ordinal number of the character with
a '#' prefix. There must be no space between the prefix and the
number.
character = "#" number
-
Strings are character
sequences enclosed by apostrophes. A character string with nothing between
the apostrophes is a null string. Two sequential apostrophes in a character
string denote a single apostrophe within that string.The number of characters
in the string is called its length. A one-character string can be used whereever
a character is allowed and vice versa.
string = "'" {char} "'"
Examples:
'Pascal'
'Don''t worry'
'x'
-
Operators and
delimiters are of special characters, character pairs,
or reserved words. The reserved words cannot be redefined. The character
pair "(." is equivalent to the opening bracket "[", and ".)" is equivalent
to the closing bracket "]". Likewise, a left brace "{" is equivalent to the
character pair "(*", and a right brace "}" is equivalent to the character
pair "*)".
+ |
- |
|
AND |
EXPORTS |
LIBRARY |
SHL |
* |
/ |
ARRAY |
FILE |
MOD |
SHR |
= |
<> |
AS |
FINALIZATION |
|
STRING |
< |
> |
ASM |
FINALLY |
NOT |
THEN |
<= |
>= |
BEGIN |
FOR |
OBJECT |
THREADVAR |
. |
, |
CASE |
FUNCTION |
OF |
TO |
: |
; |
CLASS |
GOTO |
OR |
TRY |
^ |
@ |
CONST |
IF |
PACKED |
TYPE |
$ |
# |
CONSTRUCTOR |
IMPLEMENTATION |
PROCEDURE |
UNIT |
:= |
.. |
DESTRUCTOR |
IN |
PROGRAM |
UNTIL |
[ |
] |
DIV |
INHERITED |
PROPERTY |
USES |
( |
) |
DO |
INITIALIZATION |
RAISE |
VAR |
(* |
*) |
DOWNTO |
|
RECORD |
WHILE |
{ |
} |
ELSE |
INTERFACE |
REPEAT |
WITH |
(. |
.) |
END |
IS |
SET |
XOR |
// |
|
EXCEPT |
LABEL |
|
Unlike other Pascal compilers such as Borland Object Pascal, Canterbury
Pascal does NOT treat the following symbols as reserved words:
-
Standard
directives act like reserved words in certain language contexts.
Unlike reserved words, they can be redefined in other places, but it is strongly
advised not to do so.
ABSTRACT |
NAME |
PUBLISHED |
AUTOMATED |
OVERRIDE |
REGISTER |
CDECL |
PASCAL |
RESIDENT |
DYNAMIC |
PRIVATE |
STDCALL |
FORWARD |
PROTECTED |
VIRTUAL |
INDEX |
PUBLIC |
|
Unlike Borland Object Pascal, Canterbury Pascal does NOT treat the following
symbols as standard directives or reserved words:
ABSOLUTE |
FAR |
READ |
DEFAULT |
MESSAGE |
STORED |
DISPID |
NEAR |
WRITE |
EXPORT |
NODEFAULT |
|
-
Comments
may be inserted between any two symbols in a program. They are (almost) arbitrary
character sequences opened by the left bracket "(*" and closed by the right
bracket "*)". Comments may also be opened and closed by the curly braces
"{" and "}". Comments may be nested once if the inner pair of comment brackets
or braces differs from the outer pair of comment brackets or braces. Comments
do not affect the meaning of a program.
This compiler recognizes certain comment-embedded
directives which give the compiler some
hints on how to perform its compilation.
Contents | Prev |
Next | Index
Canterbury Pascal for JVM (Last documentation update
Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com
. All rights reserved.
Please send any comments or corrections to
neuhoff@mhccorp.com