--* From postmaster%watson.vnet.ibm.com@yktvmv.watson.ibm.com  Wed Jul 21 10:49:20 1993
--* Received: from yktvmv2.watson.ibm.com by radical.watson.ibm.com (AIX 3.2/UCB 5.64/900524)
--*           id AA19112; Wed, 21 Jul 1993 10:49:20 -0400
--* X-External-Networks: yes
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 1141; Wed, 21 Jul 93 10:50:26 EDT
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.EDWARDS.NOTE.YKTVMV.3765.Jul.21.10:50:24.-0400>
--*           for asbugs@watson; Wed, 21 Jul 93 10:50:25 -0400
--* Received: from ibm8.scri.fsu.edu by watson.ibm.com (IBM VM SMTP V2R3) with TCP;
--*    Wed, 21 Jul 93 10:50:23 EDT
--* Received: by ibm8.scri.fsu.edu id AA38169
--*   (5.65c/IDA-1.4.4 for asbugs@watson.ibm.com); Wed, 21 Jul 1993 10:50:21 -0400
--* Date: Wed, 21 Jul 1993 10:50:21 -0400
--* From: Robert Edwards <edwards@ibm8.scri.fsu.edu>
--* Message-Id: <199307211450.AA38169@ibm8.scri.fsu.edu>
--* To: asbugs@watson.ibm.com
--* Subject: compiler fails assertion (debug version: bug366.as) [adk_bug6.as][A# version 29.2 for AIX RS/6000 (debug version)]

--@ Fixed  by: SMW Sat Oct 09 15:02:32 1993
--@ Tested by: n/a
--@ Summary:   Reparied by previous fixes

--+ % asharp -rv adk_bug6.as
--+ A# version 29.2 for AIX RS/6000 (debug version)
--+ Assertion failed, file "../src/genfoam.c" line 946: gen0Self
--+ 16.240u 0.250s 0:45.98elap 35.8%cpu (646t+2307ds+2953avg+2484max)kb (0i+0o)ev (259maj+1116min)pf 0swaps
------------------------------ bug366.as ---------------------------------
--* From postmaster%watson.vnet.ibm.com@yktvmv.watson.ibm.com  Tue Jul 20 19:52:22 1993
--* Received: from yktvmv2.watson.ibm.com by radical.watson.ibm.com (AIX 3.2/UCB 5.64/900524)
--*           id AA14691; Tue, 20 Jul 1993 19:52:22 -0400
--* X-External-Networks: yes
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 2273; Tue, 20 Jul 93 19:53:27 EDT
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.ADK.NOTE.YKTVMV.5837.Jul.20.19:53:25.-0400>
--*           for asbugs@watson; Tue, 20 Jul 93 19:53:26 -0400
--* Received: from ibm4.scri.fsu.edu by watson.ibm.com (IBM VM SMTP V2R3) with TCP;
--*    Tue, 20 Jul 93 19:53:25 EDT
--* Received: by ibm4.scri.fsu.edu id AA12252
--*   (5.65c/IDA-1.4.4 for asbugs@watson.ibm.com); Tue, 20 Jul 1993 19:53:22 -0400
--* Date: Tue, 20 Jul 1993 19:53:22 -0400
--* From: Tony Kennedy <adk@ibm4.scri.fsu.edu>
--* Message-Id: <199307202353.AA12252@ibm4.scri.fsu.edu>
--* To: asbugs@watson.ibm.com
--* Subject: Compiler crashes with (segmentation violation). [bugs/bug6.as][A# version 29.2 for AIX RS/6000]

--@ Fixed  by: SMW Sat Oct 09 15:02:32 1993
--@ Tested by: n/a
--@ Summary:   Reparied by previous fixes

--+ ibm4::adk[632]> asharp -rv lexer.as
--+ A# version 29.2 for AIX RS/6000
--+ (Error) Program fault (segmentation violation).
--
-- Categorical description of a lexical analyzer
--

#include "aslib.as"

macro SI == SingleInteger

RegularExpression(Char: BasicType): Category == BasicType with

    coerce: Char -> %
    seq: Tuple % -> %
    alt: Tuple % -> %
    rpt: % -> %
--  next: (%, Char) -> %
    nextaa: (%, Char) -> %

RegExp: RegularExpression(String) == add

    macro State == SI
    macro Link == Record(char: String, next: State)
    macro Node == List Link
    macro Rep == Record(start: State, stop: State)

    import
      String
      Link
      Node
      Rep

    print("Creating domain RegExp")()

    macro maxNodes == 100
    macro void == "~"

    local table: Array Node == new(maxNodes, nil)
    local freeState: SI := 1

    addNode(n: Node): State ==
      free freeState := freeState + 1
      freeState > maxNodes => error("Too many nodes!")
      table.freeState := n
      freeState

    coerce(nextChar: String): % ==
      local end: State == addNode(nil)
      per [addNode(list [nextChar, end]), end]

    seq(t: Tuple %): % ==
      local begin: State := addNode(nil)
      local prev: State := begin
      for r: % in t repeat
        table.prev := list [void, (rep r).start]
        prev := (rep r).stop
      per [begin, prev]

    alt(t: Tuple %): % ==
      local begin: State := addNode(nil)
      local end: State := addNode(nil)
      for r: % in t repeat
        table.begin := cons( [void, (rep r).start], table.begin )
        table((rep r).stop) := list [void, end]
      per [begin, end]

    rpt(r: %): % ==
      local begin: State := (rep r).start
      local end: State := addNode(nil)
      table((rep r).stop) := list( [void, end], [void, begin] )
      per [begin, end]

    apply(p: Outport, r: %): Outport ==
      p("RegExp[")((rep r))("]")

print("Constructing RegExp...")()

r : RegExp == seq(coerce("a")@RegExp, coerce("b")@RegExp)

print("Printing RegExp...")()

print(r)()

print("Successfully finished!")()

 
