Added Structured Dagger in langs.
authorMilind Bhandarkar <milind@cs.uiuc.edu>
Sun, 3 May 1998 08:24:46 +0000 (08:24 +0000)
committerMilind Bhandarkar <milind@cs.uiuc.edu>
Sun, 3 May 1998 08:24:46 +0000 (08:24 +0000)
52 files changed:
src/langs/sdag/doc/example1/Makefile.html [new file with mode: 0644]
src/langs/sdag/doc/example1/index.html [new file with mode: 0644]
src/langs/sdag/doc/example1/main.C.html [new file with mode: 0644]
src/langs/sdag/doc/example1/main.ci.html [new file with mode: 0644]
src/langs/sdag/doc/example1/main.h.html [new file with mode: 0644]
src/langs/sdag/doc/example1/test.C.html [new file with mode: 0644]
src/langs/sdag/doc/example1/test.ci.html [new file with mode: 0644]
src/langs/sdag/doc/example1/test.h.html [new file with mode: 0644]
src/langs/sdag/doc/example1/test.sdag.html [new file with mode: 0644]
src/langs/sdag/doc/grammar.html [new file with mode: 0644]
src/langs/sdag/examples/ex0/ex0.sdag [new file with mode: 0644]
src/langs/sdag/examples/ex1/ex1.sdag [new file with mode: 0644]
src/langs/sdag/examples/ex2/ex2.sdag [new file with mode: 0644]
src/langs/sdag/examples/ex3/ex3.sdag [new file with mode: 0644]
src/langs/sdag/examples/ex4/ex4.sdag [new file with mode: 0644]
src/langs/sdag/examples/ex5/ex5.sdag [new file with mode: 0644]
src/langs/sdag/examples/lu/lu.sdag [new file with mode: 0644]
src/langs/sdag/examples/ring/ring.sdag [new file with mode: 0644]
src/langs/sdag/runtime/CCounter.h [new file with mode: 0644]
src/langs/sdag/runtime/CDep.C [new file with mode: 0644]
src/langs/sdag/runtime/CDep.h [new file with mode: 0644]
src/langs/sdag/runtime/CMsgBuffer.h [new file with mode: 0644]
src/langs/sdag/runtime/CWhenTrigger.h [new file with mode: 0644]
src/langs/sdag/runtime/Makefile.runtime [new file with mode: 0644]
src/langs/sdag/runtime/TList.h [new file with mode: 0644]
src/langs/sdag/runtime/TStrideArray.h [new file with mode: 0644]
src/langs/sdag/runtime/sdag.h [new file with mode: 0644]
src/langs/sdag/xlator/CEntry.C [new file with mode: 0644]
src/langs/sdag/xlator/CEntry.h [new file with mode: 0644]
src/langs/sdag/xlator/CLexer.C [new file with mode: 0644]
src/langs/sdag/xlator/CLexer.h [new file with mode: 0644]
src/langs/sdag/xlator/CList.h [new file with mode: 0644]
src/langs/sdag/xlator/CParseNode.C [new file with mode: 0644]
src/langs/sdag/xlator/CParseNode.h [new file with mode: 0644]
src/langs/sdag/xlator/CParseNodeProcess.C [new file with mode: 0644]
src/langs/sdag/xlator/CParsedFile.C [new file with mode: 0644]
src/langs/sdag/xlator/CParsedFile.h [new file with mode: 0644]
src/langs/sdag/xlator/CParser.C [new file with mode: 0644]
src/langs/sdag/xlator/CParser.h [new file with mode: 0644]
src/langs/sdag/xlator/CStateVar.h [new file with mode: 0644]
src/langs/sdag/xlator/CString.h [new file with mode: 0644]
src/langs/sdag/xlator/CToken.h [new file with mode: 0644]
src/langs/sdag/xlator/EToken.h [new file with mode: 0644]
src/langs/sdag/xlator/Makefile.xlator [new file with mode: 0644]
src/langs/sdag/xlator/example.txt [new file with mode: 0644]
src/langs/sdag/xlator/grammar.txt [new file with mode: 0644]
src/langs/sdag/xlator/sdag-globals.C [new file with mode: 0644]
src/langs/sdag/xlator/sdag-globals.h [new file with mode: 0644]
src/langs/sdag/xlator/sdag-main.C [new file with mode: 0644]
src/langs/sdag/xlator/trans.c [new file with mode: 0644]
src/langs/sdag/xlator/trans.l [new file with mode: 0644]
src/scripts/Makefile

diff --git a/src/langs/sdag/doc/example1/Makefile.html b/src/langs/sdag/doc/example1/Makefile.html
new file mode 100644 (file)
index 0000000..6602705
--- /dev/null
@@ -0,0 +1,41 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>Makefile</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+<B><TT><FONT SIZE=+1>INC=-I../../runtime</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>LIB=-L../../runtime</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>all: cifiles <FONT COLOR="#CC0000">sdagfiles </FONT>pgm</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>cifiles:</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; charmxi
+main.ci</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; charmxi
+test.ci</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>sdagfiles:</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#CC0000">sdagx
+test.sdag</FONT></FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>pgm: main.o test.o</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; charmc
+-g -language charm++ -o pgm main.o test.o $(LIB) <FONT COLOR="#CC0000">-lsdag</FONT></FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>main.o: main.C main.h</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; charmc
+-g -c main.C $(INC)</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>test.o: test.C test.h</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; charmc
+-g -c test.C $(INC)</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>clean:</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rm
+-f pgm *.o <FONT COLOR="#CC0000">test.sdag.h test.sdag.C</FONT> *.top.h
+*.bot.h</FONT></TT></B>
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/doc/example1/index.html b/src/langs/sdag/doc/example1/index.html
new file mode 100644 (file)
index 0000000..5eb936e
--- /dev/null
@@ -0,0 +1,42 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>Example Structured Dagger Program</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+
+<CENTER>
+<H1>
+Example of a Structured Dagger Program</H1></CENTER>
+
+<H2>
+What does it do ?</H2>
+
+
+<P><FONT SIZE=+1><TT><FONT COLOR="#CC0000">main </FONT></TT>chare gets
+created. It then creates a <TT><FONT COLOR="#CC0000">test </FONT></TT>chare.
+<TT><FONT COLOR="#CC0000">main </FONT></TT>then invokes the <FONT COLOR="#CC0000"><U>sdagentry
+</U><TT>teststart</TT></FONT>, and sends 1000 messages with appropriate
+reference number set. the <TT><FONT COLOR="#CC0000">teststart </FONT></TT>entry
+function of <TT><FONT COLOR="#CC0000">test </FONT></TT>chare waits in <U><FONT COLOR="#CC0000">forall
+</FONT></U>loop for messages with appropriate reference numbers, and adds
+the data member of the messages to a member of the chare called <TT><FONT COLOR="#CC0000">sum</FONT></TT>.
+After all the messages arrive, it prints out the <TT><FONT COLOR="#CC0000">sum
+</FONT></TT>and exits program.</FONT>
+<BR>&nbsp;
+<H2>
+Files:</H2>
+
+
+<P><FONT SIZE=+1><A HREF="Makefile.html">Makefile</A></FONT>
+<BR><FONT SIZE=+1><A HREF="main.C.html">main.C</A></FONT>
+<BR><FONT SIZE=+1><A HREF="main.h.html">main.h</A></FONT>
+<BR><FONT SIZE=+1><A HREF="main.ci.html">main.ci</A></FONT>
+<BR><FONT SIZE=+1><A HREF="test.sdag.html">test.sdag</A></FONT>
+<BR><FONT SIZE=+1><A HREF="test.C.html">test.C</A></FONT>
+<BR><FONT SIZE=+1><A HREF="test.h.html">test.h</A></FONT>
+<BR><FONT SIZE=+1><A HREF="test.ci.html">test.ci</A></FONT>
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/doc/example1/main.C.html b/src/langs/sdag/doc/example1/main.C.html
new file mode 100644 (file)
index 0000000..58ca52e
--- /dev/null
@@ -0,0 +1,53 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>main.C</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+<B><TT><FONT SIZE=+1>#include "ckdefs.h"</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>#include "chare.h"</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>#include "c++interface.h"</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>#include "main.top.h"</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>#include "main.h"</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>#include "test.top.h"</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>main::main(int argc, char **argv)</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>{</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; int i, j;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; // create Test chare</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; TestMsg *msg = new (MsgIndex(TestMsg))
+TestMsg;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; ChareIDType testChare;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; new_chare2(Test, msg, &amp;testChare, 0);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; // send message to teststart</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; msg = new (MsgIndex(TestMsg)) TestMsg;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; CSendMsg(Test, teststart, msg, &amp;testChare);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; for(i=1;i&lt;=100;i++) {</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; for(j=10;j>=1;j--) {</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Msg *msg = new (MsgIndex(Msg))
+Msg;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetRefNumber(msg,
+i);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg->data = i;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSendMsg(Test,
+entry1, msg, &amp;testChare);</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg = new (MsgIndex(Msg))
+Msg;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetRefNumber(msg,
+j);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg->data = j;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSendMsg(Test,
+entry2, msg, &amp;testChare);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; }</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; }</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>}</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>#include "main.bot.h"</FONT></TT></B>
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/doc/example1/main.ci.html b/src/langs/sdag/doc/example1/main.ci.html
new file mode 100644 (file)
index 0000000..63496ec
--- /dev/null
@@ -0,0 +1,16 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>main.ci</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+<B><TT><FONT SIZE=+1>extern message TestMsg;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>extern message Msg;</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>chare main {</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; entry main();</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>};</FONT></TT></B>
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/doc/example1/main.h.html b/src/langs/sdag/doc/example1/main.h.html
new file mode 100644 (file)
index 0000000..79e8807
--- /dev/null
@@ -0,0 +1,18 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>main.h</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+<B><TT><FONT SIZE=+1>#include "test.h"</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>class main : public chare_object</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>{</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; public:</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; main(int argc, char **argv);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>};</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1></FONT></TT></B>&nbsp;
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/doc/example1/test.C.html b/src/langs/sdag/doc/example1/test.C.html
new file mode 100644 (file)
index 0000000..dd39033
--- /dev/null
@@ -0,0 +1,18 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>test.C</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+<B><TT><FONT SIZE=+1>#include "test.top.h"</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>#include "test.h"</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT COLOR="#CC0000"><FONT SIZE=+1>#include "test.sdag.C"</FONT></FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>#include "test.bot.h"</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1></FONT></TT></B>&nbsp;
+<BR><B><TT><FONT SIZE=+1></FONT></TT></B>&nbsp;
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/doc/example1/test.ci.html b/src/langs/sdag/doc/example1/test.ci.html
new file mode 100644 (file)
index 0000000..879a2a1
--- /dev/null
@@ -0,0 +1,19 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>test.ci</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+<B><TT><FONT SIZE=+1>message TestMsg;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>message Msg;</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>chare Test {</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; entry Test(TestMsg *);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; entry teststart(TestMsg *);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; entry entry1(Msg *);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; entry entry2(Msg *);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>};</FONT></TT></B>
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/doc/example1/test.h.html b/src/langs/sdag/doc/example1/test.h.html
new file mode 100644 (file)
index 0000000..e53d54d
--- /dev/null
@@ -0,0 +1,35 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>test.h</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+<B><TT><FONT SIZE=+1>#include "sdag.h"</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>class TestMsg : public comm_object</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>{</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; public:</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; int dummy;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>};</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>class Msg : public comm_object</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>{</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; public:</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; int data;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>};</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>class Test : public chare_object</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>{</FONT></TT></B>
+<BR><B><TT><FONT COLOR="#CC0000"><FONT SIZE=+1>#include "test.sdag.h"</FONT></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; public:</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; int sum;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; int j[100];</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; Test(TestMsg *msg) {</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#CC0000">__sdag_init();</FONT></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum = 0;</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; }</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>};</FONT></TT></B>
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/doc/example1/test.sdag.html b/src/langs/sdag/doc/example1/test.sdag.html
new file mode 100644 (file)
index 0000000..10c6b74
--- /dev/null
@@ -0,0 +1,39 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>test.sdag</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+<B><TT><FONT SIZE=+1><FONT COLOR="#CC0000">class </FONT>Test</FONT></TT></B><B><TT><FONT SIZE=+1></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1><FONT COLOR="#CC0000">sdagentry </FONT>teststart
+(TestMsg *msg) {</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; <FONT COLOR="#CC0000">atomic </FONT>{</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; CPrintf("Starting forall loops\n");</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; }</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; <FONT COLOR="#CC0000">forall</FONT>[i]
+(1:100,1) {</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; <FONT COLOR="#CC0000">for </FONT>(j[i-1]=1;j[i-1]&lt;=10;j[i-1]++)
+{</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#CC0000">when
+</FONT>entry1[i](Msg *m1),entry2[j[i-1]](Msg *m2) {</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#CC0000">atomic
+</FONT>{</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+CPrintf("processing entry1[%d] &amp; entry2[%d]\n", i, j[i-1]);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+sum += (m1->data * m2->data);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; }</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; }</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; <FONT COLOR="#CC0000">atomic </FONT>{</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; CPrintf("Ended forall loops.
+Sum = %d\n", sum);</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp; CharmExit();</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; }</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>}</FONT></TT></B>
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/doc/grammar.html b/src/langs/sdag/doc/grammar.html
new file mode 100644 (file)
index 0000000..76483f4
--- /dev/null
@@ -0,0 +1,78 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="Author" CONTENT="Milind Bhandarkar">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.02 [en] (X11; I; IRIX 6.3 IP32) [Netscape]">
+   <TITLE>Structured Dagger: Grammar</TITLE>
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FE0000">
+
+<CENTER>
+<H1>
+<U><FONT COLOR="#CC0000">Structured Dagger: Grammar</FONT></U></H1></CENTER>
+&nbsp;
+<H2>
+<FONT COLOR="#000099"><B>Tokens</B>:</FONT></H2>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B><TT><FONT SIZE=+1>&lt;ident> = Valid
+C++ identifier</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; &lt;int-expr> = Valid C++ integer expression</FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp; &lt;c++-code> = Valid C++ code</FONT></TT></B>
+<BR>&nbsp;
+<BR>&nbsp;
+<H2>
+<FONT COLOR="#000099">Grammar in EBNF Form:</FONT></H2>
+<B><TT><FONT SIZE=+1>&lt;sdag> := &lt;class-decl> &lt;sdagentry>+</FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;class-decl> := "class" &lt;ident></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;sdagentry> := "sdagentry" &lt;ident> "(" &lt;ident>
+"*" &lt;ident> ")" &lt;body></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;body> := &lt;stmt></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | "{"
+&lt;stmt>+ "}"</FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;stmt> := &lt;overlap-stmt></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;when-stmt></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;atomic-stmt></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;if-stmt></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;while-stmt></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;for-stmt></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;forall-stmt></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;overlap-stmt> := "overlap" &lt;body></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;atomic-stmt> := "atomic" "{" &lt;c++-code>
+"}"</FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;if-stmt> := "if" "(" &lt;int-expr> ")" &lt;body>
+[&lt;else-stmt>]</FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;else-stmt> := "else" &lt;body></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;while-stmt> := "while" "(" &lt;int-expr> ")"
+&lt;body></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;for-stmt> := "for" "(" &lt;c++-code> ";" &lt;int-expr>
+";" &lt;c++-code> ")" &lt;body></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;forall-stmt> := "forall" "[" &lt;ident> "]"
+"(" &lt;range-stride> ")" &lt;body></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;range-stride> := &lt;int-expr> ":" &lt;int-expr>
+"," &lt;int-expr></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;when-stmt> := "when" &lt;entry-list>&nbsp;
+&lt;body></FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;entry-list> := &lt;entry></FONT></TT></B>
+<BR><B><TT><FONT SIZE=+1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+| &lt;entry> [ "," &lt;entry-list> ]</FONT></TT></B>
+
+<P><B><TT><FONT SIZE=+1>&lt;entry> := &lt;ident> [ "[" &lt;int-expr> "]"
+] "(" &lt;ident> "*" &lt;ident> ")"</FONT></TT></B>
+<BR>&nbsp;
+<BR>&nbsp;
+<BR>&nbsp;
+</BODY>
+</HTML>
diff --git a/src/langs/sdag/examples/ex0/ex0.sdag b/src/langs/sdag/examples/ex0/ex0.sdag
new file mode 100644 (file)
index 0000000..0aa558d
--- /dev/null
@@ -0,0 +1,16 @@
+class example1
+sdagentry init (INIT *m)
+{
+  atomic
+  { 
+    initialize(m); 
+    i = 0;
+    j = 1;
+  }
+  when rcv(MSG *m1)
+    atomic{process(m1);}
+  atomic { i++; }
+  atomic { j++; }
+  atomic { i--; }
+}
+
diff --git a/src/langs/sdag/examples/ex1/ex1.sdag b/src/langs/sdag/examples/ex1/ex1.sdag
new file mode 100644 (file)
index 0000000..c5df0fc
--- /dev/null
@@ -0,0 +1,21 @@
+class example1
+sdagentry init (INIT *m)
+{
+  atomic { initialize(m); }
+  overlap
+  {
+    when e1(MSGTYPE1 *m1)
+      atomic {c1(m1);}
+    when e2(MSGTYPE2 *m2)
+      atomic {c2(m2);}
+    {
+      when e3(MSGTYPE *m3)
+        atomic {c3(m3);}
+      when e4(MSGTYPE *m4)
+        atomic {c4(m4);}
+    }
+  }
+  when e3(MSGTYPE *m3)
+    atomic{c3(m3);}
+}
+
diff --git a/src/langs/sdag/examples/ex2/ex2.sdag b/src/langs/sdag/examples/ex2/ex2.sdag
new file mode 100644 (file)
index 0000000..027c20f
--- /dev/null
@@ -0,0 +1,12 @@
+class mult_chare
+sdagentry init(MSG *msg)
+{
+  atomic
+  {
+    MyChareID(&mychareid);
+    TblFind(ATable, msg->row_index, recv_row, &mychareid, TBL_NEVER_WAIT);
+    TblFind(BTable, msg->col_index, revc_col, &mychareid, TBL_NEVER_WAIT);
+  }
+  when recv_row(TBL_MSG *row), recv_col(TBL_MSG *col)
+    atomic { multiply(row->data, col->data); }
+}
diff --git a/src/langs/sdag/examples/ex3/ex3.sdag b/src/langs/sdag/examples/ex3/ex3.sdag
new file mode 100644 (file)
index 0000000..7190db1
--- /dev/null
@@ -0,0 +1,27 @@
+class jacobi
+
+sdagentry init(MSGINIT *msg)
+{
+  atomic {
+    initialize();
+    convdone = FALSE;
+  }
+  while(!convdone) {
+    atomic {
+      for (dir=0; dir<4; dir++) {
+        m[dir] = copy_boundary(dir);
+        SendMsgBranch(entry_no[dir],m[dir],nbr[dir]);
+      }
+    }
+    when NORTH(BOUNDARY *north), SOUTH(BOUNDARY *south), 
+         EAST(BOUNDARY *east), WEST(BOUNDARY *west) {
+      atomic {
+        update(north, south, east, west);
+        reduction(my_conv, CONVERGE, &mycid);
+      }
+    }
+    when CONVERGE(CONV *conv)
+      atomic{convdone = conv->done;}
+  }
+  atomic { print_results(); }
+}
diff --git a/src/langs/sdag/examples/ex4/ex4.sdag b/src/langs/sdag/examples/ex4/ex4.sdag
new file mode 100644 (file)
index 0000000..7f9619d
--- /dev/null
@@ -0,0 +1,29 @@
+class Harlow_Welch
+
+sdagentry init(MSGINIT *msg)
+{
+  atomic { initialize(); }
+  forall[i](0:Z-1,1)
+    atomic { convdone[i] = FALSE; }
+  forall[i](0:Z-1,1) {
+    while(!convdone[i]) {
+      atomic {
+        for (dir=0; dir<4; dir++) {
+          m[i][dir] = copy_boundary(i,dir);
+          SendMsgBranch(entry_no[dir],m[i][dir],nbr[i][dir]);
+        }
+      }
+      when NORTH(BOUNDARY *north), SOUTH(BOUNDARY *south), 
+           EAST(BOUNDARY *east), WEST(BOUNDARY *west) {
+        atomic {
+          update(i, north, south, east, west);
+          reduction(my_conv, i, CONVERGE, &mycid);
+        }
+      }
+      when CONVERGE[i](CONV *conv)
+        atomic{convdone[i] = conv->done;}
+    }
+  }
+  atomic { print_results(); }
+}
+
diff --git a/src/langs/sdag/examples/ex5/ex5.sdag b/src/langs/sdag/examples/ex5/ex5.sdag
new file mode 100644 (file)
index 0000000..2b21dc8
--- /dev/null
@@ -0,0 +1,24 @@
+class example 
+
+sdagentry sample (M *msg)
+{
+  atomic{
+    i=0;
+    MyChareID(&thisID);
+    buf1 = (M *) CkAllocMsg(M);
+    SendMsg(ep1, buf1, &thisID);
+    buf1 = (M *) CkAllocMsg(M);
+    SendMsg(ep3, buf1, &thisID);
+    buf1 = (M *) CkAllocMsg(M);
+    SendMsg(ep2, buf1, &thisID);
+  }
+  overlap {
+    when ep1(M *m1), ep2(M *m2) {
+      atomic { i++; }
+    }
+    when ep3(M *m3) {
+      atomic { i += 2; }
+    }
+  }
+  atomic{CkPrintf("i = %d\n");}
+}
diff --git a/src/langs/sdag/examples/lu/lu.sdag b/src/langs/sdag/examples/lu/lu.sdag
new file mode 100644 (file)
index 0000000..34b5847
--- /dev/null
@@ -0,0 +1,89 @@
+class cube
+
+sdagentry iterations (InitMessage *mesg)
+{
+  atomic {
+    Initialization(); 
+    SendMessage(xmnbr,rhs_entry_xp1,xmmsg); 
+    SendMessage(xpnbr,rhs_entry_xm1,xpmsg);
+    SendMessage(ymnbr,rhs_entry_yp1,ymmsg); 
+    SendMessage(ypnbr,rhs_entry_ym1,ypmsg);
+    SendMessage(zmnbr,rhs_entry_zp1,zmmsg); 
+    SendMessage(zpnbr,rhs_entry_zm1,zpmsg);
+  }
+  while(iter<maxiter) {
+    atomic { rhs_init(); }
+    overlap {
+      when rhs_entry_xm1(Boundary *xm1), 
+           rhs_entry_xp1(Boundary *xp1) {
+        atomic {rhs_x(xm1,xp1);}
+      }
+      when rhs_entry_ym1(Boundary *ym1), 
+           rhs_entry_yp1(Boundary *yp1) {
+        atomic {rhs_y(ym1,yp1); }
+      }
+      when rhs_entry_zm1(Boundary *zm1), 
+           rhs_entry_yp1(Boundary *zp1) {
+        atomic {rhs_z(zm1,zp1); }
+      }
+    }
+    if(x==0 && y==0 && z==0) {
+      atomic {
+        SendMessage(xpnbr,XmBoundary,xmsg);
+        SendMessage(ypnbr,YmBoundary,ymsg);
+        SendMessage(zpnbr,ZmBoundary,zmsg);
+      }
+    }
+    overlap {
+      when XmBoundary(Boundary *xmmsg) {
+        atomic {CopyMessageX(xmmsg); }
+      }
+      when YmBoundary(Boundary *ymmsg) {
+        atomic {CopyMessageY(ymmsg); }
+      }
+      when ZmBoundary(Boundary *zmmsg) {
+        atomic {CopyMessageZ(zmmsg); }
+      }
+    }
+    atomic {
+      blts();
+      jacld();
+      SendMessage(xpnbr);
+      SendMessage(ypnbr);
+      SendMessage(zpnbr);
+    }
+    if(x==maxx && y==maxy && z==maxz) {
+      atomic {
+        SendMessage(xmnbr,XpBoundary,xmsg);
+        SendMessage(ymnbr,YpBoundary,ymsg);
+        SendMessage(zmnbr,ZpBoundary,zmsg);
+      }
+    }
+    overlap {
+      when XpBoundary(Boundary *xmsg) {
+        atomic {CopyMessageX(xmsg); }
+      }
+      when YpBoundary(Boundary *ymsg) {
+        atomic {CopyMessageY(ymsg); }
+      }
+      when ZpBoundary(Boundary *zmsg) {
+        atomic {CopyMessageZ(zmsg); }
+      }
+    }
+    atomic {
+      buts();
+      jacu();
+      SendMessage(xmnbr);
+      SendMessage(xpnbr);
+      SendMessage(xpnbr);
+      updateu();
+      SendMessage(xmnbr,rhs_entry_xp1,xmmsg); 
+      SendMessage(xpnbr,rhs_entry_xm1,xpmsg);
+      SendMessage(ymnbr,rhs_entry_yp1,ymmsg); 
+      SendMessage(ypnbr,rhs_entry_ym1,ypmsg);
+      SendMessage(zmnbr,rhs_entry_zp1,zmmsg); 
+      SendMessage(zpnbr,rhs_entry_zm1,zpmsg);
+      iter++;
+    }
+  }
+}
diff --git a/src/langs/sdag/examples/ring/ring.sdag b/src/langs/sdag/examples/ring/ring.sdag
new file mode 100644 (file)
index 0000000..d89fd1e
--- /dev/null
@@ -0,0 +1,20 @@
+class example 
+sdagentry sample (M *msg)
+{
+  atomic {
+    i=0;
+    MyChareID(&thisID);
+    buf1 = (M *) CkAllocMsg(M);
+    SendMsg(ep1, buf1, &thisID);
+  }
+  while(i<NITER)
+  {
+    when ep1(M *m1){
+      atomic {SendMsg(ep2, m1, &thisID);}
+    }
+    when ep2(M *m2) {
+      atomic{SendMsg(ep1, m2, &thisID);}
+    }
+    atomic { i++; }
+  }
+}
diff --git a/src/langs/sdag/runtime/CCounter.h b/src/langs/sdag/runtime/CCounter.h
new file mode 100644 (file)
index 0000000..27f640c
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _CCounter_H_
+#define _CCounter_H_
+
+class CCounter {
+  private:
+    unsigned int count;
+  public:
+    CCounter(int c) : count(c) {}
+    CCounter(int first, int last, int stride) {
+      count = ((last-first)/stride)+1;
+    }
+    void decrement(void) {count--;}
+    int isDone(void) {return (count==0);}
+};
+
+#endif
diff --git a/src/langs/sdag/runtime/CDep.C b/src/langs/sdag/runtime/CDep.C
new file mode 100644 (file)
index 0000000..37f3d6e
--- /dev/null
@@ -0,0 +1,79 @@
+#include "CDep.h"
+
+// called by when function
+void CDep::Register(CWhenTrigger *trigger)
+{
+  whens[trigger->whenID]->append(trigger);
+}
+
+// called by entry function
+void CDep::deRegister(CWhenTrigger *trigger)
+{
+  whens[trigger->whenID]->remove(trigger);
+}
+
+// called by entry function
+void CDep::bufferMessage(int entry, void *msg, int refnum)
+{
+  CMsgBuffer *buf = new CMsgBuffer(entry, msg, refnum);
+  buffers[entry]->append(buf);
+  return;
+}
+
+// called by when function
+CMsgBuffer *CDep::getMessage(int entry)
+{
+  return buffers[entry]->front();
+}
+
+// called by when function
+CMsgBuffer *CDep::getMessage(int entry, int refnum)
+{
+  TListCMsgBuffer *list = buffers[entry];
+  for(CMsgBuffer *elem=list->begin(); !list->end(); elem=list->next()) {
+    if(elem==0)
+      return 0;
+    if(elem->refnum == refnum)
+      return elem;
+  }
+  return 0;
+}
+
+// called by when function
+void CDep::removeMessage(CMsgBuffer *msg)
+{
+  TListCMsgBuffer *list = buffers[msg->entry];
+  list->remove(msg);
+}
+
+// called by entry funcion
+int CDep::depSatisfied(CWhenTrigger *trigger)
+{
+  for(int i=0;i<trigger->nEntries;i++) {
+    if(!getMessage(trigger->entries[i], trigger->refnums[i]))
+      return 0;
+  }
+  for(i=0;i<trigger->nAnyEntries;i++) {
+    if(!getMessage(trigger->anyEntries[i]))
+      return 0;
+  }
+  return 1;
+}
+
+// called by entry function
+CWhenTrigger *CDep::getTrigger(int entry, int refnum)
+{
+  for(int i=0;i<numEntryDepends[entry];i++) {
+    TListCWhenTrigger *wlist = entryDepends[entry][i];
+    for(CWhenTrigger *elem=wlist->begin(); !wlist->end(); elem=wlist->next()) {
+      if(elem==0)
+        break;
+      if(depSatisfied(elem)){
+         deRegister(elem);
+         return elem;
+      }
+    }
+  }
+  return 0;
+}
+
diff --git a/src/langs/sdag/runtime/CDep.h b/src/langs/sdag/runtime/CDep.h
new file mode 100644 (file)
index 0000000..4a77c1c
--- /dev/null
@@ -0,0 +1,91 @@
+#ifndef _CDep_H_
+#define _CDep_H_
+
+/**
+ This class hides all the details of dependencies between
+ when blocks and entries. It also contains the entry buffers
+ and when triggers.
+*/
+
+#include <stddef.h> // for size_t
+#include "CMsgBuffer.h"
+#include "CWhenTrigger.h"
+#include "TList.h"
+
+class CDep {
+   int numEntries, numWhens;
+   TListCWhenTrigger **whens;
+   TListCMsgBuffer **buffers;
+   int *numWhenDepends;
+   int *numEntryDepends;
+   TListCMsgBuffer ***whenDepends;
+   TListCWhenTrigger ***entryDepends;
+ public:
+   CDep(int ne, int nw) : numEntries(ne), numWhens(nw)
+   {
+     // initialize the internal data structures here
+     whens = new TListCWhenTrigger *[numWhens];
+     buffers = new TListCMsgBuffer *[numEntries];
+     numWhenDepends = new int[numWhens];
+     numEntryDepends = new int[numEntries];
+     whenDepends = new TListCMsgBuffer **[numWhens];
+     entryDepends = new TListCWhenTrigger **[numEntries];
+     int i;
+     for(i=0;i<numWhens;i++) {
+       whens[i] = new TListCWhenTrigger();
+       whenDepends[i] = new TListCMsgBuffer *[numEntries];
+       numWhenDepends[i] = 0;
+     }
+     for(i=0;i<numEntries;i++) {
+       buffers[i] = new TListCMsgBuffer();
+       entryDepends[i] = new TListCWhenTrigger *[numWhens];
+       numEntryDepends[i] = 0;
+     }
+   }
+
+   // adds a dependency of whenID upon Entry
+   // done only at initialization.
+   void addDepends(int whenID, int entry) {
+     whenDepends[whenID][numWhenDepends[whenID]++] = buffers[entry];
+     entryDepends[entry][numEntryDepends[entry]++] = whens[whenID];
+   }
+
+   // register a trigger to be called with
+   // with <nEntries> specified
+   // in <entries> with corresponding <refnums>
+   void Register(CWhenTrigger *trigger);
+
+   // deregister trigger from all
+   // the entries it is registered for
+   void deRegister(CWhenTrigger *trigger);
+
+   // buffer a message for a specific entry point with a specified
+   // reference number
+   void bufferMessage(int entry, void *msg, int refnum);
+
+   // For a specified entry number and reference number,
+   // get the registered trigger which satisfies dependency. 
+   // If no trigger exists
+   // for the given reference number, get the trigger registered for
+   // ANY ref num. If that also doesnt exist, Return NULL
+   CWhenTrigger *getTrigger(int entry, int refnum);
+
+   // given the entry number and reference number,
+   // get the buffered message, without removing it from
+   // the list, NULL if no such message exists
+   CMsgBuffer *getMessage(int entry, int refnum);
+
+   // given the entry number,
+   // get the buffered message, without removing it from
+   // the list, NULL if no such message exists
+   // note that this is the ANY case
+   CMsgBuffer *getMessage(int entry);
+
+   // remove the given message from buffer
+   void removeMessage(CMsgBuffer *msg);
+
+   // return 1 if all the dependeces for trigger are satisfied
+   // return 0 otherwise
+   int depSatisfied(CWhenTrigger *trigger);
+};
+#endif
diff --git a/src/langs/sdag/runtime/CMsgBuffer.h b/src/langs/sdag/runtime/CMsgBuffer.h
new file mode 100644 (file)
index 0000000..f5fa8c1
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef _CMsgBufer_H_
+#define _CMsgBufer_H_
+
+class CMsgBuffer {
+  public:
+    int entry;
+    void *msg;
+    int refnum;
+    CMsgBuffer *next;
+    CMsgBuffer(int e, void *m, int r) : entry(e), msg(m), refnum(r) {}
+};
+
+#endif
diff --git a/src/langs/sdag/runtime/CWhenTrigger.h b/src/langs/sdag/runtime/CWhenTrigger.h
new file mode 100644 (file)
index 0000000..080f060
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef _CWhenTrigger_H_
+#define _CWhenTrigger_H_
+
+#include <stddef.h> // for size_t
+
+#define MAXARG 8
+#define MAXANY 8
+#define MAXREF 8
+
+class CWhenTrigger {
+  public:
+    int whenID, nArgs;
+    size_t args[MAXARG];
+    int nAnyEntries;
+    int anyEntries[MAXANY];
+    int nEntries;
+    int entries[MAXREF];
+    int refnums[MAXREF];
+    CWhenTrigger *next;
+    CWhenTrigger(int id, int na, int ne, int nae) :
+       whenID(id), nArgs(na), nEntries(ne), nAnyEntries(nae){}
+};
+#endif
diff --git a/src/langs/sdag/runtime/Makefile.runtime b/src/langs/sdag/runtime/Makefile.runtime
new file mode 100644 (file)
index 0000000..dfad94b
--- /dev/null
@@ -0,0 +1,8 @@
+libsdag.a: CDep.o
+       ar r libsdag.a CDep.o
+
+CDep.o: CDep.C CDep.h CMsgBuffer.h CWhenTrigger.h
+       charmc -c -O CDep.C
+
+clean:
+       rm -rf ptrepository ii_files *.o *.a  *.ii
diff --git a/src/langs/sdag/runtime/TList.h b/src/langs/sdag/runtime/TList.h
new file mode 100644 (file)
index 0000000..39d68d9
--- /dev/null
@@ -0,0 +1,147 @@
+#ifndef _TList_H_
+#define _TList_H_
+
+#include <stdio.h>
+#include "CWhenTrigger.h"
+#include "CMsgBuffer.h"
+
+// Quick and dirty List for small numbers of items.
+// It should ideally be a template, but in order to have portability,
+// we would make it two lists
+
+class TListCWhenTrigger
+{
+  private:
+
+    CWhenTrigger *first, *last;
+    CWhenTrigger *current;
+
+  public:
+
+    TListCWhenTrigger(void) : first(0), last(0) {;}
+
+    int empty(void) { return ! first; }
+    
+    CWhenTrigger *begin(void) {
+      return (current = first);
+    }
+
+    int end(void) {
+      return (current == 0);
+    }
+
+    CWhenTrigger *next (void) {
+      return (current = current->next);
+    }
+
+    CWhenTrigger *front(void)
+    {
+      return first;
+    }
+
+    void remove(CWhenTrigger *data)
+    {
+      // case 1: empty list
+      if (first == 0)
+        return;
+      // case 2: first element to be removed
+      if(first == data) {
+        first = first->next;
+       if(first==0) last=0;
+        return;
+      }
+      // case 3: middle or last element to be removed
+      CWhenTrigger *nn;
+      CWhenTrigger *prev = first;
+      for(nn=first->next; nn; nn = nn->next) {
+        if (nn == data) {
+          prev->next = nn->next;
+         if(nn==last)
+           last=prev;
+          return;
+        }
+        prev = nn;
+      }
+    }
+
+    void append(CWhenTrigger *data)
+    {
+      data->next = 0;
+      if(first == 0) {
+        last = first = data;
+      } else {
+        last->next = data;
+       last = last->next;
+      }
+    }
+};
+
+class TListCMsgBuffer
+{
+  private:
+
+    CMsgBuffer *first, *last;
+    CMsgBuffer *current;
+
+  public:
+
+    TListCMsgBuffer(void) : first(0), last(0) {;}
+
+    int empty(void) { return ! first; }
+    
+    CMsgBuffer *begin(void) {
+      return (current = first);
+    }
+
+    int end(void) {
+      return (current == 0);
+    }
+
+    CMsgBuffer *next (void) {
+      return (current = current->next);
+    }
+
+    CMsgBuffer *front(void)
+    {
+      return first;
+    }
+
+    void remove(CMsgBuffer *data)
+    {
+      // case 1: empty list
+      if (first == 0)
+        return;
+      // case 2: first element to be removed
+      if(first == data) {
+        first = first->next;
+       if(first==0) last=0;
+        return;
+      }
+      // case 3: middle or last element to be removed
+      CMsgBuffer *nn;
+      CMsgBuffer *prev = first;
+      for(nn=first->next; nn; nn = nn->next) {
+        if (nn == data) {
+          prev->next = nn->next;
+         if(nn==last)
+           last=prev;
+          return;
+        }
+        prev = nn;
+      }
+    }
+
+    void append(CMsgBuffer *data)
+    {
+      data->next = 0;
+      if(first == 0) {
+        last = first = data;
+      } else {
+        last->next = data;
+       last = last->next;
+      }
+    }
+};
+
+#endif
+
diff --git a/src/langs/sdag/runtime/TStrideArray.h b/src/langs/sdag/runtime/TStrideArray.h
new file mode 100644 (file)
index 0000000..e5c016e
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef _TStrideArray_H_
+#define _TStrideArray_H_
+
+template <class T> 
+class TStrideArray {
+  private:
+    T *array;
+    int start, end, stride;
+  public:
+    TStrideArray<T>(int s, int e, int st=1) {
+      int size = (e-s+1)/st;
+      array = new T[size];
+      start = s; end = e; stride = st;
+    }
+    T& operator[](int idx) {
+      return array[(idx-start)/stride];
+    }
+    ~TStrideArray<T>(void) {
+      delete[] array;
+    }
+};
+
+#endif
diff --git a/src/langs/sdag/runtime/sdag.h b/src/langs/sdag/runtime/sdag.h
new file mode 100644 (file)
index 0000000..df7f1b8
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef _sdag_H_
+#define _sdag_H_
+
+#include "charm++.h"
+
+#include "CDep.h"
+#include "CCounter.h"
+
+// returns count of values from starting and ending value
+// considering stride.
+
+static int __getCount(int start, int end, int stride)
+{
+  return (((end-start)/stride)+1);
+}
+
+static void __swap(int *x, int *y)
+{
+  int tmp = *x;
+  *x = *y;
+  *y = tmp;
+}
+
+#endif
diff --git a/src/langs/sdag/xlator/CEntry.C b/src/langs/sdag/xlator/CEntry.C
new file mode 100644 (file)
index 0000000..f4b3fc6
--- /dev/null
@@ -0,0 +1,67 @@
+#include "CEntry.h"
+#include "CParseNode.h"
+
+void CEntry::generateDeps(void)
+{
+  CParseNode *cn;
+  for(cn=(CParseNode *)whenList->begin(); !whenList->end(); cn=(CParseNode *)whenList->next()) {
+    pH(2, "__cDep->addDepends(%d, %d);\n", cn->nodeNum, entryNum);
+  }
+}
+
+void CEntry::generateCode(CString *className)
+{
+  // header file
+  pH(1,"void %s(%s *);\n", entry->charstar(), msgType->charstar());
+
+  CParseNode *cn;
+  // C++ file
+  pC(0, "void %s::%s(%s *msg) {\n",
+              className->charstar(),
+              entry->charstar(),
+              msgType->charstar());
+  // actual code begins
+  pC(1,"CWhenTrigger *tr;\n");
+  if(refNumNeeded) {
+    pC(1,"int refnum = GetRefNumber(msg);\n");
+    pC(1,"__cDep->bufferMessage(%d, (void *) msg, refnum);\n", entryNum);
+    pC(1,"tr = __cDep->getTrigger(%d, refnum);\n", entryNum);
+  } else {
+    pC(1,"__cDep->bufferMessage(%d, (void *) msg, 0);\n", entryNum);
+    pC(1,"tr = __cDep->getTrigger(%d, 0);\n", entryNum);
+  }
+  pC(1,"if (tr == 0)\n");
+  pC(2,"return;\n");
+  if(whenList->length() == 1) {
+    cn = (CParseNode *)whenList->begin();
+    pC(1,"%s(", cn->label->charstar());
+    CStateVar *sv = (CStateVar *)cn->stateVars->begin();
+    int i = 0;
+    for(; i<(cn->stateVars->length());i++, sv=(CStateVar *)cn->stateVars->next()) {
+      if(i!=0)
+        pC(0,", ");
+      pC(0,"(%s) tr->args[%d]", sv->type->charstar(), i);
+    }
+    pC(0,");\n");
+    pC(1,"return;\n");
+  } else {
+    pC(1,"switch(tr->whenID) {\n");
+    for(cn=(CParseNode *)whenList->begin(); !whenList->end(); cn=(CParseNode *)whenList->next()) {
+      pC(2,"case %d:\n", cn->nodeNum);
+      pC(3,"%s(", cn->label->charstar());
+      CStateVar *sv = (CStateVar *)cn->stateVars->begin();
+      int i = 0;
+      for(; i<(cn->stateVars->length());i++, sv=(CStateVar *)cn->stateVars->next()) {
+        if(i!=0)
+          pC(0,", ");
+        pC(0,"(%s) tr->args[%d]", sv->type->charstar(), i);
+      }
+      pC(0,");\n");
+      pC(3,"return;\n");
+    }
+    pC(1,"}\n");
+  }
+  // actual code ends
+  pC(0,"}\n\n");
+}
+
diff --git a/src/langs/sdag/xlator/CEntry.h b/src/langs/sdag/xlator/CEntry.h
new file mode 100644 (file)
index 0000000..186f1b5
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef _CEntry_H_
+#define _CEntry_H_
+
+#include "CString.h"
+#include "sdag-globals.h"
+#include "CList.h"
+
+class CParseNode;
+
+class CEntry{
+  public:
+    CString *entry;
+    CString *msgType;
+    int entryNum;
+    int refNumNeeded;
+    TList *whenList;
+    CEntry(CString *e, CString *m) : entry(e), msgType(m) {
+      entryNum = numEntries++;
+      whenList = new TList();
+      refNumNeeded=0;
+    }
+    void print(int indent) {
+      Indent(indent);
+      printf("entry %s (%s *)", entry->charstar(), msgType->charstar());
+    }
+    void generateCode(CString *);
+    void generateDeps(void);
+    
+};
+#endif
diff --git a/src/langs/sdag/xlator/CLexer.C b/src/langs/sdag/xlator/CLexer.C
new file mode 100644 (file)
index 0000000..930e4fc
--- /dev/null
@@ -0,0 +1,164 @@
+#include "CLexer.h"
+#include <stdlib.h>
+
+CLexer::CLexer(void)
+{
+  lineNum = 1;
+  charNum = 1;
+  wsSignificant = 0;
+}
+
+CLexer::~CLexer(void)
+{
+}
+
+int CLexer::sourceFile(char *filename)
+{
+  FILE *fp;
+  if((fp=fopen(filename, "r"))==(FILE *)0)
+    return 0;
+  fclose(fp);
+  freopen(filename, "r", stdin);
+  return 1;
+}
+
+CToken *CLexer::lookAhead(void)
+{
+  while(1) {
+    CToken *cToken = getNextToken();
+    if(cToken==0)
+      return cToken;
+    if(cToken->type == NEW_LINE) {
+      delete cToken;
+      continue;
+    } else {
+      char *yycopy = strdup(yytext);
+      for(int i=strlen(yycopy)-1; i>=0; i-- ) {
+        charNum--;
+        Unput(yycopy[i]) ;
+      }
+      free(yycopy);
+      return cToken;
+    }
+  }
+  return (CToken *) 0;
+}
+
+CToken *CLexer::getNextToken(void)
+{
+  EToken type;
+  CToken *cToken;
+
+  while(1) {
+    type = yylex();
+    if ((int)type == 0)
+      return (CToken *) 0;
+    charNum += strlen(yytext);
+    if(type == NEW_LINE) {
+      lineNum++;
+      charNum = 1;
+      if (wsSignificant)
+        return new CToken(type, yytext);
+      else
+        continue;
+    }
+    if((type != WSPACE) || wsSignificant) {
+      cToken = new CToken(type, yytext);
+      // cToken->print(0);
+      return cToken;
+    }
+  }
+}
+
+CToken *CLexer::getBracedCode(void)
+{
+  CToken *code = new CToken(BRACE_MATCHED_CPP_CODE, "{ ");
+  int currentScope = 1;
+  wsSignificant = 1;
+  // Code to eat C++ code
+  while(currentScope != 0) {
+    CToken *cToken = getNextToken();
+    if(cToken==0)
+      return cToken;
+    if(cToken->type == LBRACE) {
+      currentScope++;
+    }
+    if(cToken->type == RBRACE) {
+      currentScope--;
+    }
+    code->text->append(cToken->text);
+    delete cToken;
+  }
+  wsSignificant = 0;
+  return code;
+}
+
+CToken *CLexer::getParenCode(void)
+{
+  CToken *code = new CToken(BRACE_MATCHED_CPP_CODE, "( ");
+  int currentScope = 1;
+  wsSignificant = 1;
+  // Code to eat C++ code
+  while(currentScope != 0) {
+    CToken *cToken = getNextToken();
+    if(cToken==0)
+      return cToken;
+    if(cToken->type == LP) {
+      currentScope++;
+    }
+    if(cToken->type == RP) {
+      currentScope--;
+    }
+    code->text->append(cToken->text);
+    delete cToken;
+  }
+  wsSignificant = 0;
+  return code;
+}
+
+CToken *CLexer::getIntExpr(EToken term)
+{
+  CToken *expr = new CToken(INT_EXPR, "");
+  unsigned int endExpr = 0;
+  unsigned int numBraces=(term==RBRACE)?1:0;
+  unsigned int numParens=(term==RP)?1:0;
+  unsigned int numBrackets=(term==RB)?1:0;
+  wsSignificant = 1;
+  while(!endExpr) {
+    CToken *cToken = getNextToken();
+    if(cToken==0)
+      return cToken;
+    switch(cToken->type) {
+      case LP:
+        numParens++;
+        break;
+      case RP:
+        numParens--;
+        break;
+      case LB:
+        numBrackets++;
+        break;
+      case RB:
+        numBrackets--;
+        break;
+      case LBRACE:
+        numBraces++;
+        break;
+      case RBRACE:
+        numBraces--;
+        break;
+    }
+    if(cToken->type == term && !numBraces && !numParens && !numBrackets) {
+      for(int i=strlen(yytext)-1; i>=0; i-- ) {
+        charNum--;
+        Unput(yytext[i]) ;
+      }
+      endExpr = 1;
+    } else {
+      expr->text->append(cToken->text);
+    }
+    delete cToken;
+  }
+  wsSignificant = 0;
+  return expr;
+}
diff --git a/src/langs/sdag/xlator/CLexer.h b/src/langs/sdag/xlator/CLexer.h
new file mode 100644 (file)
index 0000000..a130eef
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef _CLexer_H_
+#define _CLexer_H_
+
+#include <stdio.h>
+#include "CToken.h"
+#include "sdag-globals.h"
+
+extern "C" EToken yylex();
+extern char *yytext;
+extern "C" void Unput(char);
+
+class CLexer {
+  private:
+    unsigned int wsSignificant;
+  public:
+    unsigned int lineNum;
+    unsigned int charNum;
+    CLexer(void);
+    ~CLexer(void);
+    int sourceFile(char *filename);
+    CToken *lookAhead(void);
+    CToken *getNextToken(void);
+    CToken *getBracedCode(void);
+    CToken *getParenCode(void);
+    CToken *getIntExpr(EToken term);
+};
+
+#endif /* _CLexer_H_ */
diff --git a/src/langs/sdag/xlator/CList.h b/src/langs/sdag/xlator/CList.h
new file mode 100644 (file)
index 0000000..03d0684
--- /dev/null
@@ -0,0 +1,115 @@
+#ifndef _TList_H_
+#define _TList_H_
+
+#include <stdio.h>
+
+// Quick and dirty List for small numbers of items.
+// This should ideally be a template but for portability's sake, its
+// a generic list of (void *)
+
+class TList
+{
+  private:
+
+    class Elem
+    {
+      public:
+      Elem *next;
+      void *data;
+      Elem(void *d) : next(NULL), data(d) {;}
+    };
+
+    Elem *first;
+    Elem *current;
+    unsigned int len;
+
+  public:
+
+    TList(void) : first(0), len(0) {;}
+
+    int empty(void) { return ! first; }
+    
+    void *begin(void) {
+      current = first;
+      if(current==(Elem *)0)
+        return (void *) 0;
+      else
+        return current->data;
+    }
+
+
+    int end(void) {
+      return (current == 0);
+    }
+
+    void *next (void) {
+      current = current->next;
+      if(current==(Elem *)0)
+       return (void *)0;
+      else
+        return current->data;
+    }
+
+    void *front(void)
+    {
+      return ((first==0) ? 0 : first->data);
+    }
+
+    void *pop(void)
+    {
+      void *data;
+      if( first!= 0) {
+        data = first->data;
+        Elem *nn = first->next;
+        delete first;
+        first = nn;
+        len --;
+      } else {
+        data = 0;
+      }
+      return data;
+    }
+
+    void remove(void *data)
+    {
+      // case 1: empty list
+      if (first == 0)
+        return;
+      // case 2: first element to be removed
+      if(first->data == data) {
+        first = first->next;
+        len --;
+        return;
+      }
+      // case 3: middle or last element to be removed
+      Elem *nn;
+      Elem *prev = first;
+      for(nn=first->next; nn; nn = nn->next) {
+        if (nn->data == data) {
+          prev->next = nn->next;
+          len --;
+          return;
+        }
+        prev = nn;
+      }
+    }
+
+    void append(void *data)
+    {
+      if(first == 0) {
+        first = new Elem(data);
+      } else {
+        Elem *nn;
+        for( nn = first ; nn->next ; nn = nn->next );
+        nn->next = new Elem(data);
+      }
+      len++;
+    }
+
+    int length(void) {
+      return len;
+    }
+};
+
+#endif
+
diff --git a/src/langs/sdag/xlator/CParseNode.C b/src/langs/sdag/xlator/CParseNode.C
new file mode 100644 (file)
index 0000000..6e82267
--- /dev/null
@@ -0,0 +1,279 @@
+#include "CParseNode.h"
+#include "CParser.h"
+
+void printc(TList *cons, int indent, char *sep)
+{
+  for(CParseNode *tmp=(CParseNode *)(cons->begin()); !cons->end();) {
+    tmp->print(indent);
+    tmp = (CParseNode *)(cons->next());
+    if(!cons->end())
+      printf("%s", sep);
+  }
+}
+
+void CParseNode::print(int indent)
+{
+  Indent(indent);
+  switch(type) {
+    case SDAGENTRY:
+      printf("sdagentry "); con1->print(0); printf("(");
+      con2->print(0); printf(" *"); con3->print(0);
+      printf(")\n"); ::printc(constructs,indent, "\n"); printf("\n");
+      break;
+    case OVERLAP:
+      printf("overlap\n"); printc(constructs,indent, "\n"); printf("\n");
+      break;
+    case WHEN:
+      printf("when "); con1->print(0); printf("\n");
+      printc(constructs,indent, "\n"); printf("\n");
+      break;
+    case FOR:
+      printf("for ("); con1->print(0); 
+      printf(";"); con2->print(0);
+      printf(";"); con3->print(0);
+      printf(")\n"); printc(constructs,indent, "\n");
+      printf("\n");
+      break;
+    case WHILE:
+      printf("while "); con1->print(0); printf("\n"); 
+      printc(constructs,indent,"\n");
+      printf("\n");
+      break;
+    case IF:
+      printf("if "); con1->print(0); 
+      printc(constructs,indent, "\n");
+      if(con2!=0) {
+        con2->print(indent);
+        printf("\n");
+      }
+      break;
+    case ELSE:
+      printf("else ");
+      printc(constructs,indent, "\n");
+      break;
+    case FORALL:
+      printf("forall ["); con1->print(0); printf("]");
+      printf(" ("); con2->print(0); printf(":"); con3->print(0); 
+      printf(","); con4->print(0); printf(")\n");
+      printc(constructs,indent, "\n");
+      printf("\n");
+      break;
+    case ELIST:
+      printc(constructs,0, ",");
+      break;
+    case SLIST:
+    case OLIST:
+      printf("{\n");
+      printc(constructs,indent+1, "\n");
+      printf("\n");
+      Indent(indent);
+      printf("}\n");
+      break;
+    case INT_EXPR:
+      text->print(0);
+      break;
+    case IDENT:
+      text->print(0);
+      break;
+    case ENTRY:
+      con1->print(0);
+      if(con2) { printf("["); con2->print(0); printf("]"); }
+      printf("("); con3->print(0); printf(" *");
+      con4->print(0); printf(")");
+      break;
+    case ATOMIC:
+      printf("atomic\n");
+      text->print(indent+1);
+      break;
+    default:
+      printf("ERROR!!!\n");
+      break;
+  }
+}
+
+static void syntaxError(CLexer *cLexer)
+{
+  fprintf(stderr, "Syntax error near line %d, char %d\n",
+                  cLexer->lineNum, cLexer->charNum);
+  exit(1);
+}
+
+CParseNode::CParseNode(EToken t, CLexer *cLexer, CParser *cParser)
+{
+  CToken *tok;
+
+  type = t; text = 0; constructs = new TList();
+  con1 = con2 = con3 = con4 = 0;
+  switch (t) {
+    case SDAGENTRY:
+      tok = cParser->lookForToken(IDENT);
+      con1 = new CParseNode(IDENT, tok->text);
+      tok = cParser->lookForToken(LP); delete tok;
+      tok = cParser->lookForToken(IDENT);
+      con2 = new CParseNode(IDENT, tok->text);
+      tok = cParser->lookForToken(STAR); delete tok;
+      tok = cParser->lookForToken(IDENT);
+      con3 = new CParseNode(IDENT, tok->text);
+      tok = cParser->lookForToken(RP); delete tok;
+      tok = cLexer->getNextToken();
+      if(tok->type == LBRACE) {
+        delete tok;
+        constructs->append(new CParseNode(SLIST, cLexer, cParser));
+      } else
+        constructs->append(new CParseNode(tok->type, cLexer, cParser));
+      break;
+    case OVERLAP:
+      tok = cLexer->getNextToken();
+      if(tok->type == LBRACE) {
+        delete tok;
+        constructs->append(new CParseNode(OLIST, cLexer, cParser));
+      } else {
+        constructs->append(new CParseNode(tok->type, cLexer, cParser));
+      }
+      break;
+    case WHEN:
+      con1 = new CParseNode(ELIST, cLexer, cParser);
+      tok = cLexer->getNextToken();
+      if(tok->type == LBRACE) {
+        delete tok;
+        constructs->append(new CParseNode(SLIST, cLexer, cParser));
+      } else {
+        constructs->append(new CParseNode(tok->type, cLexer, cParser));
+      }
+      break;
+    case IF:
+      tok = cParser->lookForToken(LP); delete tok;
+      tok = cLexer->getParenCode();
+      con1 = new CParseNode(INT_EXPR, tok->text);
+      tok = cLexer->getNextToken();
+      if(tok->type == LBRACE) {
+        delete tok;
+        constructs->append(new CParseNode(SLIST, cLexer, cParser));
+      } else {
+        constructs->append(new CParseNode(tok->type, cLexer, cParser));
+      }
+      tok = cLexer->lookAhead();
+      if (tok->type != ELSE) {
+        break;
+      }
+      delete tok;
+      tok = cLexer->getNextToken(); delete tok;
+      con2 = new CParseNode(ELSE, cLexer, cParser);
+      break;
+    case ELSE:
+      tok = cLexer->getNextToken();
+      if(tok->type == LBRACE) {
+        delete tok;
+        constructs->append(new CParseNode(SLIST, cLexer, cParser));
+      } else {
+        constructs->append(new CParseNode(tok->type, cLexer, cParser));
+      }
+      break;
+    case FOR:
+      tok = cParser->lookForToken(LP); delete tok;
+      tok = cLexer->getIntExpr(SEMICOLON);
+      con1 = new CParseNode(INT_EXPR, tok->text);
+      tok = cParser->lookForToken(SEMICOLON); delete tok;
+      tok = cLexer->getIntExpr(SEMICOLON);
+      con2 = new CParseNode(INT_EXPR, tok->text);
+      tok = cParser->lookForToken(SEMICOLON); delete tok;
+      tok = cLexer->getIntExpr(RP);
+      con3 = new CParseNode(INT_EXPR, tok->text);
+      tok = cParser->lookForToken(RP); delete tok;
+      tok = cLexer->getNextToken();
+      if(tok->type == LBRACE) {
+        delete tok;
+        constructs->append(new CParseNode(SLIST, cLexer, cParser));
+      } else {
+        constructs->append(new CParseNode(tok->type, cLexer, cParser));
+      }
+      break;
+    case WHILE:
+      tok = cParser->lookForToken(LP); delete tok;
+      tok = cLexer->getParenCode();
+      con1 = new CParseNode(INT_EXPR, tok->text);
+      tok = cLexer->getNextToken();
+      if(tok->type == LBRACE) {
+        delete tok;
+        constructs->append(new CParseNode(SLIST, cLexer, cParser));
+      } else {
+        constructs->append(new CParseNode(tok->type, cLexer, cParser));
+      }
+      break;
+    case ATOMIC:
+      tok = cParser->lookForToken(LBRACE); delete tok;
+      tok = cLexer->getBracedCode();
+      text = tok->text;
+      break;
+    case OLIST:
+    case SLIST:
+      tok = cLexer->getNextToken();
+      while(tok->type != RBRACE) {
+        if (tok->type == LBRACE) {
+          delete tok;
+          constructs->append(new CParseNode(SLIST, cLexer, cParser));
+        } else {
+          constructs->append(new CParseNode(tok->type, cLexer, cParser));
+        }
+        tok = cLexer->getNextToken();
+      }
+      break;
+    case ELIST:
+      tok = cLexer->lookAhead();
+      while (tok->type == IDENT) {
+        constructs->append(new CParseNode(ENTRY, cLexer, cParser));
+        tok = cLexer->lookAhead();
+      }
+      break;
+    case ENTRY:
+      tok = cParser->lookForToken(IDENT);
+      con1 = new CParseNode(IDENT, tok->text);
+      tok = cParser->lookForToken2(LB, LP);
+      if(tok->type == LB) {
+        delete tok;
+        tok = cLexer->getIntExpr(RB);
+        con2 = new CParseNode(INT_EXPR, tok->text);
+        tok = cParser->lookForToken(RB); delete tok;
+        tok = cParser->lookForToken(LP); delete tok;
+      }
+      tok = cParser->lookForToken(IDENT);
+      con3 = new CParseNode(IDENT, tok->text);
+      tok = cParser->lookForToken(STAR); delete tok;
+      tok = cParser->lookForToken(IDENT);
+      con4 = new CParseNode(IDENT, tok->text);
+      tok = cParser->lookForToken(RP); delete tok;
+      tok = cLexer->lookAhead();
+      if(tok->type == COMMA) {
+        delete tok;
+        tok = cLexer->getNextToken();
+      }
+      break;
+    case FORALL:
+      tok = cParser->lookForToken(LB); delete tok;
+      tok = cParser->lookForToken(IDENT);
+      con1 = new CParseNode(IDENT, tok->text);
+      tok = cParser->lookForToken(RB); delete tok;
+      tok = cParser->lookForToken(LP); delete tok;
+      tok = cLexer->getIntExpr(COLON);
+      con2 = new CParseNode(INT_EXPR, tok->text);
+      tok = cParser->lookForToken(COLON); delete tok;
+      tok = cLexer->getIntExpr(COMMA);
+      con3 = new CParseNode(INT_EXPR, tok->text);
+      tok = cParser->lookForToken(COMMA); delete tok;
+      tok = cLexer->getIntExpr(RP);
+      con4 = new CParseNode(INT_EXPR, tok->text);
+      tok = cParser->lookForToken(RP); delete tok;
+      tok = cLexer->getNextToken();
+      if(tok->type == LBRACE) {
+        delete tok;
+        constructs->append(new CParseNode(SLIST, cLexer, cParser));
+      } else {
+        constructs->append(new CParseNode(tok->type, cLexer, cParser));
+      }
+      break;
+    default:
+      syntaxError(cLexer);
+      break;
+  }
+}
+
diff --git a/src/langs/sdag/xlator/CParseNode.h b/src/langs/sdag/xlator/CParseNode.h
new file mode 100644 (file)
index 0000000..bd5efa8
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef _CParseNode_H_
+#define _CParseNode_H_
+
+#include "EToken.h"
+#include "CString.h"
+#include "CLexer.h"
+#include "sdag-globals.h"
+#include "CList.h"
+#include "CStateVar.h"
+#include "CEntry.h"
+
+class CParser;
+
+class CParseNode {
+  public:
+    CString *className;
+    void print(int indent);
+    int nodeNum;
+    CString *label;
+    CString *counter;
+    EToken type;
+    CString *text;
+    CParseNode *con1, *con2, *con3, *con4;
+    TList *constructs;
+    TList *stateVars;
+    TList *stateVarsChildren;
+    CParseNode *next;
+    int nextBeginOrEnd;
+    CEntry *entryPtr;
+    CParseNode(EToken t, CLexer *cLexer, CParser *cParser);
+    CParseNode(EToken t, CString *txt) : type(t), text(txt), con1(0), con2(0),
+                                         con3(0), con4(0), constructs(0) {}
+    void numberNodes(void);
+    void labelNodes(CString *);
+    void generateEntryList(TList *, CParseNode *);
+    void propogateState(TList *);
+    void generateCode(void);
+    void setNext(CParseNode *, int);
+  private:
+    void generateWhen(void);
+    void generateOverlap(void);
+    void generateWhile(void);
+    void generateFor(void);
+    void generateIf(void);
+    void generateElse(void);
+    void generateForall(void);
+    void generateOlist(void);
+    void generateSdagEntry(void);
+    void generateSlist(void);
+    void generateAtomic(void);
+    void generatePrototype(FILE *, TList *);
+    void generateCall(FILE *f, TList *);
+};
+#endif
diff --git a/src/langs/sdag/xlator/CParseNodeProcess.C b/src/langs/sdag/xlator/CParseNodeProcess.C
new file mode 100644 (file)
index 0000000..e6cfe03
--- /dev/null
@@ -0,0 +1,883 @@
+#include <stdlib.h>
+#include "sdag-globals.h"
+#include "CParseNode.h"
+
+void CParseNode::numberNodes(void)
+{
+  switch(type) {
+    case SDAGENTRY: nodeNum = numSdagEntries++; break;
+    case OVERLAP: nodeNum = numOverlaps++; break;
+    case WHEN: nodeNum = numWhens++; break;
+    case FOR: nodeNum = numFors++; break;
+    case WHILE: nodeNum = numWhiles++; break;
+    case IF: nodeNum = numIfs++; if(con2!=0) con2->numberNodes(); break;
+    case ELSE: nodeNum = numElses++; break;
+    case FORALL: nodeNum = numForalls++; break;
+    case SLIST: nodeNum = numSlists++; break;
+    case OLIST: nodeNum = numOlists++; break;
+    case ATOMIC: nodeNum = numAtomics++; break;
+    case ELIST:
+    case INT_EXPR:
+    case IDENT:
+    case ENTRY:
+    default:
+      break;
+  }
+  CParseNode *cn;
+  for(cn=(CParseNode *)(constructs->begin()); !constructs->end(); cn=(CParseNode *)(constructs->next())) {
+    cn->numberNodes();
+  }
+}
+
+void CParseNode::labelNodes(CString *cname)
+{
+  char text[128];
+
+  className = cname;
+  switch(type) {
+    case ENTRY:
+    case SDAGENTRY:
+      sprintf(text, "%s", con1->text->charstar());
+      label = new CString(text);
+      break;
+    case OVERLAP: 
+      sprintf(text, "_overlap_%d", nodeNum); 
+      label = new CString(text);
+      break;
+    case WHEN: 
+      sprintf(text, "_when_%d", nodeNum); 
+      label = new CString(text);
+      break;
+    case FOR: 
+      sprintf(text, "_for_%d", nodeNum); 
+      label = new CString(text);
+      break;
+    case WHILE: 
+      sprintf(text, "_while_%d", nodeNum); 
+      label = new CString(text);
+      break;
+    case IF: 
+      sprintf(text, "_if_%d", nodeNum); 
+      label = new CString(text);
+      if(con2!=0) con2->labelNodes(cname);
+      break;
+    case ELSE: 
+      sprintf(text, "_else_%d", nodeNum); 
+      label = new CString(text);
+      break;
+    case FORALL: 
+      sprintf(text, "_forall_%d", nodeNum); 
+      label = new CString(text);
+      break;
+    case SLIST: 
+      sprintf(text, "_slist_%d", nodeNum); 
+      label = new CString(text);
+      break;
+    case OLIST: 
+      sprintf(text, "_olist_%d", nodeNum); 
+      label = new CString(text);
+      break;
+    case ATOMIC: 
+      sprintf(text, "_atomic_%d", nodeNum); 
+      label = new CString(text);
+      break;
+    case ELIST:
+    case INT_EXPR:
+    case IDENT:
+    default:
+      break;
+  }
+  CParseNode *cn;
+  for(cn=(CParseNode *)(constructs->begin()); !constructs->end(); cn=(CParseNode *)(constructs->next())) {
+    cn->labelNodes(cname);
+  }
+}
+
+void CParseNode::generateEntryList(TList *list, CParseNode *thisWhen)
+{
+  switch(type) {
+    case WHEN:
+      con1->generateEntryList(list, this);
+      break;
+    case IF:
+      if(con2!=0) con2->generateEntryList(list,thisWhen);
+      break;
+    case ENTRY:
+      CEntry *entry;
+      int found=0;
+      for(entry=(CEntry *)(list->begin()); !list->end(); entry=(CEntry *)(list->next())) {
+        if(entry->entry->equal(con1->text) &&
+           entry->msgType->equal(con3->text)) {
+           found = 1;
+           entry->whenList->append(thisWhen);
+           entryPtr = entry;
+          if(con2)
+            entry->refNumNeeded = 1;
+           break;
+        }
+      }
+      if(!found) {
+        CEntry *newEntry;
+        newEntry = new CEntry(new CString(con1->text), new CString(con3->text));
+        list->append(newEntry);
+        entryPtr = newEntry;
+        newEntry->whenList->append(thisWhen);
+       if(con2)
+         newEntry->refNumNeeded = 1;
+      }
+      break;
+  }
+  CParseNode *cn;
+  for(cn=(CParseNode *)(constructs->begin()); !constructs->end(); cn=(CParseNode *)(constructs->next())) {
+    cn->generateEntryList(list,thisWhen);
+  }
+}
+
+void CParseNode::propogateState(TList *list)
+{
+  CStateVar *sv;
+  stateVars = new TList();
+  switch(type) {
+    case SDAGENTRY:
+      {
+        CString *vType = new CString(con2->text);
+        vType->append(" *");
+        sv = new CStateVar(vType, new CString(con3->text));
+      }
+      stateVars->append(sv);
+      stateVarsChildren = stateVars;
+      break;
+    case FORALL:
+      stateVarsChildren = new TList();
+      for(sv=(CStateVar *)(list->begin()); !list->end(); sv=(CStateVar *)(list->next())) {
+        stateVars->append(sv);
+        stateVarsChildren->append(sv);
+      }
+      sv = new CStateVar(new CString("int"), new CString(con1->text));
+      stateVarsChildren->append(sv);
+      {
+        char txt[128];
+        sprintf(txt, "_cf%d", nodeNum);
+        counter = new CString(txt);
+        sv = new CStateVar(new CString("CCounter *"), counter);
+        stateVarsChildren->append(sv);
+      }
+      break;
+    case WHEN:
+      stateVarsChildren = new TList();
+      for(sv=(CStateVar *)(list->begin()); !list->end(); sv=(CStateVar *)(list->next())) {
+        stateVars->append(sv);
+        stateVarsChildren->append(sv);
+      }
+      {
+        TList *elist = con1->constructs;
+        CParseNode *en;
+        for(en=(CParseNode *)(elist->begin()); !elist->end(); en=(CParseNode *)(elist->next())) {
+          CString *vType = new CString(en->con3->text);
+          vType->append(" *");
+          sv = new CStateVar(vType, new CString(en->con4->text));
+          stateVarsChildren->append(sv);
+        }
+      }
+      break;
+    case IF:
+      for(sv=(CStateVar *)(list->begin()); !list->end(); sv=(CStateVar *)(list->next())) {
+        stateVars->append(sv);
+      }
+      stateVarsChildren = stateVars;
+      if(con2 != 0) con2->propogateState(list);
+      break;
+    case OLIST:
+      stateVarsChildren = new TList();
+      for(sv=(CStateVar *)(list->begin()); !list->end(); sv=(CStateVar *)(list->next())) {
+        stateVars->append(sv);
+        stateVarsChildren->append(sv);
+      }
+      {
+        char txt[128];
+        sprintf(txt, "_co%d", nodeNum);
+        counter = new CString(txt);
+        sv = new CStateVar(new CString("CCounter *"), counter);
+        stateVarsChildren->append(sv);
+      }
+      break;
+    case FOR:
+    case WHILE:
+    case ELSE:
+    case SLIST:
+    case OVERLAP:
+    case ATOMIC:
+      for(sv=(CStateVar *)(list->begin()); !list->end(); sv=(CStateVar *)(list->next())) {
+        stateVars->append(sv);
+      }
+      stateVarsChildren = stateVars;
+      break;
+    case INT_EXPR:
+    case IDENT:
+    case ENTRY:
+    case ELIST:
+    default:
+      break;
+  }
+  CParseNode *cn;
+  for(cn=(CParseNode *)(constructs->begin()); !constructs->end(); cn=(CParseNode *)(constructs->next())) {
+    cn->propogateState(stateVarsChildren);
+  }
+}
+
+void CParseNode::generateCode(void)
+{
+  switch(type) {
+    case SDAGENTRY:
+      generateSdagEntry();
+      break;
+    case SLIST:
+      generateSlist();
+      break;
+    case OLIST:
+      generateOlist();
+      break;
+    case FORALL:
+      generateForall();
+      break;
+    case ATOMIC:
+      generateAtomic();
+      break;
+    case IF:
+      generateIf();
+      if(con2 != 0)
+        con2->generateCode();
+      break;
+    case ELSE:
+      generateElse();
+      break;
+    case WHILE:
+      generateWhile();
+      break;
+    case FOR:
+      generateFor();
+      break;
+    case OVERLAP:
+      generateOverlap();
+      break;
+    case WHEN:
+      generateWhen();
+      break;
+    default:
+      break;
+  }
+  CParseNode *cn;
+  for(cn=(CParseNode *)(constructs->begin()); !constructs->end(); cn=(CParseNode *)(constructs->next())) {
+    cn->generateCode();
+  }
+}
+
+void CParseNode::generateWhen(void)
+{
+  // header file
+  pH(1,"int %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(1,"void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+
+  // C++ file: start function
+  pC(0, "int %s::%s(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVars);
+  pC(0, ") {\n");
+  // actual code here 
+  TList *elist = con1->constructs;
+  CParseNode *el;
+  for(el=(CParseNode *)(elist->begin()); !elist->end(); el=(CParseNode *)(elist->next())) {
+    pC(1, "CMsgBuffer *%s_buf;\n", el->con4->text->charstar());
+    pC(1, "%s *%s;\n", el->con3->text->charstar(),
+                el->con4->text->charstar());
+  }
+  pC(0, "\n");
+  for(el=(CParseNode *)(elist->begin()); !elist->end(); el=(CParseNode *)(elist->next())) {
+    if(el->con2 == 0)
+      pC(1, "%s_buf = __cDep->getMessage(%d);\n",
+                  el->con4->text->charstar(),
+                  el->entryPtr->entryNum);
+    else
+      pC(1, "%s_buf = __cDep->getMessage(%d, %s);\n",
+                  el->con4->text->charstar(),
+                  el->entryPtr->entryNum,
+                  el->con2->text->charstar());
+  }
+  pC(0, "\n");
+  pC(1, "if (");
+  for(el=(CParseNode *)(elist->begin()); !elist->end();) {
+    pC(0, "(%s_buf != 0)", el->con4->text->charstar());
+    el = (CParseNode *)(elist->next());
+    if(el != 0)
+      pC(0, "&&");
+  }
+  pC(0, ") {\n");
+  for(el=(CParseNode *)(elist->begin()); !elist->end(); el=(CParseNode *)(elist->next())) {
+    pC(2, "%s = (%s *) %s_buf->msg;\n",
+                  el->con4->text->charstar(),
+                  el->con3->text->charstar(),
+                  el->con4->text->charstar());
+    pC(2, "__cDep->removeMessage(%s_buf);\n",
+                el->con4->text->charstar());
+  }
+  pC(2, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fC, stateVarsChildren);
+  pC(0, ");\n");
+  pC(2, "return 1;\n");
+  pC(1, "} else {\n");
+
+  int nRefs=0, nAny=0;
+  for(el=(CParseNode *)(elist->begin()); !elist->end(); el=(CParseNode *)(elist->next())) {
+    if(el->con2 == 0)
+      nAny++;
+    else
+      nRefs++;
+  }
+
+// keep these consts consistent with CWhenTrigger.h in runtime
+
+#define MAXARG 8
+#define MAXANY 8
+#define MAXREF 8
+
+  if(stateVars->length() > MAXARG) {
+    fprintf(stderr, "numStateVars more that %d, contact developers.\n",
+                    MAXARG);
+    exit(1);
+  }
+  if(nRefs > MAXREF) {
+    fprintf(stderr, "numDepends more that %d, contact developers.\n",
+                    MAXREF);
+    exit(1);
+  }
+  if(nAny > MAXANY) {
+    fprintf(stderr, "numDepends more that %d, contact developers.\n",
+                    MAXANY);
+    exit(1);
+  }
+
+  pC(2, "CWhenTrigger *tr;\n");
+  pC(2, "tr = new CWhenTrigger(%d, %d, %d, %d);\n",
+                   nodeNum, 
+                   stateVars->length(), nRefs, nAny);
+  CStateVar *sv;
+  int iArgs=0;
+  for(sv=(CStateVar *)(stateVars->begin());!stateVars->end();sv=(CStateVar *)(stateVars->next())) {
+    pC(2, "tr->args[%d] = (size_t) %s;\n", iArgs++,
+                sv->name->charstar());
+  }
+  int iRef=0, iAny=0;
+  for(el=(CParseNode *)(elist->begin()); !elist->end(); el=(CParseNode *)(elist->next())) {
+    if(el->con2 == 0) {
+      pC(2, "tr->anyEntries[%d] = %d;\n", iAny++,
+                  el->entryPtr->entryNum);
+    } else {
+      pC(2, "tr->entries[%d] = %d;\n", iRef,
+                  el->entryPtr->entryNum);
+      pC(2, "tr->refnums[%d] = %s;\n", iRef++,
+                  el->con2->text->charstar());
+    }
+  }
+  pC(2, "__cDep->Register(tr);\n");
+  pC(2, "return 0;\n");
+  pC(1, "}\n");
+  // end actual code
+  pC(0, "}\n\n");
+  // C++ file: end function
+  pC(0, "void %s::%s_end(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVarsChildren);
+  pC(0, ") {\n");
+  // actual code here 
+  for(el=(CParseNode *)(elist->begin()); !elist->end(); el=(CParseNode *)(elist->next())) {
+    // pC(1, "delete %s;\n", el->con4->text->charstar());
+  }
+  if(nextBeginOrEnd == 1)
+   pC(1, "%s(", next->label->charstar());
+  else
+   pC(1, "%s_end(", next->label->charstar());
+  generateCall(fC, stateVars);
+  pC(0, ");\n");
+  // end actual code
+  pC(0, "}\n\n");
+}
+
+void CParseNode::generateWhile(void)
+{
+  // header file
+  pH(1,"void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(1,"void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+
+  // C++ file: start function
+  pC(0, "void %s::%s(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVars);
+  pC(0, ") {\n");
+  // actual code here 
+  pC(1, "if (%s) {\n", con1->text->charstar());
+  pC(2, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fC, stateVarsChildren);
+  pC(0, ");\n");
+  pC(1, "} else {\n");
+  if(nextBeginOrEnd == 1)
+   pC(2, "%s(", next->label->charstar());
+  else
+   pC(2, "%s_end(", next->label->charstar());
+  generateCall(fC, stateVars);
+  pC(0, ");\n");
+  pC(1, "}\n");
+  // end actual code
+  pC(0, "}\n\n");
+  // C++ file: end function
+  pC(0, "void %s::%s_end(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVarsChildren);
+  pC(0, ") {\n");
+  // actual code here 
+  pC(1, "if (%s) {\n", con1->text->charstar());
+  pC(2, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fC, stateVarsChildren);
+  pC(0, ");\n");
+  pC(1, "} else {\n");
+  if(nextBeginOrEnd == 1)
+   pC(2, "%s(", next->label->charstar());
+  else
+   pC(2, "%s_end(", next->label->charstar());
+  generateCall(fC, stateVars);
+  pC(0, ");\n");
+  pC(1, "}\n");
+  // end actual code
+  pC(0, "}\n\n");
+}
+
+void CParseNode::generateFor(void)
+{
+#if 0
+  // header file
+  pH(1,"void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(1,"void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+#endif
+
+  // header file: inlined start function
+  pH(1, "void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0, ") {\n");
+  // actual code here 
+  pH(2, "%s;\n", con1->text->charstar());
+  pH(2, "if (%s) {\n", con2->text->charstar());
+  pH(3, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fh, stateVarsChildren);
+  pH(0, ");\n");
+  pH(2, "} else {\n");
+  if(nextBeginOrEnd == 1)
+   pH(3, "%s(", next->label->charstar());
+  else
+   pH(3, "%s_end(", next->label->charstar());
+  generateCall(fh, stateVars);
+  pH(0, ");\n");
+  pH(2, "}\n");
+  // end actual code
+  pH(1, "}\n");
+  // header file: inlined end function
+  pH(1, "void %s_end(",  label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0, ") {\n");
+  // actual code here 
+  pH(2, "%s;\n", con3->text->charstar());
+  pH(2, "if (%s) {\n", con2->text->charstar());
+  pH(3, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fh, stateVarsChildren);
+  pH(0, ");\n");
+  pH(2, "} else {\n");
+  if(nextBeginOrEnd == 1)
+   pH(3, "%s(", next->label->charstar());
+  else
+   pH(3, "%s_end(", next->label->charstar());
+  generateCall(fh, stateVars);
+  pH(0, ");\n");
+  pH(2, "}\n");
+  // end actual code
+  pH(1, "}\n");
+}
+
+void CParseNode::generateIf(void)
+{
+  // header file
+  pH(1,"void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(1,"void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+
+  // C++ file: start function
+  pC(0, "void %s::%s(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVars);
+  pC(0, ") {\n");
+  // actual code here 
+  pC(1, "if (%s) {\n", con1->text->charstar());
+  pC(2, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fC, stateVarsChildren);
+  pC(0, ");\n");
+  pC(1, "} else {\n");
+  if (con2 != 0) {
+    pC(2, "%s(", con2->label->charstar());
+    generateCall(fC, stateVarsChildren);
+    pC(0, ");\n");
+  } else {
+    pC(2, "%s_end(", label->charstar());
+    generateCall(fC, stateVarsChildren);
+    pC(0, ");\n");
+  }
+  pC(1, "}\n");
+  // end actual code
+  pC(0, "}\n\n");
+  // C++ file: end function
+  pC(0, "void %s::%s_end(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVarsChildren);
+  pC(0, ") {\n");
+  // actual code here 
+  if(nextBeginOrEnd == 1)
+   pC(2, "%s(", next->label->charstar());
+  else
+   pC(2, "%s_end(", next->label->charstar());
+  generateCall(fC, stateVars);
+  pC(0, ");\n");
+  // end actual code
+  pC(0, "}\n\n");
+}
+
+void CParseNode::generateElse(void)
+{
+  // header file
+  pH(1,"void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(1,"void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+
+  // C++ file: start function
+  pC(0, "void %s::%s(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVars);
+  pC(0, ") {\n");
+  // actual code here 
+  pC(1, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fC, stateVarsChildren);
+  pC(0, ");\n");
+  // end actual code
+  pC(0, "}\n\n");
+  // C++ file: end function
+  pC(0, "void %s::%s_end(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVarsChildren);
+  pC(0, ") {\n");
+  // actual code here 
+  if(nextBeginOrEnd == 1)
+   pC(2, "%s(", next->label->charstar());
+  else
+   pC(2, "%s_end(", next->label->charstar());
+  generateCall(fC, stateVars);
+  pC(0, ");\n");
+  // end actual code
+  pC(0, "}\n\n");
+}
+
+void CParseNode::generateForall(void)
+{
+  // header file
+  pH(1,"void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(1,"void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+
+  // C++ file: start function
+  pC(0, "void %s::%s(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVars);
+  pC(0, ") {\n");
+  // actual code here 
+  pC(1, "int __first = (%s), __last = (%s), __stride = (%s);\n",
+              con2->text->charstar(), con3->text->charstar(),
+              con4->text->charstar());
+  pC(1, "if (__first > __last) {\n");
+  pC(2, "__swap(&__first, &__last);\n");
+  pC(2, "__stride = -__stride;\n");
+  pC(1, "}\n");
+  pC(1, "CCounter *%s = new CCounter(__first,__last,__stride);\n", 
+              counter->charstar());
+  pC(1, "for(int %s=__first;%s<=__last;%s+=__stride) {\n",
+              con1->text->charstar(), con1->text->charstar(),
+              con1->text->charstar());
+  pC(2, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fC, stateVarsChildren);
+  pC(0, ");\n");
+  pC(1, "}\n");
+  // end actual code
+  pC(0, "}\n\n");
+  // C++ file: end function
+  pC(0, "void %s::%s_end(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVarsChildren);
+  pC(0, ") {\n");
+  // actual code here 
+  pC(1, "%s->decrement();\n", counter->charstar());
+  pC(1, "if (%s->isDone()) {\n", counter->charstar());
+  pC(2, "delete %s;\n", counter->charstar());
+  if(nextBeginOrEnd == 1)
+   pC(2, "%s(", next->label->charstar());
+  else
+   pC(2, "%s_end(", next->label->charstar());
+  generateCall(fC, stateVars);
+  pC(0, ");\n");
+  // end actual code
+  pC(1, "}\n}\n\n");
+}
+
+void CParseNode::generateOlist(void)
+{
+#if 0
+  // header file
+  pH(1,"void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(1,"void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+#endif
+
+  // header file: inlined start function
+  pH(1, "void %s(",  label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0, ") {\n");
+  // actual code here 
+  pH(2, "CCounter *%s = new CCounter(%d);\n", counter->charstar(),
+                                                      (CParseNode *)constructs->length());
+  for(CParseNode *cn=(CParseNode *)(constructs->begin()); 
+                     !constructs->end(); cn=(CParseNode *)(constructs->next())) {
+    pH(2, "%s(", cn->label->charstar());
+    generateCall(fh, stateVarsChildren);
+    pH(0, ");\n");
+  }
+  // end actual code
+  pH(1, "}\n");
+  // header file: inlined end function
+  pH(1, "void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0, ") {\n");
+  // actual code here 
+  pH(2, "%s->decrement();\n", counter->charstar());
+  pH(2, "if (%s->isDone()) {\n", counter->charstar());
+  pH(3, "delete %s;\n", counter->charstar());
+  if(nextBeginOrEnd == 1)
+   pH(3, "%s(", next->label->charstar());
+  else
+   pH(3, "%s_end(", next->label->charstar());
+  generateCall(fh, stateVars);
+  pH(0, ");\n");
+  // end actual code
+  pH(2, "}\n");
+  pH(1, "}\n");
+}
+
+void CParseNode::generateOverlap(void)
+{
+#if 0
+  // header file
+  pH(1,"void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(1,"void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+#endif
+
+  // header file: inlined start function
+  pH(1, "void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0, ") {\n");
+  // actual code here 
+  pH(2, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fh, stateVarsChildren);
+  pH(0, ");\n");
+  // end actual code
+  pH(1, "}\n");
+  // header file: inlined end function
+  pH(1, "void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0, ") {\n");
+  // actual code here 
+  if(nextBeginOrEnd == 1)
+   pH(2, "%s(", next->label->charstar());
+  else
+   pH(2, "%s_end(", next->label->charstar());
+  generateCall(fh, stateVars);
+  pH(0, ");\n");
+  // end actual code
+  pH(1, "}\n");
+}
+
+void CParseNode::generateSlist(void)
+{
+#if 0
+  // header file
+  pH(1,"void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(1,"void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+#endif
+
+  // header file: inlined start function
+  pH(1, "void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0, ") {\n");
+  // actual code here 
+  pH(2, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fh, stateVarsChildren);
+  pH(0, ");\n");
+  // end actual code
+  pH(1, "}\n");
+  // header file: inlined end function
+  pH(1, "void %s_end(", label->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0, ") {\n");
+  // actual code here 
+  if(nextBeginOrEnd == 1)
+   pH(2, "%s(", next->label->charstar());
+  else
+   pH(2, "%s_end(", next->label->charstar());
+  generateCall(fh, stateVars);
+  pH(0, ");\n");
+  // end actual code
+  pH(1, "}\n");
+}
+
+void CParseNode::generateSdagEntry(void)
+{
+  // header file
+  pH(0,"public:\n");
+  pH(1,"void %s(", con1->text->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pH(0,"private:\n");
+  pH(1,"void %s_end(", con1->text->charstar());
+  generatePrototype(fh, stateVarsChildren);
+  pH(0,");\n");
+
+  // C++ file
+  pC(0, "void %s::%s(", className->charstar(), con1->text->charstar());
+  generatePrototype(fC, stateVars);
+  pC(0, ") {\n");
+  // actual code here 
+  pC(1, "%s(", ((CParseNode *)constructs->front())->label->charstar());
+  generateCall(fC, stateVarsChildren);
+  pC(0, ");\n");
+  // end actual code
+  pC(0, "}\n\n");
+  pC(0, "void %s::%s_end(", className->charstar(), con1->text->charstar());
+  generatePrototype(fC, stateVars);
+  pC(0, ") {\n");
+  // actual code here 
+  // pC(1, "delete %s;\n", con3->text->charstar());
+  // end actual code
+  pC(0, "}\n\n");
+}
+
+void CParseNode::generateAtomic(void)
+{
+  pH(1,"void %s(", label->charstar());
+  generatePrototype(fh, stateVars);
+  pH(0,");\n");
+  pC(0, "void %s::%s(", className->charstar(), label->charstar());
+  generatePrototype(fC, stateVars);
+  pC(0, ") {\n");
+  pC(0, "%s\n", text->charstar());
+  if(nextBeginOrEnd == 1)
+    pC(1, "%s(", next->label->charstar());
+  else
+    pC(1, "%s_end(", next->label->charstar());
+  generateCall(fC, stateVars);
+  pC(0, ");\n");
+  pC(0, "}\n\n");
+}
+
+void CParseNode::generatePrototype(FILE *f, TList *list)
+{
+  CStateVar *sv;
+  for(sv=(CStateVar *)(list->begin()); !list->end(); ) {
+    fprintf(f, "%s %s", sv->type->charstar(), sv->name->charstar());
+    sv = (CStateVar *)list->next();
+    if (sv != 0)
+      fprintf(f, ", ");
+  }
+}
+
+void CParseNode::generateCall(FILE *f, TList *list) {
+  CStateVar *sv;
+  for(sv=(CStateVar *)list->begin(); !list->end(); ) {
+    fprintf(f, "%s", sv->name->charstar());
+    sv = (CStateVar *)list->next();
+    if (sv != 0)
+      fprintf(f, ", ");
+  }
+}
+
+// boe = 1, if the next call is to begin construct
+// boe = 0, if the next call is to end a contruct
+void CParseNode::setNext(CParseNode *n, int boe)
+{
+  switch(type) {
+    case SLIST:
+      next = n;
+      nextBeginOrEnd = boe;
+      {
+        CParseNode *cn=(CParseNode *)constructs->begin();
+        if (cn==0) // empty slist
+          return;
+        CParseNode *nextNode=(CParseNode *)constructs->next();
+        for(; nextNode != 0;) {
+          cn->setNext(nextNode, 1);
+          cn = nextNode;
+          nextNode = (CParseNode *)constructs->next();
+        }
+        cn->setNext(this, 0);
+      }
+      return;
+    case SDAGENTRY:
+    case OVERLAP:
+    case OLIST:
+    case FORALL:
+    case WHEN:
+    case FOR:
+    case WHILE:
+    case ATOMIC:
+    case ELSE:
+      next = n;
+      nextBeginOrEnd = boe;
+      n = this; boe = 0; break;
+    case IF:
+      next = n;
+      nextBeginOrEnd = boe;
+      if(con2 != 0)
+        con2->setNext(n, boe);
+      n = this;
+      boe = 0;
+      break;
+    default:
+      break;
+  }
+  CParseNode *cn;
+  for(cn=(CParseNode *)constructs->begin(); !constructs->end(); cn=(CParseNode *)constructs->next()) {
+    cn->setNext(n, boe);
+  }
+}
+
diff --git a/src/langs/sdag/xlator/CParsedFile.C b/src/langs/sdag/xlator/CParsedFile.C
new file mode 100644 (file)
index 0000000..a7a7c18
--- /dev/null
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include "CParsedFile.h"
+
+void CParsedFile::print(int indent)
+{
+  sourceFile->print(indent);
+  printf(":\nclass ");
+  className->print(indent);
+  printf("\n");
+  for(CEntry *ce=(CEntry *)(entryList->begin()); !entryList->end(); ce=(CEntry *)(entryList->next()))
+  {
+    ce->print(indent);
+    printf("\n");
+  }
+  for(CParseNode *cn=(CParseNode *)(nodeList->begin()); !nodeList->end(); cn=(CParseNode *)(nodeList->next()))
+  {
+    cn->print(indent);
+    printf("\n");
+  }
+}
+
+void CParsedFile::numberNodes(void)
+{
+  for(CParseNode *cn=(CParseNode *)(nodeList->begin()); !nodeList->end(); cn=(CParseNode *)(nodeList->next())) {
+    cn->numberNodes();
+  }
+}
+
+void CParsedFile::labelNodes(void)
+{
+  for(CParseNode *cn=(CParseNode *)(nodeList->begin()); !nodeList->end(); cn=(CParseNode *)(nodeList->next())) {
+    cn->labelNodes(className);
+  }
+}
+
+void CParsedFile::propogateState(void)
+{
+  for(CParseNode *cn=(CParseNode *)(nodeList->begin()); !nodeList->end(); cn=(CParseNode *)(nodeList->next())) {
+    cn->propogateState(0);
+  }
+}
+
+void CParsedFile::generateEntryList(void)
+{
+  for(CParseNode *cn=(CParseNode *)(nodeList->begin()); !nodeList->end(); cn=(CParseNode *)(nodeList->next())) {
+    cn->generateEntryList(entryList, 0);
+  }
+}
+
+void CParsedFile::generateCode(void)
+{
+  for(CParseNode *cn=(CParseNode *)(nodeList->begin()); !nodeList->end(); cn=(CParseNode *)(nodeList->next())) {
+    cn->setNext(0,0);
+    cn->generateCode();
+  }
+}
+
+void CParsedFile::generateEntries(void)
+{
+  CEntry *en;
+  pH(0,"public:\n");
+  for(en=(CEntry *)(entryList->begin()); !entryList->end(); en=(CEntry *)(entryList->next())) {
+    en->generateCode(className);
+  }
+}
+
+void CParsedFile::generateInitFunction(void)
+{
+  pH(0,"private:\n");
+  pH(1,"CDep *__cDep;\n");
+  // pH(1,"void __sdag_init(void);\n");
+
+  pH(1,"void __sdag_init(void) {\n");
+  pH(2,"__cDep = new CDep(%d, %d);\n", numEntries, numWhens);
+  CEntry *en;
+  for(en=(CEntry *)(entryList->begin()); !entryList->end(); en=(CEntry *)(entryList->next())) {
+    en->generateDeps();
+  }
+  pH(1,"}\n");
+}
diff --git a/src/langs/sdag/xlator/CParsedFile.h b/src/langs/sdag/xlator/CParsedFile.h
new file mode 100644 (file)
index 0000000..eb1b74d
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef _CParsedFile_H_
+#define _CParsedFile_H_
+
+#include "CString.h"
+#include "CList.h"
+#include "CEntry.h"
+#include "CParseNode.h"
+#include "sdag-globals.h"
+#include <stdio.h>
+
+class CParsedFile {
+  private:
+    void numberNodes(void);
+    void labelNodes(void);
+    void propogateState(void);
+    void generateEntryList(void);
+    void generateCode(void);
+    void generateEntries(void);
+    void generateInitFunction(void);
+  public:
+    CString *className;
+    CString *sourceFile;
+    TList *entryList;
+    TList *nodeList;
+    CParsedFile(char *sFile): className(0) {
+      sourceFile = new CString(sFile);
+      entryList = new TList();
+      nodeList = new TList();
+    }
+    ~CParsedFile(void){}
+    void print(int indent);
+    void doProcess(void) {
+      numberNodes();
+      labelNodes();
+      propogateState();
+      generateEntryList();
+      CString *fCname = new CString(sourceFile);
+      fCname->append(".C");
+      fC = fopen(fCname->charstar(), "w");
+      CString *fhname = new CString(sourceFile);
+      fhname->append(".h");
+      fh = fopen(fhname->charstar(), "w");
+      generateCode();
+      generateEntries();
+      generateInitFunction();
+      fclose(fC);
+      fclose(fh);
+    }
+};
+
+#endif
diff --git a/src/langs/sdag/xlator/CParser.C b/src/langs/sdag/xlator/CParser.C
new file mode 100644 (file)
index 0000000..5163e4f
--- /dev/null
@@ -0,0 +1,82 @@
+#include "CParser.h"
+
+CToken *CParser::lookForToken(EToken t)
+{
+  CToken *tok;
+  while((tok=cLexer->getNextToken()) !=0) {
+    if(tok->type == NEW_LINE) {
+      delete tok;
+      continue;
+    }
+    if(tok->type == t) {
+      return tok;
+    } else {
+      fprintf(stderr, "Syntax Error near line %d, char %d\n",
+                      cLexer->lineNum, cLexer->charNum);
+      exit(1);
+    }
+  }
+  return (CToken *) 0; // End of File
+}
+
+CToken *CParser::lookForToken2(EToken t1, EToken t2)
+{
+  CToken *tok;
+  while((tok=cLexer->getNextToken()) !=0) {
+    if(tok->type == NEW_LINE) {
+      delete tok;
+      continue;
+    }
+    if(tok->type == t1 || tok->type == t2) {
+      return tok;
+    } else
+      break;
+  }
+  fprintf(stderr, "Syntax Error near line %d, char %d\n",
+                  cLexer->lineNum, cLexer->charNum);
+  exit(1);
+  return (CToken *) 0; // Just to satisfy the compiler
+}
+
+CToken *CParser::lookForStatement(void)
+{
+  CToken *tok;
+  while((tok=cLexer->getNextToken()) !=0) {
+    if(tok->type == NEW_LINE) {
+      delete tok;
+      continue;
+    }
+    if(tok->type == OVERLAP ||
+       tok->type == WHEN ||
+       tok->type == FOR ||
+       tok->type == IF ||
+       tok->type == WHILE ||
+       tok->type == ATOMIC ||
+       tok->type == FORALL) {
+      return tok;
+    } else
+      break;
+  }
+  fprintf(stderr, "Syntax Error near line %d, char %d\n",
+                  cLexer->lineNum, cLexer->charNum);
+  exit(1);
+  return (CToken *) 0; // Just to satisfy the compiler
+}
+
+CParsedFile *CParser::doParse(void)
+{
+  CParsedFile *cParsedFile = new CParsedFile(sourceFile);
+  CToken *tok;
+
+  tok = lookForToken(CLASS); delete tok;
+  tok = lookForToken(IDENT);
+  cParsedFile->className = tok->text;
+  while(1) {
+    tok = lookForToken(SDAGENTRY);
+    if(tok == 0)
+      break;
+    cParsedFile->nodeList->append(new CParseNode(SDAGENTRY, cLexer, this));
+  }
+  return cParsedFile;
+}
+
diff --git a/src/langs/sdag/xlator/CParser.h b/src/langs/sdag/xlator/CParser.h
new file mode 100644 (file)
index 0000000..02e8a14
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef _CParser_H_
+#define _CParser_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "CLexer.h"
+#include "CParsedFile.h"
+#include "CToken.h"
+#include "sdag-globals.h"
+
+class CParser {
+  private:
+    CLexer *cLexer;
+    char *sourceFile;
+
+  public:
+    CParser(char *filename) {
+      sourceFile = filename;
+      cLexer = new CLexer();
+      if(cLexer->sourceFile(filename) == 0) {
+        fprintf(stderr, "sdagx: Cannot open file %s for reading !\n", filename);
+        exit(1);
+      }
+    }
+
+    ~CParser(void) {;}
+
+    CParsedFile *doParse(void);
+    CToken *lookForToken(EToken t);
+    CToken *lookForToken2(EToken t1, EToken t2);
+    CToken *lookForStatement(void);
+};
+
+#endif
diff --git a/src/langs/sdag/xlator/CStateVar.h b/src/langs/sdag/xlator/CStateVar.h
new file mode 100644 (file)
index 0000000..cf91efe
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef _CStateVar_H_
+#define _CStateVar_H_
+
+#include "CString.h"
+
+class CStateVar {
+  public:
+    CString *type;
+    CString *name;
+    CStateVar(CString *t, CString *n) : type(t), name(n) {}
+};
+
+#endif
diff --git a/src/langs/sdag/xlator/CString.h b/src/langs/sdag/xlator/CString.h
new file mode 100644 (file)
index 0000000..d020870
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef _CString_H_
+#define _CString_H_
+
+#include <string.h>
+#include <stdio.h>
+#include "sdag-globals.h"
+
+class CString {
+  private:
+    unsigned int len;
+    unsigned int stringlen;
+    char *text;
+  public:
+    CString(int initlen=128)
+    {
+      len = initlen;
+      stringlen = 0;
+      text = new char[initlen];
+      text[0] = '\0';
+    }
+    CString(const char *txt)
+    {
+      stringlen = strlen(txt);
+      len = (stringlen+1)*2;
+      text = new char[len];
+      strcpy(text, txt);
+    }
+    CString(CString *str)
+    {
+      stringlen = str->length();
+      len = (stringlen+1)*2;
+      text = new char[len];
+      strcpy(text, str->charstar());
+    }
+    ~CString(){
+      // delete[] text;
+    }
+    void append(char *txt)
+    {
+      stringlen += strlen(txt);
+      while (stringlen>=len)
+        len *= 2;
+      char *newstr = new char[len];
+      strcpy(newstr, text);
+      strcat(newstr, txt);
+      delete[] text;
+      text = newstr;
+    }
+    void append(CString* cstr)
+    {
+      char *txt = cstr->charstar();
+      stringlen += cstr->length();
+      while (stringlen>=len)
+        len *= 2;
+      char *newstr = new char[len];
+      strcpy(newstr, text);
+      strcat(newstr, txt);
+      delete[] text;
+      text = newstr;
+    }
+    unsigned int length(void)
+    {
+      return stringlen;
+    }
+    char *charstar(void)
+    {
+      return text;
+    }
+    void print(int indent) {
+      Indent(indent);
+      printf("%s", text);
+    }
+    int equal(CString *another) {
+      return (strcmp(text, another->text)==0) ? 1 : 0;
+    }
+};
+
+#endif /* _CString_H_ */
diff --git a/src/langs/sdag/xlator/CToken.h b/src/langs/sdag/xlator/CToken.h
new file mode 100644 (file)
index 0000000..498b880
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef _CToken_H_
+#define _CToken_H_
+
+#include <stdio.h>
+#include "EToken.h"
+#include "CString.h"
+#include "sdag-globals.h"
+
+class CToken {
+  public:
+    EToken type;
+    CString *text;
+    CToken(EToken t, const char *txt)
+    {
+      type = t;
+      text = new CString(txt);
+    }
+    ~CToken()
+    {
+      // delete text;
+    }
+    void print(int indent)
+    {
+      Indent(indent);
+      printf("Token: %d\tText: \"%s\"\n", type, text->charstar());
+    }
+};
+
+#endif /* _CToken_H_ */
diff --git a/src/langs/sdag/xlator/EToken.h b/src/langs/sdag/xlator/EToken.h
new file mode 100644 (file)
index 0000000..6ac2f34
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef _EToken_H_
+#define _EToken_H_
+
+enum EToken {
+   DEFAULT=1
+
+  ,IDENT=2
+  ,LBRACE=3
+  ,RBRACE=4
+  ,LB=5
+  ,RB=6
+  ,LP=7
+  ,RP=8
+  ,COLON=9
+  ,STAR=10
+  ,CHAR=11
+  ,STRING=12
+  ,NEW_LINE=13
+  ,CLASS=14
+  ,ENTRY=15
+  ,SDAGENTRY=16
+  ,OVERLAP=17
+  ,WHEN=18
+  ,IF=19
+  ,WHILE=20
+  ,FOR=21
+  ,FORALL=22
+  ,ATOMIC=23
+  ,COMMA=24
+  ,ELSE=25
+  ,SEMICOLON=26
+
+  ,BRACE_MATCHED_CPP_CODE=100
+  ,PAREN_MATCHED_CPP_CODE=101
+  ,INT_EXPR=102
+  ,WSPACE=103
+  ,SLIST=104
+  ,ELIST=105
+  ,OLIST=106
+};
+
+#endif /* _EToken_H_ */
diff --git a/src/langs/sdag/xlator/Makefile.xlator b/src/langs/sdag/xlator/Makefile.xlator
new file mode 100644 (file)
index 0000000..86c11d5
--- /dev/null
@@ -0,0 +1,38 @@
+COPTS=-seq -O 
+
+sdagx: main.o trans.o CLexer.o CParser.o CParsedFile.o CParseNode.o globals.o CParseNodeProcess.o CEntry.o
+       charmc -o sdagx $(COPTS) -language c++ main.o trans.o CLexer.o CParser.o CParsedFile.o \
+               CParseNode.o globals.o CParseNodeProcess.o CEntry.o
+
+main.o: main.C CLexer.h CToken.h
+       charmc -c $(COPTS) main.C
+
+trans.o: trans.c EToken.h
+       charmc -c $(COPTS) trans.c
+
+trans.c: trans.l
+       flex -otrans.c trans.l
+
+CLexer.o: CLexer.C CLexer.h
+       charmc -c $(COPTS) CLexer.C
+
+CParser.o: CParser.C CParser.h
+       charmc -c $(COPTS) CParser.C
+
+CParsedFile.o: CParsedFile.C CParsedFile.h
+       charmc -c $(COPTS) CParsedFile.C
+
+CParseNode.o: CParseNode.C CParseNode.h
+       charmc -c $(COPTS) CParseNode.C
+
+globals.o: globals.C globals.h
+       charmc -c $(COPTS) globals.C
+
+CParseNodeProcess.o: CParseNodeProcess.C CParseNode.h
+       charmc -c $(COPTS) CParseNodeProcess.C
+
+CEntry.o: CEntry.C CEntry.h
+       charmc -c $(COPTS) CEntry.C
+
+clean:
+       rm -rf sdagx trans.c *.o ptrepository ii_files *.ii
diff --git a/src/langs/sdag/xlator/example.txt b/src/langs/sdag/xlator/example.txt
new file mode 100644 (file)
index 0000000..b5fe1a6
--- /dev/null
@@ -0,0 +1,194 @@
+Structured Dagger Code:
+=======================
+forall [i] (1:N,1) {
+  atomic { 
+    sum[i] = 0;
+  }
+  forall [j] (M:1,-1) {
+    when e1[i-1](MSG *m1), e2[j-1](MSG *m2) {
+      atomic {
+        sum[i] += m1->data * m2->data;
+      }
+    }
+  }
+  atomic {
+    CPrintf("Sum = %d\n", sum[i]);
+  }
+}
+
+Translated Code:
+================
+forall_1_begin()
+{
+  int start = 1, end = N, incr = 1;
+  if (start > end) {
+    swap(&start, &end);
+    incr = -incr;
+  }
+  Counter *c1 = new Counter(1,N,1)
+  for(int i=start; i != end; i+=incr) {
+    _slist_1_begin(i, c1);
+  }
+  forall_1_end(c1);
+}
+
+forall_1_end(Counter *c1)
+{
+  c1->done();
+  if(c1->finished()) {
+    delete c1;
+    // call next
+  }
+}
+
+slist_1_begin(int i, Counter *c1)
+{
+  atomic_1(i, c1);
+}
+
+slist_1_end(int i, Counter *c1)
+{
+  forall_1_end(c1);
+}
+
+forall_2_begin(int i, Counter *c1)
+{
+  int start = M, end = 1, incr = -1;
+  if (start > end) {
+    swap(&start, &end);
+    incr = -incr;
+  }
+  if(start > end)
+  Counter *c2 = new Counter(M,1,-1);
+  for(int j=start; j >= end; j+= incr) {
+    when_1(i, j, c1, c2);
+  }
+  forall_2_end(i, c1, c2);
+}
+
+forall_2_end(int i, Counter *c1, Counter *c2)
+{
+  c2->done();
+  if(c2->finished()) {
+    delete c2;
+    atomic_3(i, c1);
+  }
+}
+
+#define E1     1
+#define E2     1
+
+#define WHEN_1 1
+
+int when_1(int i, int j, Counter *c1, Counter *c2)
+{
+  MSG *m1;
+  MSG *m2;
+
+  m1 = e1_A->access(i-1);
+  m2 = e2_A->access(j-1);
+  if(m1 != 0 && m2 != 0) {
+    m1 = e1_A->remove(i-1);
+    m2 = e2_A->remove(j-1);
+    atomic_2(i,j,m1,m2,c1,c2);
+    return 1;
+  } else {
+    int *tmp_entry = new int[2];
+    int *tmp_ref = new int[2];
+    size_t *args = new size_t[4];
+    tmp_entry[0] = E1;
+    tmp_ref[0] = i-1;
+    tmp_entry[1] = E2;
+    tmp_ref[0] = j-1;
+    args[0] = i;
+    args[1] = j;
+    args[2] = c1;
+    args[3] = c2;
+    when_1_A->register(2, tmp_entry, tmp_ref, args);
+    return 0;
+  }
+}
+
+atomic_1(int i, Counter *c1)
+{
+  {
+    sum[i] = 0;
+  }
+  forall_2_begin(i, c1);
+}
+
+atomic_2(int i, int j, MSG *m1, MSG *m2, Counter *c1, Counter *c2)
+{
+  {
+    sum[i] += m1->data * m2->data;
+  }
+  forall_2_end(i, c1, c2);
+}
+
+atomic_3(int i, Counter *c1)
+{
+  {
+    CPrintf("Sum = %d\n", sum[i]);
+  }
+  slist_1_end(i, c1);
+}
+
+void e1(MSG *m)
+{
+  int refnum = GetRefNum(m);
+  // buffer the message first
+  e1_Buffer->putElement(refnum, m);
+  // get a list of when blocks waiting for this msg
+  TList<someStruct> *e1_A = e1_Buffer->getList(refnum);
+  // no one is waiting, so return
+  if(e1_A == 0) {
+    return;
+  }
+  for(WhenStruct *tmp=e1_A.begin();!e1_A.end();tmp=e1_A.next()){
+    switch(tmp->id) {
+      case WHEN_1:
+        if(tmp->allDependenciesSatisfied()) {
+          // deregister removes element from all entryLists
+          tmp->deregister();
+          when_1(tmp->args[0], tmp->args[1], tmp->args[2], tmp->args[3]);
+          goto out;
+        }
+        break;
+    }
+  }
+out:
+  return;
+}
+
+void e2(MSG *m)
+{
+  int refnum = GetRefNum(m);
+  // buffer the message first
+  e2_Buffer->putElement(refnum, m);
+  // get a list of when blocks waiting for this msg
+  TList<someStruct> *e2_A = e2_Buffer->getList(refnum);
+  // no one is waiting, so return
+  if(e2_A == 0) {
+    return;
+  }
+  for(WhenStruct *tmp=e2_A.begin();!e2_A.end();tmp=e2_A.next()){
+    switch(tmp->id) {
+      case WHEN_1:
+        if(tmp->allDependenciesSatisfied()) {
+          // deregister removes element from all entryLists
+          tmp->deregister();
+          when_1(tmp->args[0], tmp->args[1], tmp->args[2], tmp->args[3]);
+          goto out;
+        }
+        break;
+    }
+  }
+out:
+  return;
+}
+
+_sdag_classname_init()
+{
+  // Initialize all the data structures
+}
+
diff --git a/src/langs/sdag/xlator/grammar.txt b/src/langs/sdag/xlator/grammar.txt
new file mode 100644 (file)
index 0000000..9c1ec09
--- /dev/null
@@ -0,0 +1,48 @@
+Tokens:
+  <ident>
+  <int-expr>
+  <brace-matched-c++-code>
+  <parenthesis-matched-c++-code>
+
+Grammar in EBNF Form:
+
+<sdag> := <class-decl> <sdagentry>+
+
+<class-decl> := "class" <ident>
+
+<sdagentry> := "sdagentry" <ident> "(" <ident> "*" <ident> ")" <body>
+
+<body> := <stmt>
+        | "{" <stmt>+ "}"
+
+<stmt> := <overlap-stmt>
+        | <when-stmt>
+        | <atomic-stmt>
+        | <if-stmt>
+        | <while-stmt>
+        | <for-stmt>
+        | <forall-stmt>
+        
+<overlap-stmt> := "overlap" <body>
+
+<atomic-stmt> := "atomic" <brace-matched-C++-code>
+
+<if-stmt> := "if" <parenthesis-matched-c++-condition> <body> [<else-stmt>]
+
+<else-stmt> := "else" <body>
+
+<while-stmt> := "while" <parenthesis-matched-c++-condition> <body>
+
+<for-stmt> := "for" <parenthesis-matched-c++-condition> <body>
+
+<forall-stmt> := "forall" "[" <ident> "]" "(" <range-stride> ")" <body>
+
+<range-stride> := <int-expr> ":" <int-expr> "," <int-expr>
+
+<when-stmt> := "when" <entry-list>  <body>
+
+<entry-list> := <entry>
+              | <entry> [ "," <entry-list> ]
+              
+<entry> := <ident> [ "[" <int-expr> "]" ] "(" <ident> "*" <ident> ")"
+
diff --git a/src/langs/sdag/xlator/sdag-globals.C b/src/langs/sdag/xlator/sdag-globals.C
new file mode 100644 (file)
index 0000000..6312387
--- /dev/null
@@ -0,0 +1,63 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include "sdag-globals.h"
+
+void Indent(int indent)
+{
+  for(int i=0;i<indent;i++)
+    printf("  ");
+}
+
+int numSdagEntries=0;
+int numSlists=0;
+int numOverlaps=0;
+int numWhens=0;
+int numFors=0;
+int numIfs=0;
+int numElses=0;
+int numEntries=0;
+int numOlists=0;
+int numWhiles=0;
+int numAtomics=0;
+int numForalls=0;
+
+FILE *fC, *fh;
+
+void pC(int indent, const char *format, ...)
+{
+  va_list args;
+
+  va_start(args, format);
+  for(int i=0;i<indent;i++)
+    fprintf(fC, "  ");
+  vfprintf(fC, format, args);
+  va_end(args);
+}
+
+void pH(int indent, const char *format, ...)
+{
+  va_list args;
+
+  va_start(args, format);
+  for(int i=0;i<indent;i++)
+    fprintf(fh, "  ");
+  vfprintf(fh, format, args);
+  va_end(args);
+}
+
+void resetNumbers(void)
+{
+  numSdagEntries=0;
+  numSlists=0;
+  numOverlaps=0;
+  numWhens=0;
+  numFors=0;
+  numIfs=0;
+  numElses=0;
+  numEntries=0;
+  numOlists=0;
+  numWhiles=0;
+  numAtomics=0;
+  numForalls=0;
+}
+
diff --git a/src/langs/sdag/xlator/sdag-globals.h b/src/langs/sdag/xlator/sdag-globals.h
new file mode 100644 (file)
index 0000000..538fdc6
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef _GLOBALS_H_
+#define _GLOBALS_H_
+
+#include <stdio.h>
+#include <stdarg.h>
+
+extern void Indent(int indent);
+
+extern int numSdagEntries;
+extern int numSlists;
+extern int numOverlaps;
+extern int numWhens;
+extern int numFors;
+extern int numIfs;
+extern int numElses;
+extern int numEntries;
+extern int numOlists;
+extern int numWhiles;
+extern int numAtomics;
+extern int numForalls;
+
+extern FILE *fC;
+extern FILE *fh;
+
+extern void pC(int, const char *, ...);
+extern void pH(int, const char *, ...);
+extern void resetNumbers(void);
+
+#endif
diff --git a/src/langs/sdag/xlator/sdag-main.C b/src/langs/sdag/xlator/sdag-main.C
new file mode 100644 (file)
index 0000000..a391f56
--- /dev/null
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "CLexer.h"
+#include "CToken.h"
+#include "CParsedFile.h"
+#include "CParser.h"
+#include "sdag-globals.h"
+
+void Usage(void)
+{
+  fprintf(stderr, "Usage: sdagx <filename>\n");
+}
+
+int main(int argc, char *argv[])
+{
+  if(argc<2) {
+    Usage();
+    exit(1);
+  }
+  for(int i=1; i<argc; i++) {
+    resetNumbers();
+    printf("%s:\n", argv[i]);
+    CParser *cParser = new CParser(argv[i]);
+    CParsedFile *parsedFile = cParser->doParse();
+    parsedFile->doProcess();
+    // parsedFile->print(0);
+    delete parsedFile;
+    delete cParser;
+  }
+  exit(0);
+}
diff --git a/src/langs/sdag/xlator/trans.c b/src/langs/sdag/xlator/trans.c
new file mode 100644 (file)
index 0000000..4c36ebd
--- /dev/null
@@ -0,0 +1,1854 @@
+#line 2 "trans.c"
+/* A lexical scanner generated by flex */
+
+/* Scanner skeleton version:
+ * $Header$
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else  /* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif /* __STDC__ */
+#endif /* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator).  This
+ * avoids problems with code like:
+ *
+ *     if ( condition_holds )
+ *             yyless( 5 );
+ *     else
+ *             do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the yyless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define yyless(n) \
+       do \
+               { \
+               /* Undo effects of setting up yytext. */ \
+               *yy_cp = yy_hold_char; \
+               yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+               YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+               } \
+       while ( 0 )
+
+#define unput(c) yyunput( c, yytext_ptr )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int yy_size_t;
+
+
+struct yy_buffer_state
+       {
+       FILE *yy_input_file;
+
+       char *yy_ch_buf;                /* input buffer */
+       char *yy_buf_pos;               /* current position in input buffer */
+
+       /* Size of input buffer in bytes, not including room for EOB
+        * characters.
+        */
+       yy_size_t yy_buf_size;
+
+       /* Number of characters read into yy_ch_buf, not including EOB
+        * characters.
+        */
+       int yy_n_chars;
+
+       /* Whether we "own" the buffer - i.e., we know we created it,
+        * and can realloc() it to grow it, and should free() it to
+        * delete it.
+        */
+       int yy_is_our_buffer;
+
+       /* Whether this is an "interactive" input source; if so, and
+        * if we're using stdio for input, then we want to use getc()
+        * instead of fread(), to make sure we stop fetching input after
+        * each newline.
+        */
+       int yy_is_interactive;
+
+       /* Whether we're considered to be at the beginning of a line.
+        * If so, '^' rules will be active on the next match, otherwise
+        * not.
+        */
+       int yy_at_bol;
+
+       /* Whether to try to fill the input buffer when we reach the
+        * end of it.
+        */
+       int yy_fill_buffer;
+
+       int yy_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+       /* When an EOF's been seen but there's still some text to process
+        * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+        * shouldn't try reading from the input source any more.  We might
+        * still have a bunch of tokens to match, though, because of
+        * possible backing-up.
+        *
+        * When we actually see the EOF, we change the status to "new"
+        * (via yyrestart()), so that the user can continue scanning by
+        * just pointing yyin at a new input file.
+        */
+#define YY_BUFFER_EOF_PENDING 2
+       };
+
+static YY_BUFFER_STATE yy_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+
+static int yy_n_chars;         /* number of characters read into yy_ch_buf */
+
+
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1;                /* whether we need to initialize */
+static int yy_start = 0;       /* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin.  A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart YY_PROTO(( FILE *input_file ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+       { \
+       if ( ! yy_current_buffer ) \
+               yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+       yy_current_buffer->yy_is_interactive = is_interactive; \
+       }
+
+#define yy_set_bol(at_bol) \
+       { \
+       if ( ! yy_current_buffer ) \
+               yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+       yy_current_buffer->yy_at_bol = at_bol; \
+       }
+
+#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+
+typedef unsigned char YY_CHAR;
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+typedef int yy_state_type;
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+       yytext_ptr = yy_bp; \
+       yyleng = (int) (yy_cp - yy_bp); \
+       yy_hold_char = *yy_cp; \
+       *yy_cp = '\0'; \
+       yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 47
+#define YY_END_OF_BUFFER 48
+static yyconst short int yy_accept[136] =
+    {   0,
+        0,    0,   48,   47,    2,    4,    3,   34,   47,   28,
+       36,   30,   47,   18,   19,   24,   31,   26,   32,   29,
+       35,   44,   43,   25,   27,   37,   42,   38,   41,   15,
+       15,   20,   21,   39,   15,   15,   15,   15,   15,   15,
+       15,   15,   22,   40,   23,   33,    2,    4,    0,    3,
+        0,   17,    0,    0,    0,   46,    1,   46,   44,    0,
+        0,   44,   44,    0,   43,   43,   43,   15,    0,    0,
+       15,   15,   15,   15,    9,   15,   15,   15,    0,    0,
+       16,    0,    0,    0,   46,    1,    0,   46,   44,   45,
+       43,   15,   15,   15,   13,   15,   15,   15,   15,    0,
+
+        0,    0,    0,    0,   46,   45,   45,   15,   15,   10,
+       15,   15,   15,    8,   15,    0,    0,    0,    0,   45,
+       15,    5,   15,   15,   15,   11,   14,   12,   15,   15,
+        7,   15,   15,    6,    0
+    } ;
+
+static yyconst int yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        4,    5,    6,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    7,    8,    9,   10,    1,   11,   12,   13,   14,
+       15,   16,   17,   18,   19,   20,   21,   22,   23,   23,
+       23,   23,   23,   23,   23,   24,   24,   25,   26,   27,
+       28,   29,   30,    1,   31,   31,   31,   31,   32,   33,
+       34,   34,   34,   34,   34,   35,   34,   34,   34,   34,
+       34,   34,   34,   34,   36,   34,   34,   37,   34,   34,
+       38,   39,   40,   41,   34,    1,   42,   43,   44,   45,
+
+       46,   47,   48,   49,   50,   34,   34,   51,   52,   53,
+       54,   55,   34,   56,   57,   58,   36,   59,   60,   61,
+       62,   34,   63,   64,   65,   66,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static yyconst int yy_meta[67] =
+    {   0,
+        1,    1,    2,    1,    1,    1,    1,    1,    3,    1,
+        1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
+        1,    5,    5,    6,    1,    1,    1,    1,    1,    3,
+        6,    6,    6,    7,    7,    7,    7,    1,    3,    1,
+        1,    5,    5,    6,    6,    6,    5,    7,    7,    7,
+        7,    7,    8,    7,    7,    8,    7,    8,    8,    7,
+        8,    7,    1,    1,    1,    1
+    } ;
+
+static yyconst short int yy_base[145] =
+    {   0,
+        0,    0,  280,  388,   65,  388,   71,  388,   70,  388,
+      388,  388,  240,  388,  388,  388,  388,  388,  388,   58,
+      257,   90,   65,  388,  388,  388,  388,  388,  388,    0,
+       77,  388,  388,  388,  219,  225,  224,  220,  226,  212,
+      224,  217,  388,  388,  388,  388,   89,  388,  100,  126,
+       99,  388,   76,  104,   96,  123,    0,  130,  160,  166,
+      149,  229,   88,    0,  181,  227,   89,    0,  111,  223,
+      204,  215,  199,  199,    0,  208,  211,   98,  185,    0,
+      388,  187,    0,  206,  388,    0,  137,  198,  388,  183,
+      388,  200,  189,  198,  201,  186,  188,  182,  164,  228,
+
+      259,  225,  294,  217,  237,  178,  140,  152,  142,    0,
+      146,  136,  139,    0,  133,  125,    0,  154,    0,  388,
+      134,    0,   98,  100,   82,    0,    0,    0,   66,   57,
+        0,   28,   21,    0,  388,  341,  349,  353,  359,  365,
+      373,  377,  379,  381
+    } ;
+
+static yyconst short int yy_def[145] =
+    {   0,
+      135,    1,  135,  135,  135,  135,  135,  135,  136,  135,
+      135,  135,  137,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  138,
+      138,  135,  135,  135,  138,  138,  138,  138,  138,  138,
+      138,  138,  135,  135,  135,  135,  135,  135,  135,  135,
+      136,  135,  139,  137,  140,  135,  141,  135,  135,  135,
+      135,  135,  135,  142,  135,  135,  135,  138,  136,  137,
+      138,  138,  138,  138,  138,  138,  138,  138,  136,  143,
+      135,  137,  144,  135,  135,  141,  135,  135,  135,  142,
+      135,  138,  138,  138,  138,  138,  138,  138,  138,  136,
+
+      136,  137,  137,  135,  135,  135,  135,  138,  138,  138,
+      138,  138,  138,  138,  138,  136,  101,  137,  103,  135,
+      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
+      138,  138,  138,  138,    0,  135,  135,  135,  135,  135,
+      135,  135,  135,  135
+    } ;
+
+static yyconst short int yy_nxt[455] =
+    {   0,
+        4,    5,    6,    7,    7,    7,    5,    8,    9,   10,
+       11,   12,   13,   14,   15,   16,   17,   18,   19,   20,
+       21,   22,   23,   23,   24,   25,   26,   27,   28,   29,
+       30,   30,   30,   30,   31,   30,   30,   32,    4,   33,
+       34,   35,   30,   36,   30,   37,   38,   30,   30,   39,
+       30,   30,   30,   40,   30,   30,   41,   30,   30,   42,
+       30,   30,   43,   44,   45,   46,   47,   48,   49,   49,
+       49,   47,   49,   48,   50,   50,   50,   49,   52,   56,
+       56,   56,  134,  133,   58,   69,   65,   65,   65,   70,
+       47,   48,   49,   49,   49,   47,   61,   79,   79,   66,
+
+       67,   49,   48,   49,   49,   49,   49,   52,   53,   58,
+       61,   59,   59,   60,  132,   66,   81,   82,   82,   52,
+      131,   61,   89,   91,   62,   63,   64,   49,   48,   50,
+       50,   50,   49,   52,  130,   61,   80,   53,   89,   91,
+       62,  129,   55,   98,   56,   56,   56,   99,  128,   53,
+       64,   56,   56,   56,   84,   85,   83,   85,   88,   88,
+       88,   84,   85,   53,   85,   87,   81,   87,   84,   85,
+       88,   88,   88,   85,  120,   84,   85,  127,  126,   58,
+       85,   59,   59,   60,  125,   58,  124,   60,   60,   60,
+      120,   61,   55,   52,   62,   63,  123,   61,  122,   81,
+
+       58,  121,   65,   65,   65,   61,  100,  100,  102,  102,
+       62,   61,   61,  120,  115,   66,   67,  106,  107,   88,
+       88,   88,  104,   53,  104,   55,   61,  105,  105,  105,
+       85,   66,   85,  106,  114,  113,   52,   81,  105,  105,
+      105,  112,  111,  110,   85,  109,  118,  118,   85,  116,
+      116,  108,   97,   96,   95,   94,   93,   92,  105,  105,
+      105,   55,   91,   55,   89,   78,   53,   52,   77,   85,
+       76,   85,   75,   74,   73,   72,   71,   57,   55,  135,
+      117,  117,  117,   85,  135,  135,  135,   85,  135,  117,
+      117,  117,  135,  135,  135,  135,  135,   53,  135,  135,
+
+      117,  117,  117,  117,  117,  117,   81,  135,  135,  135,
+      135,  135,  135,  135,  135,  119,  119,  119,  135,  135,
+      135,  135,  135,  135,  119,  119,  119,  135,  135,  135,
+      135,  135,   55,  135,  135,  119,  119,  119,  119,  119,
+      119,   51,  135,   51,   51,   51,   51,   51,   51,   54,
+      135,   54,  135,   54,   54,   54,   54,   68,   68,   68,
+       68,   51,   51,   51,  135,  135,   51,   54,   54,   54,
+      135,  135,   54,   86,  135,   86,   86,   86,   86,   86,
+       86,   90,   90,  101,  101,  103,  103,    3,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135
+    } ;
+
+static yyconst short int yy_chk[455] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    5,    5,    5,    5,
+        5,    5,    7,    7,    7,    7,    7,    7,    9,   20,
+       20,   20,  133,  132,   23,   31,   23,   23,   23,   31,
+       47,   47,   47,   47,   47,   47,   23,   53,   53,   23,
+
+       23,   49,   49,   49,   49,   49,   49,   51,    9,   22,
+       23,   22,   22,   22,  130,   23,   54,   55,   55,   69,
+      129,   22,   63,   67,   22,   22,   22,   50,   50,   50,
+       50,   50,   50,  116,  125,   22,   53,   51,   63,   67,
+       22,  124,   54,   78,   56,   56,   56,   78,  123,   69,
+       22,   58,   58,   58,   56,   56,   55,   56,   87,   87,
+       87,   58,   58,  116,   58,   61,  118,   61,   56,   56,
+       61,   61,   61,   56,  107,   58,   58,  121,  115,   59,
+       58,   59,   59,   59,  113,   60,  112,   60,   60,   60,
+      107,   59,  118,   79,   59,   59,  111,   60,  109,   82,
+
+       65,  108,   65,   65,   65,   59,   79,   79,   82,   82,
+       59,   60,   65,  106,   99,   65,   65,   90,   90,   88,
+       88,   88,   84,   79,   84,   82,   65,   84,   84,   84,
+       88,   65,   88,   90,   98,   97,  100,  102,  104,  104,
+      104,   96,   95,   94,   88,   93,  102,  102,   88,  100,
+      100,   92,   77,   76,   74,   73,   72,   71,  105,  105,
+      105,   70,   66,  102,   62,   42,  100,  101,   41,  105,
+       40,  105,   39,   38,   37,   36,   35,   21,   13,    3,
+      101,  101,  101,  105,    0,    0,    0,  105,    0,  101,
+      101,  101,    0,    0,    0,    0,    0,  101,    0,    0,
+
+      101,  101,  101,  101,  101,  101,  103,    0,    0,    0,
+        0,    0,    0,    0,    0,  103,  103,  103,    0,    0,
+        0,    0,    0,    0,  103,  103,  103,    0,    0,    0,
+        0,    0,  103,    0,    0,  103,  103,  103,  103,  103,
+      103,  136,    0,  136,  136,  136,  136,  136,  136,  137,
+        0,  137,    0,  137,  137,  137,  137,  138,  138,  138,
+      138,  139,  139,  139,    0,    0,  139,  140,  140,  140,
+        0,    0,  140,  141,    0,  141,  141,  141,  141,  141,
+      141,  142,  142,  143,  143,  144,  144,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
+      135,  135,  135,  135
+    } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+char *yytext;
+#line 1 "trans.l"
+#define INITIAL 0
+#line 2 "trans.l"
+#include "EToken.h"
+
+/* Assume that the C-style comments are not present in the source */
+
+#line 515 "trans.c"
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap YY_PROTO(( void ));
+#else
+extern int yywrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int yy_start_stack_ptr = 0;
+static int yy_start_stack_depth = 0;
+static int *yy_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void yy_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines.  This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+       if ( yy_current_buffer->yy_is_interactive ) \
+               { \
+               int c = '*', n; \
+               for ( n = 0; n < max_size && \
+                            (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+                       buf[n] = (char) c; \
+               if ( c == '\n' ) \
+                       buf[n++] = (char) c; \
+               if ( c == EOF && ferror( yyin ) ) \
+                       YY_FATAL_ERROR( "input in flex scanner failed" ); \
+               result = n; \
+               } \
+       else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
+                 && ferror( yyin ) ) \
+               YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int yylex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+       YY_USER_ACTION
+
+YY_DECL
+       {
+       register yy_state_type yy_current_state;
+       register char *yy_cp, *yy_bp;
+       register int yy_act;
+
+#line 31 "trans.l"
+
+
+#line 665 "trans.c"
+
+       if ( yy_init )
+               {
+               yy_init = 0;
+
+#ifdef YY_USER_INIT
+               YY_USER_INIT;
+#endif
+
+               if ( ! yy_start )
+                       yy_start = 1;   /* first start state */
+
+               if ( ! yyin )
+                       yyin = stdin;
+
+               if ( ! yyout )
+                       yyout = stdout;
+
+               if ( ! yy_current_buffer )
+                       yy_current_buffer =
+                               yy_create_buffer( yyin, YY_BUF_SIZE );
+
+               yy_load_buffer_state();
+               }
+
+       while ( 1 )             /* loops until end-of-file is reached */
+               {
+               yy_cp = yy_c_buf_p;
+
+               /* Support of yytext. */
+               *yy_cp = yy_hold_char;
+
+               /* yy_bp points to the position in yy_ch_buf of the start of
+                * the current run.
+                */
+               yy_bp = yy_cp;
+
+               yy_current_state = yy_start;
+yy_match:
+               do
+                       {
+                       register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+                       if ( yy_accept[yy_current_state] )
+                               {
+                               yy_last_accepting_state = yy_current_state;
+                               yy_last_accepting_cpos = yy_cp;
+                               }
+                       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+                               {
+                               yy_current_state = (int) yy_def[yy_current_state];
+                               if ( yy_current_state >= 136 )
+                                       yy_c = yy_meta[(unsigned int) yy_c];
+                               }
+                       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+                       ++yy_cp;
+                       }
+               while ( yy_base[yy_current_state] != 388 );
+
+yy_find_action:
+               yy_act = yy_accept[yy_current_state];
+               if ( yy_act == 0 )
+                       { /* have to back up */
+                       yy_cp = yy_last_accepting_cpos;
+                       yy_current_state = yy_last_accepting_state;
+                       yy_act = yy_accept[yy_current_state];
+                       }
+
+               YY_DO_BEFORE_ACTION;
+
+
+do_action:     /* This label is used only to access EOF actions. */
+
+
+               switch ( yy_act )
+       { /* beginning of action switch */
+                       case 0: /* must back up */
+                       /* undo the effects of YY_DO_BEFORE_ACTION */
+                       *yy_cp = yy_hold_char;
+                       yy_cp = yy_last_accepting_cpos;
+                       yy_current_state = yy_last_accepting_state;
+                       goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 33 "trans.l"
+{return WSPACE;}
+       YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 35 "trans.l"
+{return WSPACE;}
+       YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 36 "trans.l"
+{return WSPACE;}
+       YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 37 "trans.l"
+{return(NEW_LINE);}
+       YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 40 "trans.l"
+{return(CLASS);}
+       YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 41 "trans.l"
+{return(SDAGENTRY);}
+       YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 42 "trans.l"
+{return(OVERLAP);}
+       YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 43 "trans.l"
+{return(WHEN);}
+       YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 44 "trans.l"
+{return(IF);}
+       YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 45 "trans.l"
+{return(ELSE);}
+       YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 46 "trans.l"
+{return(WHILE);}
+       YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 47 "trans.l"
+{return(FORALL);}
+       YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 48 "trans.l"
+{return(FOR);}
+       YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 49 "trans.l"
+{return(ATOMIC);}
+       YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 51 "trans.l"
+{return(IDENT);}
+       YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 53 "trans.l"
+{return(CHAR);}
+       YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 54 "trans.l"
+{return(STRING);}
+       YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 56 "trans.l"
+{return(LP);}
+       YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 57 "trans.l"
+{return(RP);}
+       YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 58 "trans.l"
+{return(LB);}
+       YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 59 "trans.l"
+{return(RB);}
+       YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 60 "trans.l"
+{return(LBRACE);}
+       YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 61 "trans.l"
+{return(RBRACE);}
+       YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 62 "trans.l"
+{return(STAR);}
+       YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 63 "trans.l"
+{return(COLON);}
+       YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 64 "trans.l"
+{return(COMMA);}
+       YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 65 "trans.l"
+{return(SEMICOLON);}
+       YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 67 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 68 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 69 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 70 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 71 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 72 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 73 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 74 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 75 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 76 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 77 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 78 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 79 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 80 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 81 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 83 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 84 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 85 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 46:
+YY_RULE_SETUP
+#line 86 "trans.l"
+{return(DEFAULT);}
+       YY_BREAK
+case 47:
+YY_RULE_SETUP
+#line 88 "trans.l"
+ECHO;
+       YY_BREAK
+#line 983 "trans.c"
+case YY_STATE_EOF(INITIAL):
+       yyterminate();
+
+       case YY_END_OF_BUFFER:
+               {
+               /* Amount of text matched not including the EOB char. */
+               int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+
+               /* Undo the effects of YY_DO_BEFORE_ACTION. */
+               *yy_cp = yy_hold_char;
+
+               if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+                       {
+                       /* We're scanning a new file or input source.  It's
+                        * possible that this happened because the user
+                        * just pointed yyin at a new source and called
+                        * yylex().  If so, then we have to assure
+                        * consistency between yy_current_buffer and our
+                        * globals.  Here is the right place to do so, because
+                        * this is the first action (other than possibly a
+                        * back-up) that will match for the new input source.
+                        */
+                       yy_n_chars = yy_current_buffer->yy_n_chars;
+                       yy_current_buffer->yy_input_file = yyin;
+                       yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+                       }
+
+               /* Note that here we test for yy_c_buf_p "<=" to the position
+                * of the first EOB in the buffer, since yy_c_buf_p will
+                * already have been incremented past the NUL character
+                * (since all states make transitions on EOB to the
+                * end-of-buffer state).  Contrast this with the test
+                * in input().
+                */
+               if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+                       { /* This was really a NUL. */
+                       yy_state_type yy_next_state;
+
+                       yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+
+                       yy_current_state = yy_get_previous_state();
+
+                       /* Okay, we're now positioned to make the NUL
+                        * transition.  We couldn't have
+                        * yy_get_previous_state() go ahead and do it
+                        * for us because it doesn't know how to deal
+                        * with the possibility of jamming (and we don't
+                        * want to build jamming into it because then it
+                        * will run more slowly).
+                        */
+
+                       yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+                       yy_bp = yytext_ptr + YY_MORE_ADJ;
+
+                       if ( yy_next_state )
+                               {
+                               /* Consume the NUL. */
+                               yy_cp = ++yy_c_buf_p;
+                               yy_current_state = yy_next_state;
+                               goto yy_match;
+                               }
+
+                       else
+                               {
+                               yy_cp = yy_c_buf_p;
+                               goto yy_find_action;
+                               }
+                       }
+
+               else switch ( yy_get_next_buffer() )
+                       {
+                       case EOB_ACT_END_OF_FILE:
+                               {
+                               yy_did_buffer_switch_on_eof = 0;
+
+                               if ( yywrap() )
+                                       {
+                                       /* Note: because we've taken care in
+                                        * yy_get_next_buffer() to have set up
+                                        * yytext, we can now set up
+                                        * yy_c_buf_p so that if some total
+                                        * hoser (like flex itself) wants to
+                                        * call the scanner after we return the
+                                        * YY_NULL, it'll still work - another
+                                        * YY_NULL will get returned.
+                                        */
+                                       yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+
+                                       yy_act = YY_STATE_EOF(YY_START);
+                                       goto do_action;
+                                       }
+
+                               else
+                                       {
+                                       if ( ! yy_did_buffer_switch_on_eof )
+                                               YY_NEW_FILE;
+                                       }
+                               break;
+                               }
+
+                       case EOB_ACT_CONTINUE_SCAN:
+                               yy_c_buf_p =
+                                       yytext_ptr + yy_amount_of_matched_text;
+
+                               yy_current_state = yy_get_previous_state();
+
+                               yy_cp = yy_c_buf_p;
+                               yy_bp = yytext_ptr + YY_MORE_ADJ;
+                               goto yy_match;
+
+                       case EOB_ACT_LAST_MATCH:
+                               yy_c_buf_p =
+                               &yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+                               yy_current_state = yy_get_previous_state();
+
+                               yy_cp = yy_c_buf_p;
+                               yy_bp = yytext_ptr + YY_MORE_ADJ;
+                               goto yy_find_action;
+                       }
+               break;
+               }
+
+       default:
+               YY_FATAL_ERROR(
+                       "fatal flex scanner internal error--no action found" );
+       } /* end of action switch */
+               } /* end of scanning one token */
+       } /* end of yylex */
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *     EOB_ACT_LAST_MATCH -
+ *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *     EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+       {
+       register char *dest = yy_current_buffer->yy_ch_buf;
+       register char *source = yytext_ptr;
+       register int number_to_move, i;
+       int ret_val;
+
+       if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+               YY_FATAL_ERROR(
+               "fatal flex scanner internal error--end of buffer missed" );
+
+       if ( yy_current_buffer->yy_fill_buffer == 0 )
+               { /* Don't try to fill the buffer, so this is an EOF. */
+               if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+                       {
+                       /* We matched a singled characater, the EOB, so
+                        * treat this as a final EOF.
+                        */
+                       return EOB_ACT_END_OF_FILE;
+                       }
+
+               else
+                       {
+                       /* We matched some text prior to the EOB, first
+                        * process it.
+                        */
+                       return EOB_ACT_LAST_MATCH;
+                       }
+               }
+
+       /* Try to read more data. */
+
+       /* First move last chars to start of buffer. */
+       number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+
+       for ( i = 0; i < number_to_move; ++i )
+               *(dest++) = *(source++);
+
+       if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+               /* don't do the read, it's not guaranteed to return an EOF,
+                * just force an EOF
+                */
+               yy_n_chars = 0;
+
+       else
+               {
+               int num_to_read =
+                       yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+               while ( num_to_read <= 0 )
+                       { /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+                       YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+                       /* just a shorter name for the current buffer */
+                       YY_BUFFER_STATE b = yy_current_buffer;
+
+                       int yy_c_buf_p_offset =
+                               (int) (yy_c_buf_p - b->yy_ch_buf);
+
+                       if ( b->yy_is_our_buffer )
+                               {
+                               int new_size = b->yy_buf_size * 2;
+
+                               if ( new_size <= 0 )
+                                       b->yy_buf_size += b->yy_buf_size / 8;
+                               else
+                                       b->yy_buf_size *= 2;
+
+                               b->yy_ch_buf = (char *)
+                                       /* Include room in for 2 EOB chars. */
+                                       yy_flex_realloc( (void *) b->yy_ch_buf,
+                                                        b->yy_buf_size + 2 );
+                               }
+                       else
+                               /* Can't grow it, we don't own it. */
+                               b->yy_ch_buf = 0;
+
+                       if ( ! b->yy_ch_buf )
+                               YY_FATAL_ERROR(
+                               "fatal error - scanner input buffer overflow" );
+
+                       yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+                       num_to_read = yy_current_buffer->yy_buf_size -
+                                               number_to_move - 1;
+#endif
+                       }
+
+               if ( num_to_read > YY_READ_BUF_SIZE )
+                       num_to_read = YY_READ_BUF_SIZE;
+
+               /* Read in more data. */
+               YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+                       yy_n_chars, num_to_read );
+               }
+
+       if ( yy_n_chars == 0 )
+               {
+               if ( number_to_move == YY_MORE_ADJ )
+                       {
+                       ret_val = EOB_ACT_END_OF_FILE;
+                       yyrestart( yyin );
+                       }
+
+               else
+                       {
+                       ret_val = EOB_ACT_LAST_MATCH;
+                       yy_current_buffer->yy_buffer_status =
+                               YY_BUFFER_EOF_PENDING;
+                       }
+               }
+
+       else
+               ret_val = EOB_ACT_CONTINUE_SCAN;
+
+       yy_n_chars += number_to_move;
+       yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+       yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+       yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+
+       return ret_val;
+       }
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+static yy_state_type yy_get_previous_state()
+       {
+       register yy_state_type yy_current_state;
+       register char *yy_cp;
+
+       yy_current_state = yy_start;
+
+       for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+               {
+               register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+               if ( yy_accept[yy_current_state] )
+                       {
+                       yy_last_accepting_state = yy_current_state;
+                       yy_last_accepting_cpos = yy_cp;
+                       }
+               while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+                       {
+                       yy_current_state = (int) yy_def[yy_current_state];
+                       if ( yy_current_state >= 136 )
+                               yy_c = yy_meta[(unsigned int) yy_c];
+                       }
+               yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+               }
+
+       return yy_current_state;
+       }
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *     next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+yy_state_type yy_current_state;
+#endif
+       {
+       register int yy_is_jam;
+       register char *yy_cp = yy_c_buf_p;
+
+       register YY_CHAR yy_c = 1;
+       if ( yy_accept[yy_current_state] )
+               {
+               yy_last_accepting_state = yy_current_state;
+               yy_last_accepting_cpos = yy_cp;
+               }
+       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+               {
+               yy_current_state = (int) yy_def[yy_current_state];
+               if ( yy_current_state >= 136 )
+                       yy_c = yy_meta[(unsigned int) yy_c];
+               }
+       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+       yy_is_jam = (yy_current_state == 135);
+
+       return yy_is_jam ? 0 : yy_current_state;
+       }
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void yyunput( int c, register char *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+int c;
+register char *yy_bp;
+#endif
+       {
+       register char *yy_cp = yy_c_buf_p;
+
+       /* undo effects of setting up yytext */
+       *yy_cp = yy_hold_char;
+
+       if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+               { /* need to shift things up to make room */
+               /* +2 for EOB chars. */
+               register int number_to_move = yy_n_chars + 2;
+               register char *dest = &yy_current_buffer->yy_ch_buf[
+                                       yy_current_buffer->yy_buf_size + 2];
+               register char *source =
+                               &yy_current_buffer->yy_ch_buf[number_to_move];
+
+               while ( source > yy_current_buffer->yy_ch_buf )
+                       *--dest = *--source;
+
+               yy_cp += (int) (dest - source);
+               yy_bp += (int) (dest - source);
+               yy_n_chars = yy_current_buffer->yy_buf_size;
+
+               if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+                       YY_FATAL_ERROR( "flex scanner push-back overflow" );
+               }
+
+       *--yy_cp = (char) c;
+
+
+       yytext_ptr = yy_bp;
+       yy_hold_char = *yy_cp;
+       yy_c_buf_p = yy_cp;
+       }
+#endif /* ifndef YY_NO_UNPUT */
+
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+       {
+       int c;
+
+       *yy_c_buf_p = yy_hold_char;
+
+       if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+               {
+               /* yy_c_buf_p now points to the character we want to return.
+                * If this occurs *before* the EOB characters, then it's a
+                * valid NUL; if not, then we've hit the end of the buffer.
+                */
+               if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+                       /* This was really a NUL. */
+                       *yy_c_buf_p = '\0';
+
+               else
+                       { /* need more input */
+                       yytext_ptr = yy_c_buf_p;
+                       ++yy_c_buf_p;
+
+                       switch ( yy_get_next_buffer() )
+                               {
+                               case EOB_ACT_END_OF_FILE:
+                                       {
+                                       if ( yywrap() )
+                                               {
+                                               yy_c_buf_p =
+                                               yytext_ptr + YY_MORE_ADJ;
+                                               return EOF;
+                                               }
+
+                                       if ( ! yy_did_buffer_switch_on_eof )
+                                               YY_NEW_FILE;
+#ifdef __cplusplus
+                                       return yyinput();
+#else
+                                       return input();
+#endif
+                                       }
+
+                               case EOB_ACT_CONTINUE_SCAN:
+                                       yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+                                       break;
+
+                               case EOB_ACT_LAST_MATCH:
+#ifdef __cplusplus
+                                       YY_FATAL_ERROR(
+                                       "unexpected last match in yyinput()" );
+#else
+                                       YY_FATAL_ERROR(
+                                       "unexpected last match in input()" );
+#endif
+                               }
+                       }
+               }
+
+       c = *(unsigned char *) yy_c_buf_p;      /* cast for 8-bit char's */
+       *yy_c_buf_p = '\0';     /* preserve yytext */
+       yy_hold_char = *++yy_c_buf_p;
+
+
+       return c;
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+       {
+       if ( ! yy_current_buffer )
+               yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+       yy_init_buffer( yy_current_buffer, input_file );
+       yy_load_buffer_state();
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+       {
+       if ( yy_current_buffer == new_buffer )
+               return;
+
+       if ( yy_current_buffer )
+               {
+               /* Flush out information for old buffer. */
+               *yy_c_buf_p = yy_hold_char;
+               yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+               yy_current_buffer->yy_n_chars = yy_n_chars;
+               }
+
+       yy_current_buffer = new_buffer;
+       yy_load_buffer_state();
+
+       /* We don't actually know whether we did this switch during
+        * EOF (yywrap()) processing, but the only time this flag
+        * is looked at is after yywrap() is called, so it's safe
+        * to go ahead and always set it.
+        */
+       yy_did_buffer_switch_on_eof = 1;
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+       {
+       yy_n_chars = yy_current_buffer->yy_n_chars;
+       yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+       yyin = yy_current_buffer->yy_input_file;
+       yy_hold_char = *yy_c_buf_p;
+       }
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+       {
+       YY_BUFFER_STATE b;
+
+       b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+       if ( ! b )
+               YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+       b->yy_buf_size = size;
+
+       /* yy_ch_buf has to be 2 characters longer than the size given because
+        * we need to put in 2 end-of-buffer characters.
+        */
+       b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+       if ( ! b->yy_ch_buf )
+               YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+       b->yy_is_our_buffer = 1;
+
+       yy_init_buffer( b, file );
+
+       return b;
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+       {
+       if ( ! b )
+               return;
+
+       if ( b == yy_current_buffer )
+               yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+       if ( b->yy_is_our_buffer )
+               yy_flex_free( (void *) b->yy_ch_buf );
+
+       yy_flex_free( (void *) b );
+       }
+
+
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+extern int isatty YY_PROTO(( int ));
+#endif
+#endif
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+       {
+       yy_flush_buffer( b );
+
+       b->yy_input_file = file;
+       b->yy_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+       b->yy_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+       b->yy_is_interactive = 0;
+#else
+       b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yy_flush_buffer( YY_BUFFER_STATE b )
+#else
+void yy_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+       {
+       b->yy_n_chars = 0;
+
+       /* We always need two end-of-buffer characters.  The first causes
+        * a transition to the end-of-buffer state.  The second causes
+        * a jam in that state.
+        */
+       b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+       b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+       b->yy_buf_pos = &b->yy_ch_buf[0];
+
+       b->yy_at_bol = 1;
+       b->yy_buffer_status = YY_BUFFER_NEW;
+
+       if ( b == yy_current_buffer )
+               yy_load_buffer_state();
+       }
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+#else
+YY_BUFFER_STATE yy_scan_buffer( base, size )
+char *base;
+yy_size_t size;
+#endif
+       {
+       YY_BUFFER_STATE b;
+
+       if ( size < 2 ||
+            base[size-2] != YY_END_OF_BUFFER_CHAR ||
+            base[size-1] != YY_END_OF_BUFFER_CHAR )
+               /* They forgot to leave room for the EOB's. */
+               return 0;
+
+       b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+       if ( ! b )
+               YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+       b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
+       b->yy_buf_pos = b->yy_ch_buf = base;
+       b->yy_is_our_buffer = 0;
+       b->yy_input_file = 0;
+       b->yy_n_chars = b->yy_buf_size;
+       b->yy_is_interactive = 0;
+       b->yy_at_bol = 1;
+       b->yy_fill_buffer = 0;
+       b->yy_buffer_status = YY_BUFFER_NEW;
+
+       yy_switch_to_buffer( b );
+
+       return b;
+       }
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_string( yyconst char *str )
+#else
+YY_BUFFER_STATE yy_scan_string( str )
+yyconst char *str;
+#endif
+       {
+       int len;
+       for ( len = 0; str[len]; ++len )
+               ;
+
+       return yy_scan_bytes( str, len );
+       }
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+#else
+YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+yyconst char *bytes;
+int len;
+#endif
+       {
+       YY_BUFFER_STATE b;
+       char *buf;
+       yy_size_t n;
+       int i;
+
+       /* Get memory for full buffer, including space for trailing EOB's. */
+       n = len + 2;
+       buf = (char *) yy_flex_alloc( n );
+       if ( ! buf )
+               YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+       for ( i = 0; i < len; ++i )
+               buf[i] = bytes[i];
+
+       buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+       b = yy_scan_buffer( buf, n );
+       if ( ! b )
+               YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+       /* It's okay to grow etc. this buffer, and we should throw it
+        * away when we're done.
+        */
+       b->yy_is_our_buffer = 1;
+
+       return b;
+       }
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void yy_push_state( int new_state )
+#else
+static void yy_push_state( new_state )
+int new_state;
+#endif
+       {
+       if ( yy_start_stack_ptr >= yy_start_stack_depth )
+               {
+               yy_size_t new_size;
+
+               yy_start_stack_depth += YY_START_STACK_INCR;
+               new_size = yy_start_stack_depth * sizeof( int );
+
+               if ( ! yy_start_stack )
+                       yy_start_stack = (int *) yy_flex_alloc( new_size );
+
+               else
+                       yy_start_stack = (int *) yy_flex_realloc(
+                                       (void *) yy_start_stack, new_size );
+
+               if ( ! yy_start_stack )
+                       YY_FATAL_ERROR(
+                       "out of memory expanding start-condition stack" );
+               }
+
+       yy_start_stack[yy_start_stack_ptr++] = YY_START;
+
+       BEGIN(new_state);
+       }
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state()
+       {
+       if ( --yy_start_stack_ptr < 0 )
+               YY_FATAL_ERROR( "start-condition stack underflow" );
+
+       BEGIN(yy_start_stack[yy_start_stack_ptr]);
+       }
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state()
+       {
+       return yy_start_stack[yy_start_stack_ptr - 1];
+       }
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void yy_fatal_error( yyconst char msg[] )
+#else
+static void yy_fatal_error( msg )
+char msg[];
+#endif
+       {
+       (void) fprintf( stderr, "%s\n", msg );
+       exit( YY_EXIT_FAILURE );
+       }
+
+
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+       do \
+               { \
+               /* Undo effects of setting up yytext. */ \
+               yytext[yyleng] = yy_hold_char; \
+               yy_c_buf_p = yytext + n - YY_MORE_ADJ; \
+               yy_hold_char = *yy_c_buf_p; \
+               *yy_c_buf_p = '\0'; \
+               yyleng = n; \
+               } \
+       while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef yytext_ptr
+#ifdef YY_USE_PROTOS
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+#else
+static void yy_flex_strncpy( s1, s2, n )
+char *s1;
+yyconst char *s2;
+int n;
+#endif
+       {
+       register int i;
+       for ( i = 0; i < n; ++i )
+               s1[i] = s2[i];
+       }
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_alloc( yy_size_t size )
+#else
+static void *yy_flex_alloc( size )
+yy_size_t size;
+#endif
+       {
+       return (void *) malloc( size );
+       }
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_realloc( void *ptr, yy_size_t size )
+#else
+static void *yy_flex_realloc( ptr, size )
+void *ptr;
+yy_size_t size;
+#endif
+       {
+       /* The cast to (char *) in the following accommodates both
+        * implementations that use char* generic pointers, and those
+        * that use void* generic pointers.  It works with the latter
+        * because both ANSI C and C++ allow castless assignment from
+        * any pointer type to void*, and deal with argument conversions
+        * as though doing an assignment.
+        */
+       return (void *) realloc( (char *) ptr, size );
+       }
+
+#ifdef YY_USE_PROTOS
+static void yy_flex_free( void *ptr )
+#else
+static void yy_flex_free( ptr )
+void *ptr;
+#endif
+       {
+       free( ptr );
+       }
+
+#if YY_MAIN
+int main()
+       {
+       yylex();
+       return 0;
+       }
+#endif
+#line 88 "trans.l"
+
+
+yywrap()
+{
+  return 1;
+}
+
+Unput(c)
+int c;
+{
+  unput(c);
+}
diff --git a/src/langs/sdag/xlator/trans.l b/src/langs/sdag/xlator/trans.l
new file mode 100644 (file)
index 0000000..db3e837
--- /dev/null
@@ -0,0 +1,99 @@
+%{
+#include "EToken.h"
+
+/* Assume that the C-style comments are not present in the source */
+
+%}
+
+comment "//".*
+identifier [a-zA-Z_][0-9a-zA-Z_]*
+simple_escape [abfnrtv'"?\\]
+octal_escape  [0-7]{1,3}
+hex_escape "x"[0-9a-fA-F]+
+escape_sequence [\\]({simple_escape}|{octal_escape}|{hex_escape})
+c_char [^'\\\n]|{escape_sequence}
+s_char [^"\\\n]|{escape_sequence}
+
+ht [\011]
+ff [\014]
+vt [\013]
+cret [\015]
+hwhite [ ]|{ht}
+
+exponent_part [eE][-+]?[0-9]+
+fractional_constant ([0-9]*"."[0-9]+)|([0-9]+".")
+floating_constant (({fractional_constant}{exponent_part}?)|([0-9]+{exponent_part}))[FfLl]?
+
+integer_suffix_opt ([uU]?[lL]?)|([lL][uU])
+decimal_constant [1-9][0-9]*{integer_suffix_opt}
+octal_constant "0"[0-7]*{integer_suffix_opt}
+hex_constant "0"[xX][0-9a-fA-F]+{integer_suffix_opt}
+%%
+
+{comment}              {return WSPACE;}
+
+{hwhite}+              {return WSPACE;}
+({vt}|{cret}|{ff})+    {return WSPACE;}
+({hwhite}|{vt}|{cret}|{ff})*"\n"       {return(NEW_LINE);}
+
+
+class                  {return(CLASS);}
+sdagentry              {return(SDAGENTRY);}
+overlap                        {return(OVERLAP);}
+when                   {return(WHEN);}
+if                     {return(IF);}
+else                   {return(ELSE);}
+while                  {return(WHILE);}
+forall                 {return(FORALL);}
+for                    {return(FOR);}
+atomic                 {return(ATOMIC);}
+
+{identifier}           {return(IDENT);}
+
+"L"?[']{c_char}+[']    {return(CHAR);}
+"L"?["]{s_char}*["]    {return(STRING);}
+
+"("                    {return(LP);}
+")"                    {return(RP);}
+"["                    {return(LB);}
+"]"                    {return(RB);}
+"{"                    {return(LBRACE);}
+"}"                    {return(RBRACE);}
+"*"                    {return(STAR);}
+":"                    {return(COLON);}
+","                    {return(COMMA);}
+";"                    {return(SEMICOLON);}
+
+"#"                    {return(DEFAULT);}
+"."                    {return(DEFAULT);}
+"&"                    {return(DEFAULT);}
+"+"                    {return(DEFAULT);}
+"-"                    {return(DEFAULT);}
+"~"                    {return(DEFAULT);}
+"!"                    {return(DEFAULT);}
+"/"                    {return(DEFAULT);}
+"%"                    {return(DEFAULT);}
+"<"                    {return(DEFAULT);}
+">"                    {return(DEFAULT);}
+"^"                    {return(DEFAULT);}
+"|"                    {return(DEFAULT);}
+"?"                    {return(DEFAULT);}
+"="                    {return(DEFAULT);}
+
+{decimal_constant}     {return(DEFAULT);}
+{octal_constant}       {return(DEFAULT);}
+{hex_constant}         {return(DEFAULT);}
+{floating_constant}    {return(DEFAULT);}
+
+%%
+
+yywrap()
+{
+  return 1;
+}
+
+Unput(c)
+int c;
+{
+  unput(c);
+}
index 63da7a877848abbb9c5a638d3263804a3efc0e32..f770be0834292f310e840113ae1485f8cfc74c24 100644 (file)
@@ -23,7 +23,7 @@
 
 SHELL=/bin/sh
 
-all: charm++ smsg pvm
+all: charm++ smsg pvm sdag
 
 charm: converse charmxlat charmlibs libcharm
 
@@ -33,7 +33,9 @@ smsg: converse libsimplemsg.a
 
 pvm: converse libpvmc.a
 
-translators: charmxlat charmfilter charmxlat++ charmfilter++ charmxi conv-cpm
+sdag: charm++ sdagx libsdag.a
+
+translators: sdagx charmxlat charmfilter charmxlat++ charmfilter++ charmxi conv-cpm
 
 test-all: all
        (cd ../pgms ; make test-all)
@@ -49,7 +51,7 @@ test-charm++: charm++
 
 CHARMC=../bin/charmc $(CHARMOPTS) $(OPTS)
 
-SEQCHARMC=../bin/charmc $(CHARMOPTS)
+SEQCHARMC=../bin/charmc -seq $(CHARMOPTS)
 
 
 ###############################################################################
@@ -58,7 +60,7 @@ SEQCHARMC=../bin/charmc $(CHARMOPTS)
 #
 ###############################################################################
 
-ALLHEADERS=charm++.h charm.h charm++-inc.h charm-inc.h dagger.h cpthreads.h converse.h conv-mach.h simplemsg.h trace.h generic_redn.h pvmc.h pvm3.h # pglib.h
+ALLHEADERS=charm++.h charm.h charm++-inc.h charm-inc.h dagger.h cpthreads.h converse.h conv-mach.h simplemsg.h trace.h generic_redn.h pvmc.h pvm3.h sdag.h CDep.h CCounter.h CMsgBuffer.h CWhenTrigger.h TList.h # pglib.h
 
 ALLINTERFACES=GENERIC-ACC.int GENERIC-HIST.int GENERIC-REDN.int barrier_redn.int cache.int dacc_count.int dacc_hist.int dcountredn.int dmaxredn.int dminredn.int dprodredn.int dsumredn.int facc_count.int facc_hist.int fcountredn.int fmaxredn.int fminredn.int fprodredn.int fsumredn.int iacc_count.int iacc_hist.int icountredn.int imaxredn.int iminredn.int iprodredn.int isumredn.int pg.int
 
@@ -92,6 +94,8 @@ dirs+sources:
        ./gatherflat ../../src/Common/ck-perf          .
        ./gatherflat ../../src/Common/langs/simplemsg  .
        ./gatherflat ../../src/Common/langs/pvmc       .
+       ./gatherflat ../../src/Common/langs/sdag/xlator       .
+       ./gatherflat ../../src/Common/langs/sdag/runtime      .
        ./gatherflat ../../src/Common/lib-acc          .
        ./gatherflat ../../src/Common/lib-misc         .
        ./gatherflat ../../src/Common/lib-redn         .
@@ -437,44 +441,44 @@ dcountredn.o: dcountredn.int $(GENERIC_REDN_H)
 CHARMXLAT=xl-main.o xl-yacc.tab.o xl-sym.o xl-str.o xl-lex.o xl-lexsp.o xl-rdtok.o xl-parse.o xl-outh.o xl-srch.o xl-dag.o
 
 charmxlat charmfilter: $(CHARMXLAT) xl-sfspec.o
-       $(SEQCHARMC) -seq -o charmxlat   -cp ../bin/ $(CHARMXLAT)
-       $(SEQCHARMC) -seq -o charmfilter -cp ../bin/ xl-sfspec.o
+       $(SEQCHARMC) -o charmxlat   -cp ../bin/ $(CHARMXLAT)
+       $(SEQCHARMC) -o charmfilter -cp ../bin/ xl-sfspec.o
 
 xl-main.o: xl-main.c
-       $(SEQCHARMC) -seq xl-main.c
+       $(SEQCHARMC) xl-main.c
 
 xl-sym.o: xl-sym.c xl-sym.h
-       $(SEQCHARMC) -seq xl-sym.c
+       $(SEQCHARMC) xl-sym.c
 
 xl-str.o: xl-str.c
-       $(SEQCHARMC) -seq xl-str.c
+       $(SEQCHARMC) xl-str.c
 
 xl-lex.o: xl-lex.c xl-lex.h xl-sym.h
-       $(SEQCHARMC) -seq xl-lex.c
+       $(SEQCHARMC) xl-lex.c
 
 xl-rdtok.o: xl-rdtok.c xl-lex.h xl-sym.h
-       $(SEQCHARMC) -seq xl-rdtok.c
+       $(SEQCHARMC) xl-rdtok.c
 
 xl-parse.o: xl-parse.c xl-lex.h xl-sym.h
-       $(SEQCHARMC) -seq xl-parse.c
+       $(SEQCHARMC) xl-parse.c
 
 xl-outh.o: xl-outh.c xl-lex.h xl-sym.h
-       $(SEQCHARMC) -seq xl-outh.c
+       $(SEQCHARMC) xl-outh.c
 
 xl-srch.o: xl-srch.c xl-lex.h xl-sym.h
-       $(SEQCHARMC) -seq xl-srch.c
+       $(SEQCHARMC) xl-srch.c
 
 xl-dag.o: xl-dag.c
-       $(SEQCHARMC) -seq xl-dag.c
+       $(SEQCHARMC) xl-dag.c
 
 xl-yacc.tab.o: xl-yacc.tab.c xl-lex.h xl-sym.h
-       $(SEQCHARMC) -seq xl-yacc.tab.c
+       $(SEQCHARMC) xl-yacc.tab.c
 
 xl-lexsp.o: xl-lexsp.c 
-       $(SEQCHARMC) -seq xl-lexsp.c
+       $(SEQCHARMC) xl-lexsp.c
 
 xl-sfspec.o: xl-sfspec.c
-       $(SEQCHARMC) -seq xl-sfspec.c
+       $(SEQCHARMC) xl-sfspec.c
 
 ###############################################################################
 #
@@ -487,23 +491,23 @@ XPHEADERS=xp-extn.h xp-t.tab.c
 CHARMXLATXX=xp-process.o xp-table.o xp-t.tab.o xp-lexer.o
 
 charmxlat++: $(CHARMXLATXX) xp-sfilter.o
-       $(SEQCHARMC) -seq -o charmxlat++   -cp ../bin/ $(CHARMXLATXX)
-       $(SEQCHARMC) -seq -o charmfilter++ -cp ../bin/ xp-sfilter.o
+       $(SEQCHARMC) -o charmxlat++   -cp ../bin/ $(CHARMXLATXX)
+       $(SEQCHARMC) -o charmfilter++ -cp ../bin/ xp-sfilter.o
 
 xp-process.o: xp-process.c $(XPHEADERS)
-       $(SEQCHARMC) -seq xp-process.c
+       $(SEQCHARMC) xp-process.c
 
 xp-table.o: xp-table.c $(XPHEADERS)
-       $(SEQCHARMC) -seq xp-table.c
+       $(SEQCHARMC) xp-table.c
 
 xp-t.tab.o: xp-t.tab.c $(XPHEADERS)
-       $(SEQCHARMC) -seq -DYYDEBUG xp-t.tab.c
+       $(SEQCHARMC) -DYYDEBUG xp-t.tab.c
 
 xp-lexer.o: xp-lexer.c $(XPHEADERS)
-       $(SEQCHARMC) -seq xp-lexer.c
+       $(SEQCHARMC) xp-lexer.c
 
 xp-sfilter.o: xp-sfilter.c $(XPHEADERS)
-       $(SEQCHARMC) -seq xp-sfilter.c
+       $(SEQCHARMC) xp-sfilter.c
 
 ###############################################################################
 #
@@ -512,10 +516,10 @@ xp-sfilter.o: xp-sfilter.c $(XPHEADERS)
 ###############################################################################
 
 conv-cpm: conv-cpm.o
-       $(SEQCHARMC) -seq -o conv-cpm -cp ../bin/ conv-cpm.o
+       $(SEQCHARMC) -o conv-cpm -cp ../bin/ conv-cpm.o
 
 conv-cpm.o: conv-cpm.c
-       $(SEQCHARMC) -seq conv-cpm.c
+       $(SEQCHARMC) conv-cpm.c
 
 ###############################################################################
 #
@@ -527,22 +531,22 @@ XIHEADERS=xi-symbol.h xi-parse.tab.C
 CHARMXI=xi-main.o xi-symbol.o xi-generate.o xi-parse.tab.o xi-scan.o
 
 charmxi: $(CHARMXI)
-       $(SEQCHARMC) -seq -language c++ -cp ../bin/ -o charmxi $(CHARMXI)
+       $(SEQCHARMC) -language c++ -cp ../bin/ -o charmxi $(CHARMXI)
 
 xi-main.o: xi-main.C $(XIHEADERS)
-       $(SEQCHARMC) -seq xi-main.C
+       $(SEQCHARMC) xi-main.C
 
 xi-symbol.o: xi-symbol.C $(XIHEADERS)
-       $(SEQCHARMC) -seq xi-symbol.C
+       $(SEQCHARMC) xi-symbol.C
 
 xi-generate.o: xi-generate.C $(XIHEADERS)
-       $(SEQCHARMC) -seq xi-generate.C
+       $(SEQCHARMC) xi-generate.C
 
 xi-parse.tab.o: xi-parse.tab.C $(XIHEADERS)
-       $(SEQCHARMC) -seq xi-parse.tab.C
+       $(SEQCHARMC) xi-parse.tab.C
 
 xi-scan.o: xi-scan.C $(XIHEADERS)
-       $(SEQCHARMC) -seq xi-scan.C
+       $(SEQCHARMC) xi-scan.C
 
 ###############################################################################
 #
@@ -582,6 +586,47 @@ pvmc_groups.o: pvmc_groups.c pvmc.h pvm3.h
 pvmc_main.o: pvmc_main.c pvmc.h pvm3.h
        $(CHARMC) -o $@ pvmc_main.c
 
+libsdag.a: CDep.o
+       $(CHARMC) -cp ../lib -o libsdag.a CDep.o
+
+CDep.o: CDep.C CDep.h CMsgBuffer.h CWhenTrigger.h
+       $(CHARMC) -c CDep.C
+
+SDAGOBJ=sdag-main.o trans.o CLexer.o CParser.o CParsedFile.o CParseNode.o \
+       sdag-globals.o CParseNodeProcess.o CEntry.o
+
+sdagx: $(SDAGOBJ)
+       $(SEQCHARMC) -cp ../bin -o sdagx -language c++ $(SDAGOBJ)
+
+sdag-main.o: sdag-main.C CLexer.h CToken.h
+       $(SEQCHARMC) -c sdag-main.C
+
+trans.o: trans.c EToken.h
+       $(SEQCHARMC) -c trans.c
+
+trans.c: trans.l
+       flex -otrans.c trans.l
+
+CLexer.o: CLexer.C CLexer.h
+       $(SEQCHARMC) -c CLexer.C
+
+CParser.o: CParser.C CParser.h
+       $(SEQCHARMC) -c CParser.C
+
+CParsedFile.o: CParsedFile.C CParsedFile.h
+       $(SEQCHARMC) -c CParsedFile.C
+
+CParseNode.o: CParseNode.C CParseNode.h
+       $(SEQCHARMC) -c CParseNode.C
+
+sdag-globals.o: sdag-globals.C sdag-globals.h
+       $(SEQCHARMC) -c sdag-globals.C
+
+CParseNodeProcess.o: CParseNodeProcess.C CParseNode.h
+       $(SEQCHARMC) -c CParseNodeProcess.C
+
+CEntry.o: CEntry.C CEntry.h
+       $(SEQCHARMC) -c CEntry.C
 
 ###############################################################################
 #