[Oberon] Intermediate scopes in Oberon-07

Diego Sardina dsar at eml.cc
Sun Feb 25 01:12:46 CET 2018


I have 4 - 5 books about Compilers in Pascal and Modula-2 and the procedures Term, Factor and SimpleExpression are *always* nested inside Expression. But they aren't in Project Oberon.
Are these authors just fools because they used a such (in your opinion) useless technique? I don't think so.

Saying more, these nested procedures don't even need intermediate global procedures, so they can be nested also in Oberon-07 (2016).
The parser of expressions is a very GOOD example where nested procedures are ELEGANT and makes sense. Factor, Term and SimpleExpression don't make any sense in the global scope.


(* This code is properly formatted with a fixed-width font *)

PROCEDURE Expression(...);

  PROCEDURE SimpleExpression(...);

    PROCEDURE Term(...);

      PROCEDURE Factor(...);
      BEGIN
        (* Strictly locals/globals : Factor, Expression.     *)
        (* Intemediate globals     : Term, SimpleExpression. *)
        (* Used                    : Factor, Expression.     *)
      END Factor;

    BEGIN (* Term *)
      (* Strictly locals/globals : Term, Factor, Expression. *)
      (* Intermediate globals    : SimpleExpression.         *)
      (* Used                    : Factor.                   *)
    END Term;

  BEGIN (* SimpleExpression *)
    (* Strictly locals/globals : SimpleExpression, Term, Expression. *)
    (* Intermediate globals    : (none)                              *)
    (* Used                    : Term.                               *)
  END SimpleExpression;

BEGIN (* Expression *)
  (* Strictly locals/globals : SimpleExpression, Expression. *)
  (* Intermediate globals    : (none)                        *)
  (* Used                    : SimpleExpression.             *)
END Expression;


More information about the Oberon mailing list