mentor/derived/ParseAlgClass.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:48:22 PST 1995 by kalsow  
      modified on Wed Feb 17 16:46:18 PST 1993 by johnh   
      modified on Thu Sep 24 10:59:20 PDT 1992 by mhb     

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file Parse.evt.
      ********************************************************************


MODULE ParseAlgClass;

<*NOWARN*> IMPORT Rd, ZeusClass, Fmt, Algorithm, Parse, Wr;
<*NOWARN*> IMPORT ZeusPanel, FormsVBT, VBT, Text, ZeusUtil;

<* PRAGMA LL *>
Fix any FormsVBT errors; don't handle exceptions for them.
<* FATAL FormsVBT.Error, FormsVBT.Unimplemented *>

REVEAL
  T = Public BRANDED OBJECT
      OVERRIDES
        <* LL = VBT.mu *>
        init := ParseDefaultInit;
        snapshot := ParseDefaultSnapshot;
        restore := ParseDefaultRestore;
        updateEventCounts := ParseDefaultUpdateCts;
      END;

PROCEDURE ParseDefaultInit (v: T): Algorithm.T =
  <* LL = VBT.mu *>
  PROCEDURE Attach (id: TEXT; proc: FormsVBT.Proc) =
    BEGIN
      FormsVBT.AttachProc(v.eventData, id, proc, v);
    END Attach;
  BEGIN
    v.eventData := ZeusPanel.NewForm("ParseEventData.fv");
    Attach("stopatCodeEvents", ParseDoIt);
    Attach("waitatCodeEvents", ParseDoIt);
    Attach("eventCounts", ParseRefreshCts);
    Attach("stopAtSetup", ParseDoIt);
    Attach("waitAtSetup", ParseDoIt);
    Attach("stopAtPush", ParseDoIt);
    Attach("waitAtPush", ParseDoIt);
    Attach("stopAtPop", ParseDoIt);
    Attach("waitAtPop", ParseDoIt);
    Attach("stopAtScan", ParseDoIt);
    Attach("waitAtScan", ParseDoIt);
    Attach("stopAtNoteError", ParseDoIt);
    Attach("waitAtNoteError", ParseDoIt);
    Attach("stopAtGoto", ParseDoIt);
    Attach("waitAtGoto", ParseDoIt);
    Attach("stopAtNewNode", ParseDoIt);
    Attach("waitAtNewNode", ParseDoIt);
    Attach("stopAtNewTerm", ParseDoIt);
    Attach("waitAtNewTerm", ParseDoIt);
    Attach("stopAtNewEdge", ParseDoIt);
    Attach("waitAtNewEdge", ParseDoIt);
    Attach("stopAtDeleteLeaf", ParseDoIt);
    Attach("waitAtDeleteLeaf", ParseDoIt);
    Attach("stopAtUpdateDone", ParseDoIt);
    Attach("waitAtUpdateDone", ParseDoIt);
    FromFV (v.eventData, v);    (* Get FV and internal data in sync *)
    RETURN Algorithm.T.init(v);
  END ParseDefaultInit;

PROCEDURE ParseDoIt (           fv : FormsVBT.T;
                           e  : TEXT;
                           arg: REFANY;
                <*UNUSED*> t  : VBT.TimeStamp) =
  <* LL = VBT.mu *>
  BEGIN
    IF Text.Equal(e, "stopatCodeEvents") THEN
      NARROW(arg, T).stopatCodeEvents :=
          FormsVBT.GetBoolean(fv, "stopatCodeEvents");
    END;
    IF Text.Equal(e, "waitatCodeEvents") THEN
      NARROW(arg, T).waitatCodeEvents :=
          FormsVBT.GetInteger(fv, "waitatCodeEvents");
    END;
    IF Text.Equal(e, "stopAtSetup") THEN
      NARROW(arg, T).eventDataRec.stopAtSetup :=
          FormsVBT.GetBoolean(fv, "stopAtSetup");
    END;
    IF Text.Equal(e, "waitAtSetup") THEN
      NARROW(arg, T).eventDataRec.waitAtSetup :=
          FormsVBT.GetInteger(fv, "waitAtSetup");
    END;
    IF Text.Equal(e, "stopAtPush") THEN
      NARROW(arg, T).eventDataRec.stopAtPush :=
          FormsVBT.GetBoolean(fv, "stopAtPush");
    END;
    IF Text.Equal(e, "waitAtPush") THEN
      NARROW(arg, T).eventDataRec.waitAtPush :=
          FormsVBT.GetInteger(fv, "waitAtPush");
    END;
    IF Text.Equal(e, "stopAtPop") THEN
      NARROW(arg, T).eventDataRec.stopAtPop :=
          FormsVBT.GetBoolean(fv, "stopAtPop");
    END;
    IF Text.Equal(e, "waitAtPop") THEN
      NARROW(arg, T).eventDataRec.waitAtPop :=
          FormsVBT.GetInteger(fv, "waitAtPop");
    END;
    IF Text.Equal(e, "stopAtScan") THEN
      NARROW(arg, T).eventDataRec.stopAtScan :=
          FormsVBT.GetBoolean(fv, "stopAtScan");
    END;
    IF Text.Equal(e, "waitAtScan") THEN
      NARROW(arg, T).eventDataRec.waitAtScan :=
          FormsVBT.GetInteger(fv, "waitAtScan");
    END;
    IF Text.Equal(e, "stopAtNoteError") THEN
      NARROW(arg, T).eventDataRec.stopAtNoteError :=
          FormsVBT.GetBoolean(fv, "stopAtNoteError");
    END;
    IF Text.Equal(e, "waitAtNoteError") THEN
      NARROW(arg, T).eventDataRec.waitAtNoteError :=
          FormsVBT.GetInteger(fv, "waitAtNoteError");
    END;
    IF Text.Equal(e, "stopAtGoto") THEN
      NARROW(arg, T).eventDataRec.stopAtGoto :=
          FormsVBT.GetBoolean(fv, "stopAtGoto");
    END;
    IF Text.Equal(e, "waitAtGoto") THEN
      NARROW(arg, T).eventDataRec.waitAtGoto :=
          FormsVBT.GetInteger(fv, "waitAtGoto");
    END;
    IF Text.Equal(e, "stopAtNewNode") THEN
      NARROW(arg, T).eventDataRec.stopAtNewNode :=
          FormsVBT.GetBoolean(fv, "stopAtNewNode");
    END;
    IF Text.Equal(e, "waitAtNewNode") THEN
      NARROW(arg, T).eventDataRec.waitAtNewNode :=
          FormsVBT.GetInteger(fv, "waitAtNewNode");
    END;
    IF Text.Equal(e, "stopAtNewTerm") THEN
      NARROW(arg, T).eventDataRec.stopAtNewTerm :=
          FormsVBT.GetBoolean(fv, "stopAtNewTerm");
    END;
    IF Text.Equal(e, "waitAtNewTerm") THEN
      NARROW(arg, T).eventDataRec.waitAtNewTerm :=
          FormsVBT.GetInteger(fv, "waitAtNewTerm");
    END;
    IF Text.Equal(e, "stopAtNewEdge") THEN
      NARROW(arg, T).eventDataRec.stopAtNewEdge :=
          FormsVBT.GetBoolean(fv, "stopAtNewEdge");
    END;
    IF Text.Equal(e, "waitAtNewEdge") THEN
      NARROW(arg, T).eventDataRec.waitAtNewEdge :=
          FormsVBT.GetInteger(fv, "waitAtNewEdge");
    END;
    IF Text.Equal(e, "stopAtDeleteLeaf") THEN
      NARROW(arg, T).eventDataRec.stopAtDeleteLeaf :=
          FormsVBT.GetBoolean(fv, "stopAtDeleteLeaf");
    END;
    IF Text.Equal(e, "waitAtDeleteLeaf") THEN
      NARROW(arg, T).eventDataRec.waitAtDeleteLeaf :=
          FormsVBT.GetInteger(fv, "waitAtDeleteLeaf");
    END;
    IF Text.Equal(e, "stopAtUpdateDone") THEN
      NARROW(arg, T).eventDataRec.stopAtUpdateDone :=
          FormsVBT.GetBoolean(fv, "stopAtUpdateDone");
    END;
    IF Text.Equal(e, "waitAtUpdateDone") THEN
      NARROW(arg, T).eventDataRec.waitAtUpdateDone :=
          FormsVBT.GetInteger(fv, "waitAtUpdateDone");
    END;
  END ParseDoIt;

PROCEDURE ParseRefreshCts (
                <*UNUSED*> fv  : FormsVBT.T;
                <*UNUSED*> e   : TEXT;
                           arg : REFANY;
                <*UNUSED*> t   : VBT.TimeStamp) =
  <* LL = VBT.mu *>
  BEGIN
    NARROW(arg, T).updateEventCounts(FALSE);
  END ParseRefreshCts;

PROCEDURE FromFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    alg.stopatCodeEvents :=
        FormsVBT.GetBoolean(fv, "stopatCodeEvents");
    alg.waitatCodeEvents :=
        FormsVBT.GetInteger(fv, "waitatCodeEvents");
    alg.eventDataRec.stopAtSetup :=
        FormsVBT.GetBoolean(fv, "stopAtSetup");
    alg.eventDataRec.waitAtSetup :=
        FormsVBT.GetInteger(fv, "waitAtSetup");
    alg.eventDataRec.stopAtPush :=
        FormsVBT.GetBoolean(fv, "stopAtPush");
    alg.eventDataRec.waitAtPush :=
        FormsVBT.GetInteger(fv, "waitAtPush");
    alg.eventDataRec.stopAtPop :=
        FormsVBT.GetBoolean(fv, "stopAtPop");
    alg.eventDataRec.waitAtPop :=
        FormsVBT.GetInteger(fv, "waitAtPop");
    alg.eventDataRec.stopAtScan :=
        FormsVBT.GetBoolean(fv, "stopAtScan");
    alg.eventDataRec.waitAtScan :=
        FormsVBT.GetInteger(fv, "waitAtScan");
    alg.eventDataRec.stopAtNoteError :=
        FormsVBT.GetBoolean(fv, "stopAtNoteError");
    alg.eventDataRec.waitAtNoteError :=
        FormsVBT.GetInteger(fv, "waitAtNoteError");
    alg.eventDataRec.stopAtGoto :=
        FormsVBT.GetBoolean(fv, "stopAtGoto");
    alg.eventDataRec.waitAtGoto :=
        FormsVBT.GetInteger(fv, "waitAtGoto");
    alg.eventDataRec.stopAtNewNode :=
        FormsVBT.GetBoolean(fv, "stopAtNewNode");
    alg.eventDataRec.waitAtNewNode :=
        FormsVBT.GetInteger(fv, "waitAtNewNode");
    alg.eventDataRec.stopAtNewTerm :=
        FormsVBT.GetBoolean(fv, "stopAtNewTerm");
    alg.eventDataRec.waitAtNewTerm :=
        FormsVBT.GetInteger(fv, "waitAtNewTerm");
    alg.eventDataRec.stopAtNewEdge :=
        FormsVBT.GetBoolean(fv, "stopAtNewEdge");
    alg.eventDataRec.waitAtNewEdge :=
        FormsVBT.GetInteger(fv, "waitAtNewEdge");
    alg.eventDataRec.stopAtDeleteLeaf :=
        FormsVBT.GetBoolean(fv, "stopAtDeleteLeaf");
    alg.eventDataRec.waitAtDeleteLeaf :=
        FormsVBT.GetInteger(fv, "waitAtDeleteLeaf");
    alg.eventDataRec.stopAtUpdateDone :=
        FormsVBT.GetBoolean(fv, "stopAtUpdateDone");
    alg.eventDataRec.waitAtUpdateDone :=
        FormsVBT.GetInteger(fv, "waitAtUpdateDone");
  END FromFV;

<*UNUSED*>
PROCEDURE ToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutBoolean(fv, "stopatCodeEvents", alg.stopatCodeEvents);
    FormsVBT.PutInteger(fv, "waitatCodeEvents", alg.waitatCodeEvents);
    FormsVBT.PutBoolean(fv, "stopAtSetup",
                        alg.eventDataRec.stopAtSetup);
    FormsVBT.PutInteger(fv, "waitAtSetup",
                        alg.eventDataRec.waitAtSetup);
    FormsVBT.PutBoolean(fv, "stopAtPush",
                        alg.eventDataRec.stopAtPush);
    FormsVBT.PutInteger(fv, "waitAtPush",
                        alg.eventDataRec.waitAtPush);
    FormsVBT.PutBoolean(fv, "stopAtPop",
                        alg.eventDataRec.stopAtPop);
    FormsVBT.PutInteger(fv, "waitAtPop",
                        alg.eventDataRec.waitAtPop);
    FormsVBT.PutBoolean(fv, "stopAtScan",
                        alg.eventDataRec.stopAtScan);
    FormsVBT.PutInteger(fv, "waitAtScan",
                        alg.eventDataRec.waitAtScan);
    FormsVBT.PutBoolean(fv, "stopAtNoteError",
                        alg.eventDataRec.stopAtNoteError);
    FormsVBT.PutInteger(fv, "waitAtNoteError",
                        alg.eventDataRec.waitAtNoteError);
    FormsVBT.PutBoolean(fv, "stopAtGoto",
                        alg.eventDataRec.stopAtGoto);
    FormsVBT.PutInteger(fv, "waitAtGoto",
                        alg.eventDataRec.waitAtGoto);
    FormsVBT.PutBoolean(fv, "stopAtNewNode",
                        alg.eventDataRec.stopAtNewNode);
    FormsVBT.PutInteger(fv, "waitAtNewNode",
                        alg.eventDataRec.waitAtNewNode);
    FormsVBT.PutBoolean(fv, "stopAtNewTerm",
                        alg.eventDataRec.stopAtNewTerm);
    FormsVBT.PutInteger(fv, "waitAtNewTerm",
                        alg.eventDataRec.waitAtNewTerm);
    FormsVBT.PutBoolean(fv, "stopAtNewEdge",
                        alg.eventDataRec.stopAtNewEdge);
    FormsVBT.PutInteger(fv, "waitAtNewEdge",
                        alg.eventDataRec.waitAtNewEdge);
    FormsVBT.PutBoolean(fv, "stopAtDeleteLeaf",
                        alg.eventDataRec.stopAtDeleteLeaf);
    FormsVBT.PutInteger(fv, "waitAtDeleteLeaf",
                        alg.eventDataRec.waitAtDeleteLeaf);
    FormsVBT.PutBoolean(fv, "stopAtUpdateDone",
                        alg.eventDataRec.stopAtUpdateDone);
    FormsVBT.PutInteger(fv, "waitAtUpdateDone",
                        alg.eventDataRec.waitAtUpdateDone);
    CountsToFV (fv, alg);
  END ToFV;

PROCEDURE CountsToFV (fv : FormsVBT.T; alg: T) =
  <* LL = VBT.mu *>
  BEGIN
    FormsVBT.PutText(fv, "ctOfSetup",
                        Fmt.Int(alg.eventDataRec.ctOfSetup));
    FormsVBT.PutText(fv, "ctOfPush",
                        Fmt.Int(alg.eventDataRec.ctOfPush));
    FormsVBT.PutText(fv, "ctOfPop",
                        Fmt.Int(alg.eventDataRec.ctOfPop));
    FormsVBT.PutText(fv, "ctOfScan",
                        Fmt.Int(alg.eventDataRec.ctOfScan));
    FormsVBT.PutText(fv, "ctOfNoteError",
                        Fmt.Int(alg.eventDataRec.ctOfNoteError));
    FormsVBT.PutText(fv, "ctOfGoto",
                        Fmt.Int(alg.eventDataRec.ctOfGoto));
    FormsVBT.PutText(fv, "ctOfNewNode",
                        Fmt.Int(alg.eventDataRec.ctOfNewNode));
    FormsVBT.PutText(fv, "ctOfNewTerm",
                        Fmt.Int(alg.eventDataRec.ctOfNewTerm));
    FormsVBT.PutText(fv, "ctOfNewEdge",
                        Fmt.Int(alg.eventDataRec.ctOfNewEdge));
    FormsVBT.PutText(fv, "ctOfDeleteLeaf",
                        Fmt.Int(alg.eventDataRec.ctOfDeleteLeaf));
    FormsVBT.PutText(fv, "ctOfUpdateDone",
                        Fmt.Int(alg.eventDataRec.ctOfUpdateDone));
  END CountsToFV;

PROCEDURE ParseDefaultUpdateCts ( v: T; reset: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    IF reset THEN
      v.eventDataRec.ctOfSetup := 0;
      v.eventDataRec.ctOfPush := 0;
      v.eventDataRec.ctOfPop := 0;
      v.eventDataRec.ctOfScan := 0;
      v.eventDataRec.ctOfNoteError := 0;
      v.eventDataRec.ctOfGoto := 0;
      v.eventDataRec.ctOfNewNode := 0;
      v.eventDataRec.ctOfNewTerm := 0;
      v.eventDataRec.ctOfNewEdge := 0;
      v.eventDataRec.ctOfDeleteLeaf := 0;
      v.eventDataRec.ctOfUpdateDone := 0;
    END;
    CountsToFV (v.eventData, v);
  END ParseDefaultUpdateCts;

PROCEDURE ParseDefaultSnapshot (v: T; wr: Wr.T)
  RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TRY
      Wr.PutChar(wr, '(')
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "ParseAlgClass.ParseDefaultSnapshot write error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "ParseAlgClass.ParseDefaultSnapshot: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.snapshot(wr)
    EXCEPT
      FormsVBT.Error (msg) =>
        RAISE ZeusClass.Error(
          "ParseAlgClass.ParseDefaultSnapshot FV error: "
          & msg);
    ELSE
      RAISE ZeusClass.Error(
        "ParseAlgClass.ParseDefaultSnapshot error");
    END;
    Algorithm.T.snapshot(v, wr);
    TRY
      Wr.PutChar(wr, ')')
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "ParseAlgClass.ParseDefaultSnapshot write error");
    END;
  END ParseDefaultSnapshot;

PROCEDURE ParseDefaultRestore (v: T; rd: Rd.T)
  RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    IF rd = NIL THEN RETURN END;
    IF NOT ZeusUtil.EatChar(rd, '(') THEN
      RAISE ZeusClass.Error(
          "ParseAlgClass.ParseDefaultRestore read error");
    END;
    IF v.eventData = NIL THEN
      RAISE ZeusClass.Error(
          "ParseAlgClass.ParseDefaultRestore: " &
          "eventData not set!");
    END;
    TRY
      v.eventData.restore(rd);
      v.updateEventCounts(FALSE);
      FromFV(v.eventData, v);
    EXCEPT
    ELSE
      RAISE ZeusClass.Error(
          "ParseAlgClass.ParseDefaultRestore error");
    END;
    Algorithm.T.restore(v, rd);
    IF NOT ZeusUtil.EatChar(rd, ')') THEN
      RAISE ZeusClass.Error(
          "ParseAlgClass.ParseDefaultRestore read error");
    END;
  END ParseDefaultRestore;

BEGIN
END ParseAlgClass.

interface Parse is in: