Super Prev Next

Vocabulary and Representation

The representation of (terminal) symbols in terms of characters is defined using the ASCII set. Symbols are identifiers, numbers, strings, operators, and delimiters. The following lexical rules must be observed: Blanks and line breaks must not occur within symbols (except in comments, and blanks in strings). They are ignored unless they are essential to separate two consecutive symbols. Capital and lower-case letters are considered as distinct.


Super Prev Next

1.

Identifiers are sequences of letters and digits. The first character must be a letter.

  ident = letter {letter | digit}.

Examples:

  x   Scan   Oberon2   GetSymbol   firstLetter


Super Prev Next

2.

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 suffix H, the representation is hexadecimal otherwise the representation is decimal.

A real number always contains a decimal point. Optionally it may also contain a decimal scale factor. The letter E (or D) means "times ten to the power of". A real number is of type REAL, unless it has a scale factor containing the letter D. In this case it is of type LONGREAL.

  number      = integer | real.
  integer     = digit {digit} | digit{hexDigit}"H".
  real        = digit{digit}"."{digit} [ScaleFactor].
  ScaleFactor = ("E" | "D") ["+" | "-"] digit {digit}.
  hexDigit    = digit |"A"|"B"|"C"|"D"|"E"|"F".
  digit       = "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9".

Examples:

  1991           INTEGER          1991
  0DH            SHORTINT         13
  12.3           REAL             12.3
  4.567E8        REAL             456700000
  0.57712566D-6  LONGREAL         0.00000057712566


Super Prev Next

3.

Character constants are denoted by the ordinal number of the character in hexadecimal notation followed by the letter X.

  character = digit {hexDigit} "X".


Super Prev Next

4.

Strings are sequences of characters enclosed in single (') or double (") quote marks. The opening quote must be the same as the closing quote and must not occur within the string. The number of characters in a string is called its length. A string of length 1 can be used wherever a character constant is allowed and vice versa.

  string = '"' {char} '"' | "'" {char} "'".

Examples:

  "Oberon-2"     "Don't worry!"   "x"


Super Prev Next

5.

Operators and delimiters are the special characters, character pairs, or reserved words listed below. The reserved words consist exclusively of capital letters and cannot be used as identifiers.

  +         :=         ARRAY    IMPORT     RETURN
  -         ^          BEGIN    IN         THEN
  *         =          BY       IS         TO
  /         #          CASE     LOOP       TYPE
  ~         <          CONST    MOD        UNTIL
  &         >          DIV      MODULE     VAR
  .         <=         DO       NIL        WHILE
  ,         >=         ELSE     OF         WITH
  ;         ..         ELSIF    OR
  |         :          END      POINTER
  (         )          EXIT     PROCEDURE
  [         ]          FOR      RECORD
  {         }          IF       REPEAT


Super Prev Next

6.

Comments may be inserted between any two symbols in a program. They are arbitrary character sequences opened by the bracket (* and closed by *). Comments may be nested. They do not affect the meaning of a program.