tl.def

来自「一个Modula-2语言分析器」· DEF 代码 · 共 44 行

DEF
44
字号
DEFINITION MODULE TL;

CONST
  vars = 0;
  procs = 1;
  scopes = 2;

  undef = 0;
  int   = 1;
  bool  = 2;  (* types *)

TYPE
  Object = POINTER TO Objectnode;
  Objectnode = RECORD
    name: ARRAY[0..15] OF CHAR; (* name of the object *)
    type: INTEGER;              (* type of the object (undef for procs) *)
    next: Object;               (* to next object in same scope *)
    CASE kind: INTEGER OF
        vars, procs:
          adr:     INTEGER;     (* address in memory or start of proc *)
          level:   INTEGER;     (* nesting level of declaration *)
      | scopes:
          locals:  Object;      (* to locally declared objects *)
          nextAdr: INTEGER;     (* next free address in this scope *)
      ELSE
    END;
  END;

VAR
  undefObj: Object;   (* object node for erroneous symbols *)
  curLevel: INTEGER;  (* nesting level of current scope *)

PROCEDURE EnterScope;

PROCEDURE LeaveScope;

PROCEDURE DataSpace (): INTEGER;

PROCEDURE NewObj (name: ARRAY OF CHAR; kind: INTEGER): Object;

PROCEDURE Obj (name: ARRAY OF CHAR): Object;

END TL.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?