home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / celllr20 / part01 < prev    next >
Encoding:
Text File  |  1993-04-02  |  108.3 KB  |  3,814 lines

  1. Newsgroups: comp.sources.unix
  2. From: dana@rucs.faculty.cs.runet.edu (J Dana Eckart)
  3. Subject: v26i088: cellular-2.0 - a cellular automata language, Part01/03
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: dana@rucs.faculty.cs.runet.edu (J Dana Eckart)
  8. Posting-Number: Volume 26, Issue 88
  9. Archive-Name: cellular-2.0/part01
  10.  
  11. [ my apologies for the TeX here, but the author of this package did not say
  12.   in her cover letter or README file what this is or what it does, and i do
  13.   not have a TeX interpreter so i can't make this prettier other than with a
  14.   lot of hand-editing.  it's from the "tutorial.tex" file.        --vix ]
  15.  
  16. \section{Introduction}
  17. With the growing popularity of cellular automata in both recreation
  18. \cite{life}\cite{wireworld}\cite{fluids}\cite{crystals} 
  19. and the modeling of physical 
  20. systems\cite{toffoli}\cite{Wolf-Gladrow}\cite{Chen}\cite{Lavallee}\cite{Lim},
  21. the need for an easy--to--use system for cellular automata programming
  22. is greater than ever.  {\em Cellular} is a system designed and implemented
  23. by the author to meet these needs.  The system consists of: a programming
  24. language, {\em Cellang 2.0}\footnote{
  25.             Pronounced cell ' ang.
  26.         },
  27. and associated compiler, {\tt cellc};
  28. an ``abstract'' virtual machine\footnote{
  29.         The construction of an actual machine embodying the
  30.         pe--scam architecture is under development.\cite{pe-scam}
  31.     }
  32. for execution, {\tt pe-scam}; and a viewer, {\tt cellview}.
  33. Compiled {\em Cellang 2.0} programs can be run
  34. with input provided at any specified time during the execution.  The
  35. results of an execution can either be viewed directly or output as
  36. a stream of cell locations and values.  This stream of output
  37. data can then be fed into {\tt cellview} for viewing, or it may
  38. be passed through a filter that compiles statistics, massages the
  39. data, or merely acts as a valve to control the flow of data from the
  40. cellular automaton program to the viewer.  This simple UNIX\footnote{
  41.                 UNIX is a registered trademark of AT\&T.
  42.         }
  43. toolkit view of the simulation process provides greater control
  44. than systems which combine the language and viewer (i.e.
  45. cellsim\cite{cellsim} and CAM--6\cite{toffoli}).  {\em Cellang 2.0}
  46. provides greater flexibility, particularly in the formation of
  47. neighborhoods, than does {\em Cal} (part of the {\em Scamper} 
  48. system)\cite{Scamper}.  And although the {\em SLANG}\cite{SLANG} system
  49. supports probablistic possibilities, {\em Cellang 2.0} is a far
  50. simpler language for constructing deterministic cellular automata.
  51.  
  52. #! /bin/sh
  53. # This is a shell archive.  Remove anything before this line, then unpack
  54. # it by saving it into a file and typing "sh file".  To overwrite existing
  55. # files, type "sh file -c".  You can also feed this as standard input via
  56. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  57. # will see the following message at the end:
  58. #        "End of archive 1 (of 3)."
  59. # Contents:  MANIFEST Makefile README Version compiler
  60. #   compiler/Makefile compiler/README compiler/attribute.h
  61. #   compiler/boolean.h compiler/cellc.man compiler/cellc.sh
  62. #   compiler/error.c compiler/error.h compiler/io.h compiler/parse
  63. #   compiler/scanner.h compiler/semantic.h compiler/stack.h
  64. #   compiler/symtable.c compiler/symtable.h driver driver/Makefile
  65. #   driver/pe-scam.sh examples examples/Makefile examples/README
  66. #   examples/bin examples/data examples/data/cparity
  67. #   examples/data/life examples/data/parity examples/dist_data_gen.c
  68. #   examples/gas_data_gen.c examples/map examples/map/srdp
  69. #   examples/show.sh examples/src examples/src/cparity
  70. #   examples/src/dist examples/src/gas examples/src/life
  71. #   examples/src/parity examples/src/srdp examples/srdp_data_gen.c
  72. #   viewer viewer/Makefile viewer/README viewer/boolean.h
  73. #   viewer/bw-map viewer/color-map viewer/curses-map viewer/curses.c
  74. #   viewer/curses.h viewer/view.h viewer/x11.h
  75. # Wrapped by vixie@gw.home.vix.com on Sat Apr  3 01:27:38 1993
  76. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  77. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  78.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  79. else
  80. echo shar: Extracting \"'MANIFEST'\" \(2098 characters\)
  81. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  82. X   File Name        Archive #    Description
  83. X-----------------------------------------------------------
  84. X COPYING                    2    
  85. X MANIFEST                   1    This shipping list
  86. X Makefile                   1    
  87. X README                     1    
  88. X Version                    1    
  89. X compiler                   1    
  90. X compiler/Cellang.tex       2    
  91. X compiler/Makefile          1    
  92. X compiler/README            1    
  93. X compiler/attribute.h       1    
  94. X compiler/boolean.h         1    
  95. X compiler/cellc.man         1    
  96. X compiler/cellc.sh          1    
  97. X compiler/error.c           1    
  98. X compiler/error.h           1    
  99. X compiler/io.h              1    
  100. X compiler/parse             1    
  101. X compiler/scanner.c         2    
  102. X compiler/scanner.h         1    
  103. X compiler/semantic.c        3    
  104. X compiler/semantic.h        1    
  105. X compiler/stack.h           1    
  106. X compiler/symtable.c        1    
  107. X compiler/symtable.h        1    
  108. X driver                     1    
  109. X driver/Makefile            1    
  110. X driver/pe-scam.man         2    
  111. X driver/pe-scam.sh          1    
  112. X examples                   1    
  113. X examples/Makefile          1    
  114. X examples/README            1    
  115. X examples/bin               1    
  116. X examples/data              1    
  117. X examples/data/cparity      1    
  118. X examples/data/life         1    
  119. X examples/data/parity       1    
  120. X examples/dist_data_gen.c   1    
  121. X examples/gas_data_gen.c    1    
  122. X examples/map               1    
  123. X examples/map/srdp          1    
  124. X examples/show.sh           1    
  125. X examples/src               1    
  126. X examples/src/cparity       1    
  127. X examples/src/dist          1    
  128. X examples/src/gas           1    
  129. X examples/src/life          1    
  130. X examples/src/parity        1    
  131. X examples/src/srdp          1    
  132. X examples/srdp_data_gen.c   1    
  133. X tutorial.tex               3    
  134. X viewer                     1    
  135. X viewer/Makefile            1    
  136. X viewer/README              1    
  137. X viewer/boolean.h           1    
  138. X viewer/bw-map              1    
  139. X viewer/cellview.man        2    
  140. X viewer/color-map           1    
  141. X viewer/curses-map          1    
  142. X viewer/curses.c            1    
  143. X viewer/curses.h            1    
  144. X viewer/view.c              2    
  145. X viewer/view.h              1    
  146. X viewer/x11.c               2    
  147. X viewer/x11.h               1    
  148. END_OF_FILE
  149. if test 2098 -ne `wc -c <'MANIFEST'`; then
  150.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  151. fi
  152. # end of 'MANIFEST'
  153. fi
  154. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  155.   echo shar: Will not clobber existing file \"'Makefile'\"
  156. else
  157. echo shar: Extracting \"'Makefile'\" \(4029 characters\)
  158. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  159. X#  Makefile
  160. X#  Copyright (C) 1992  J Dana Eckart
  161. X#
  162. X#  This program is free software; you can redistribute it and/or modify
  163. X#  it under the terms of the GNU General Public License as published by
  164. X#  the Free Software Foundation; either version 1, or (at your option)
  165. X#  any later version.
  166. X#
  167. X#  This program is distributed in the hope that it will be useful,
  168. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  169. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  170. X#  GNU General Public License for more details.
  171. X#
  172. X#  You should have received a copy of the GNU General Public License
  173. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  174. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  175. X
  176. X# Installation directories.
  177. X#
  178. BIN=/usr/local/bin
  179. LIB=/usr/local/lib/cellular
  180. MAN=/usr/man/manl
  181. MAN_EXT=l
  182. X
  183. X# The default (maximum) size of each dimension associated with Cellang programs.
  184. X#
  185. MAX_DIM_SIZE=64
  186. X
  187. X# If you want to have the Cellang compiler configured to compile the viewer 
  188. X# into the executables then assign COMBINED the value "1", otherwise assign 
  189. X# a "0".  This makes for faster display of many automata, though it does need
  190. X# X11 to run them.
  191. X#
  192. COMBINED=1    # 0 or 1
  193. X
  194. X# Choose a C compiler and options.
  195. X#
  196. CC = gcc
  197. CFLAGS = -O
  198. X
  199. X# Rules (default.mk on SunOS uses a -target option not supported by GNU C)
  200. X#
  201. COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
  202. X
  203. X# Dependencies
  204. X
  205. all: tutorial.PS
  206. X    (cd compiler; \
  207. X        make BIN='${BIN}' LIB='${LIB}' \
  208. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  209. X             CC='${CC}' CFLAGS='${CFLAGS}' \
  210. X             CDEFINES='-DCOMBINED=${COMBINED}' \
  211. X             MAX_DIM_SIZE='${MAX_DIM_SIZE}' \
  212. X             COMBINED='${COMBINED}' \
  213. X             all)
  214. X    (cd viewer; \
  215. X        make BIN='${BIN}' LIB='${LIB}' \
  216. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  217. X             CC='${CC}' CFLAGS='${CFLAGS}' \
  218. X             CDEFINES='-DLIB_DIR=\"${LIB}\"' \
  219. X             COMBINED='${COMBINED}' \
  220. X             all)
  221. X    (cd driver; \
  222. X        make BIN='${BIN}' LIB='${LIB}' \
  223. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  224. X             MAX_DIM_SIZE='${MAX_DIM_SIZE}' \
  225. X             COMBINED='${COMBINED}' \
  226. X             all)
  227. X    (cd examples; \
  228. X        make BIN='${BIN}' LIB='${LIB}' \
  229. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  230. X             CC='${CC}' CFLAGS='${CFLAGS}' \
  231. X             MAX_DIM_SIZE='${MAX_DIM_SIZE}' \
  232. X             all)
  233. X
  234. install: tutorial.PS
  235. X    (cd compiler; \
  236. X        make BIN='${BIN}' LIB='${LIB}' \
  237. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  238. X             CC='${CC}' CFLAGS='${CFLAGS}' \
  239. X             CDEFINES='-DCOMBINED=${COMBINED}' \
  240. X             MAX_DIM_SIZE='${MAX_DIM_SIZE}' \
  241. X             COMBINED='${COMBINED}' \
  242. X             install)
  243. X    (cd viewer; \
  244. X        make BIN='${BIN}' LIB='${LIB}' \
  245. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  246. X             CC='${CC}' CFLAGS='${CFLAGS}' \
  247. X             CDEFINES='-DLIB_DIR=\"${LIB}\"' \
  248. X             COMBINED='${COMBINED}' \
  249. X             install)
  250. X    (cd driver; \
  251. X        make BIN='${BIN}' LIB='${LIB}' \
  252. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  253. X             MAX_DIM_SIZE='${MAX_DIM_SIZE}' \
  254. X             COMBINED='${COMBINED}' \
  255. X             install)
  256. X    (cd examples; \
  257. X        make BIN='${BIN}' LIB='${LIB}' \
  258. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  259. X             CC='${CC}' CFLAGS='${CFLAGS}' \
  260. X             MAX_DIM_SIZE='${MAX_DIM_SIZE}' \
  261. X             install)
  262. X
  263. deinstall:
  264. X    (cd compiler; \
  265. X        make BIN='${BIN}' LIB='${LIB}' \
  266. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  267. X             deinstall)
  268. X    (cd viewer; \
  269. X        make BIN='${BIN}' LIB='${LIB}' \
  270. X             MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  271. X             deinstall)
  272. X    (cd driver; \
  273. X        make BIN='${BIN}' MAN='${MAN}' MAN_EXT='${MAN_EXT}' \
  274. X             deinstall)
  275. X    (cd examples; \
  276. X        make LIB='${LIB}' deinstall)
  277. X
  278. clean:
  279. X    /bin/rm -f *.aux *.dvi *.log *.toc core
  280. X    (cd compiler; make MAN_EXT='${MAN_EXT}' clean)
  281. X    (cd viewer; make MAN_EXT='${MAN_EXT}' clean)
  282. X    (cd driver; make MAN_EXT='${MAN_EXT}' clean)
  283. X    (cd examples; make clean)
  284. X
  285. realclean: clean
  286. X    /bin/rm -f tutorial.PS
  287. X    (cd compiler; make realclean)
  288. X    (cd viewer; make realclean)
  289. X    (cd driver; make realclean)
  290. X    (cd examples; make realclean)
  291. X
  292. tutorial.PS: tutorial.tex
  293. X    - latex tutorial.tex
  294. X    - latex tutorial.tex
  295. X    - dvi2ps -r tutorial.dvi > tutorial.PS
  296. END_OF_FILE
  297. if test 4029 -ne `wc -c <'Makefile'`; then
  298.     echo shar: \"'Makefile'\" unpacked with wrong size!
  299. fi
  300. # end of 'Makefile'
  301. fi
  302. if test -f 'README' -a "${1}" != "-c" ; then 
  303.   echo shar: Will not clobber existing file \"'README'\"
  304. else
  305. echo shar: Extracting \"'README'\" \(2358 characters\)
  306. sed "s/^X//" >'README' <<'END_OF_FILE'
  307. X#  README
  308. X#  Copyright (C) 1992  J Dana Eckart
  309. X#
  310. X#  This program is free software; you can redistribute it and/or modify
  311. X#  it under the terms of the GNU General Public License as published by
  312. X#  the Free Software Foundation; either version 1, or (at your option)
  313. X#  any later version.
  314. X#
  315. X#  This program is distributed in the hope that it will be useful,
  316. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  317. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  318. X#  GNU General Public License for more details.
  319. X#
  320. X#  You should have received a copy of the GNU General Public License
  321. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  322. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  323. X
  324. To install the Cellular system, edit the Makefile to reflect the proper 
  325. values of:
  326. X
  327. X     BIN      - installation directory for executables
  328. X     LIB      - installation directory for supporting software
  329. X     MAN      - installation directory for manual pages
  330. X     MAX_EXT  - manual page extension to use for installation
  331. X
  332. X     MAX_DIM_SIZE - size of each dimension in Cellang 2.0 programs 
  333. X
  334. X     COMBINED - whether or not to compile the viewer into Cellang 2.0 programs
  335. X
  336. Do "make install" to build and install everything.  In addition, the 
  337. Makefile also supports the targets:
  338. X
  339. X    all: compile, but not install, the software
  340. X  deinstall: remove an installation
  341. X      clean: remove all but the distributed files (and postscript versions of
  342. X        LaTeX documents)
  343. X  realclean: remove all but the distributed files
  344. X
  345. A tutorial is written in LaTeX and appears in ./tutorial.tex, while the
  346. Cellang 2.0 Language Reference Manual appears in compiler/Cellang.tex (and
  347. is also written in LaTeX).
  348. X
  349. The "examples" directory (found in the LIB directory specified in the Makefile)
  350. contains some sample Cellang programs with data.  It is a good place to start 
  351. for becoming familiar with the system.
  352. X
  353. NOTE: When compiled with COMBINED turned on, only the first two dimensions 
  354. X      (when present) are displayed if the output option is not chosen when 
  355. X      the automata is executed.
  356. X
  357. X
  358. X
  359. X            QUESTIONS, COMMENTS, BUG REPORTS and SUGGESTED PATCHES
  360. X
  361. can be sent to me at either:
  362. X
  363. X        J Dana Eckart
  364. X        Box 6933
  365. X        Computer Science Department
  366. X        Radford University
  367. X        Radford, VA  24142
  368. X
  369. X    or
  370. X
  371. X        dana@rucs.faculty.cs.runet.edu
  372. END_OF_FILE
  373. if test 2358 -ne `wc -c <'README'`; then
  374.     echo shar: \"'README'\" unpacked with wrong size!
  375. fi
  376. # end of 'README'
  377. fi
  378. if test -f 'Version' -a "${1}" != "-c" ; then 
  379.   echo shar: Will not clobber existing file \"'Version'\"
  380. else
  381. echo shar: Extracting \"'Version'\" \(802 characters\)
  382. sed "s/^X//" >'Version' <<'END_OF_FILE'
  383. X#  Version
  384. X#  Copyright (C) 1992  J Dana Eckart
  385. X#
  386. X#  This program is free software; you can redistribute it and/or modify
  387. X#  it under the terms of the GNU General Public License as published by
  388. X#  the Free Software Foundation; either version 1, or (at your option)
  389. X#  any later version.
  390. X#
  391. X#  This program is distributed in the hope that it will be useful,
  392. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  393. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  394. X#  GNU General Public License for more details.
  395. X#
  396. X#  You should have received a copy of the GNU General Public License
  397. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  398. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  399. X
  400. X13 Apr 1992 : initial release by J Dana Eckart
  401. END_OF_FILE
  402. if test 802 -ne `wc -c <'Version'`; then
  403.     echo shar: \"'Version'\" unpacked with wrong size!
  404. fi
  405. # end of 'Version'
  406. fi
  407. if test ! -d 'compiler' ; then
  408.     echo shar: Creating directory \"'compiler'\"
  409.     mkdir 'compiler'
  410. fi
  411. if test -f 'compiler/Makefile' -a "${1}" != "-c" ; then 
  412.   echo shar: Will not clobber existing file \"'compiler/Makefile'\"
  413. else
  414. echo shar: Extracting \"'compiler/Makefile'\" \(3502 characters\)
  415. sed "s/^X//" >'compiler/Makefile' <<'END_OF_FILE'
  416. X#  Makefile
  417. X#  Copyright (C) 1992  J Dana Eckart
  418. X#
  419. X#  This program is free software; you can redistribute it and/or modify
  420. X#  it under the terms of the GNU General Public License as published by
  421. X#  the Free Software Foundation; either version 1, or (at your option)
  422. X#  any later version.
  423. X#
  424. X#  This program is distributed in the hope that it will be useful,
  425. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  426. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  427. X#  GNU General Public License for more details.
  428. X#
  429. X#  You should have received a copy of the GNU General Public License
  430. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  431. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  432. X
  433. X# Installation directories.
  434. X#
  435. BIN=/usr/local/bin
  436. LIB=/usr/local/lib/cellular
  437. MAN=/usr/man/manl
  438. MAN_EXT=l
  439. X
  440. X# The default (maximum) sizes associated with Cellang programs.
  441. X#
  442. MAX_DIM_SIZE=64
  443. MAX_SUPPORTED_DIMENSIONS=16
  444. MAX_SUPPORTED_FIELDS=32
  445. X
  446. X# If you want to have the Cellang compiler configured to compile the viewer 
  447. X# into the executables then assign COMBINED the value "1", otherwise assign 
  448. X# a "0".  This makes for faster display of many automata, though it does need
  449. X# X11 to run them.
  450. X#
  451. COMBINED=0    # 0 or 1
  452. X
  453. X# The C type declaration to use for cell field declarations and the upper
  454. X# and lower bounds on the range of values supported by that data type.
  455. X# The range of values should be taken from the limits.h file used by your
  456. X# C compiler.
  457. X#
  458. XFIELD_TYPE = "unsigned char"
  459. MAX_RANGE_LB = 0
  460. MAX_RANGE_UB = 255
  461. X
  462. X# Choose a C compiler and options.
  463. X#
  464. CC= gcc
  465. CFLAGS= -O -ansi -pedantic 
  466. CDEFINES= -DCOMBINED=$(COMBINED)
  467. X
  468. X# Rules (default.mk on SunOS uses a -target option not supported by GNU C)
  469. X#
  470. COMPILE.c=$(CC) $(CFLAGS) $(CDEFINES) -DFIELD_TYPE=\"$(FIELD_TYPE)\" \
  471. X        -DMAX_RANGE_LB=$(MAX_RANGE_LB) -DMAX_RANGE_UB=$(MAX_RANGE_UB) \
  472. X        $(CPPFLAGS) -c
  473. X
  474. X# Dependencies
  475. X
  476. all: cellfront cellc Cellang.PS cellc.${MAN_EXT}
  477. X
  478. install: all
  479. X    - mkdir -p ${BIN}
  480. X    - mkdir -p ${LIB}
  481. X    - mkdir -p ${MAN}
  482. X
  483. X    install cellfront ${LIB}/cellfront
  484. X    install cellc ${BIN}/cellc
  485. X    install -m 644 cellc.${MAN_EXT} ${MAN}/cellc.${MAN_EXT}
  486. X
  487. deinstall:
  488. X    /bin/rm -f ${LIB}/cellfront
  489. X    /bin/rm -f ${BIN}/cellc
  490. X    /bin/rm -f ${MAN}/cellc.${MAN_EXT}
  491. X
  492. clean:
  493. X    /bin/rm -f *.o *.tab.h *.tab.c *.aux *.dvi *.log *.toc \
  494. X        cellc cellfront core cellc.${MAN_EXT} size.h
  495. X
  496. realclean: clean
  497. X    /bin/rm -f *.PS
  498. X
  499. cellfront: scanner.o semantic.o symtable.o y.tab.o error.o
  500. X    ${CC} ${CFLAGS} -o cellfront *.o
  501. X
  502. cellc.${MAN_EXT}: cellc.man
  503. X    sed -e 's?LIB_DIR?$(LIB)?' \
  504. X        -e 's?MAN_EXT?$(MAN_EXT)?g' cellc.man > cellc.${MAN_EXT}
  505. X
  506. size.h: ../Makefile
  507. X    echo "#define MAX_DIM_SIZE             ${MAX_DIM_SIZE}" > size.h
  508. X    echo "#define MAX_SUPPORTED_DIMENSIONS ${MAX_SUPPORTED_DIMENSIONS}" >> size.h
  509. X    echo "#define MAX_SUPPORTED_FIELDS     ${MAX_SUPPORTED_FIELDS}" >> size.h
  510. X
  511. semantic.o: semantic.c semantic.h symtable.h stack.h size.h\
  512. X        attribute.h boolean.h error.h
  513. X
  514. symtable.o: symtable.c symtable.h attribute.h boolean.h
  515. X
  516. scanner.o: scanner.c scanner.h y.tab.h error.h
  517. X
  518. error.o: error.c error.h
  519. X
  520. y.tab.h y.tab.c: parse error.h
  521. X    yacc -d parse
  522. X
  523. y.tab.o: parse attribute.h semantic.h symtable.h boolean.h error.h
  524. X
  525. cellc: cellc.sh
  526. X    sed -e 's?YOUR_LIB?$(LIB)?' \
  527. X        -e 's?YOUR_CC?$(CC)?' \
  528. X        -e 's?YOUR_CFLAGS?$(CFLAGS)?' \
  529. X        -e 's?YOUR_COMBINED?$(COMBINED)?' \
  530. X    cellc.sh > cellc
  531. X    chmod u+rx cellc
  532. X
  533. Cellang.PS: Cellang.tex
  534. X    - latex Cellang.tex
  535. X    - latex Cellang.tex
  536. X    - dvi2ps -r Cellang.dvi > Cellang.PS
  537. END_OF_FILE
  538. if test 3502 -ne `wc -c <'compiler/Makefile'`; then
  539.     echo shar: \"'compiler/Makefile'\" unpacked with wrong size!
  540. fi
  541. # end of 'compiler/Makefile'
  542. fi
  543. if test -f 'compiler/README' -a "${1}" != "-c" ; then 
  544.   echo shar: Will not clobber existing file \"'compiler/README'\"
  545. else
  546. echo shar: Extracting \"'compiler/README'\" \(1930 characters\)
  547. sed "s/^X//" >'compiler/README' <<'END_OF_FILE'
  548. X#  README
  549. X#  Copyright (C) 1992  J Dana Eckart
  550. X#
  551. X#  This program is free software; you can redistribute it and/or modify
  552. X#  it under the terms of the GNU General Public License as published by
  553. X#  the Free Software Foundation; either version 1, or (at your option)
  554. X#  any later version.
  555. X#
  556. X#  This program is distributed in the hope that it will be useful,
  557. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  558. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  559. X#  GNU General Public License for more details.
  560. X#
  561. X#  You should have received a copy of the GNU General Public License
  562. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  563. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  564. X
  565. To install the Cellang compiler, edit the Makefile to reflect the proper 
  566. values of:
  567. X
  568. X     BIN     - installation directory for executables
  569. X     LIB     - installation directory for supporting software
  570. X     MAN     - installation directory for manual pages
  571. X     MAX_EXT - manual page extension to use for installation
  572. X
  573. X     MAX_DIM_SIZE           - size of each dimension in Cellang 2.0 programs 
  574. X     MAX_SUPPORTED_DIMENSIONS - maximum allowed dimensions in programs
  575. X     MAX_SUPPORTED_FIELDS     - maximum allowed fields per cell in programs
  576. X
  577. X     FIELD_TYPE   - C data type to use for cell fields
  578. X     MAX_RANGE_LB - smallest value of FIELD_TYPE
  579. X     MAX_RANGE_UB - largest value of FIELD_TYPE
  580. X
  581. Do "make install" to build and install the compiler.  In addition, the 
  582. Makefile also supports the targets:
  583. X
  584. X    all: compile, but not install, the software
  585. X  deinstall: remove an installation
  586. X      clean: remove all but the distributed files (and postscript version of
  587. X        the language reference manual) within this directory
  588. X  realclean: remove all but the distributed files within this directory
  589. X
  590. The Cellang language reference manual is written in LaTeX and appears in
  591. Cellang.tex.
  592. END_OF_FILE
  593. if test 1930 -ne `wc -c <'compiler/README'`; then
  594.     echo shar: \"'compiler/README'\" unpacked with wrong size!
  595. fi
  596. # end of 'compiler/README'
  597. fi
  598. if test -f 'compiler/attribute.h' -a "${1}" != "-c" ; then 
  599.   echo shar: Will not clobber existing file \"'compiler/attribute.h'\"
  600. else
  601. echo shar: Extracting \"'compiler/attribute.h'\" \(1069 characters\)
  602. sed "s/^X//" >'compiler/attribute.h' <<'END_OF_FILE'
  603. X/* attribute.h
  604. X   Copyright (C) 1992  J Dana Eckart
  605. X  
  606. X   This program is free software; you can redistribute it and/or modify
  607. X   it under the terms of the GNU General Public License as published by
  608. X   the Free Software Foundation; either version 1, or (at your option)
  609. X   any later version.
  610. X  
  611. X   This program is distributed in the hope that it will be useful,
  612. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  613. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  614. X   GNU General Public License for more details.
  615. X  
  616. X   You should have received a copy of the GNU General Public License
  617. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  618. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  619. X*/
  620. X
  621. X#include "boolean.h"
  622. X
  623. X/* The exported declarations for attributes appearing in the symbol table. */
  624. X
  625. typedef struct {
  626. X    boolean assignable;     /* True iff assignable. */
  627. X    boolean field_name;    /* True iff the symbol is a cell field. */
  628. X    boolean structured;    /* True iff the value is structured. */
  629. X} attr_rec;
  630. END_OF_FILE
  631. if test 1069 -ne `wc -c <'compiler/attribute.h'`; then
  632.     echo shar: \"'compiler/attribute.h'\" unpacked with wrong size!
  633. fi
  634. # end of 'compiler/attribute.h'
  635. fi
  636. if test -f 'compiler/boolean.h' -a "${1}" != "-c" ; then 
  637.   echo shar: Will not clobber existing file \"'compiler/boolean.h'\"
  638. else
  639. echo shar: Extracting \"'compiler/boolean.h'\" \(817 characters\)
  640. sed "s/^X//" >'compiler/boolean.h' <<'END_OF_FILE'
  641. X/* boolean.h
  642. X   Copyright (C) 1992  J Dana Eckart
  643. X  
  644. X   This program is free software; you can redistribute it and/or modify
  645. X   it under the terms of the GNU General Public License as published by
  646. X   the Free Software Foundation; either version 1, or (at your option)
  647. X   any later version.
  648. X  
  649. X   This program is distributed in the hope that it will be useful,
  650. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  651. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  652. X   GNU General Public License for more details.
  653. X  
  654. X   You should have received a copy of the GNU General Public License
  655. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  656. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  657. X*/
  658. X
  659. X#define boolean int
  660. X
  661. X#define true     1
  662. X#define false     0
  663. END_OF_FILE
  664. if test 817 -ne `wc -c <'compiler/boolean.h'`; then
  665.     echo shar: \"'compiler/boolean.h'\" unpacked with wrong size!
  666. fi
  667. # end of 'compiler/boolean.h'
  668. fi
  669. if test -f 'compiler/cellc.man' -a "${1}" != "-c" ; then 
  670.   echo shar: Will not clobber existing file \"'compiler/cellc.man'\"
  671. else
  672. echo shar: Extracting \"'compiler/cellc.man'\" \(1147 characters\)
  673. sed "s/^X//" >'compiler/cellc.man' <<'END_OF_FILE'
  674. X.TH cellc 1
  675. X.SH NAME
  676. cellc \- 
  677. X.I "Cellang 2.0"
  678. X(cellular automata) compiler
  679. X.SH SYNOPSIS
  680. X.B cellc
  681. X[
  682. X.B \-o 
  683. X.I outputfile
  684. X]
  685. file
  686. X.SH DESCRIPTION
  687. X.I cellc
  688. is the Cellang celluar automata compiler.
  689. X.I cellc
  690. compiles and builds the executable for the Cellang program contained
  691. within file.  By default, the executable is placed in a.pe-scam.
  692. X.TP
  693. X.BI \-o " outputfile"
  694. Name the output file
  695. X.IR outputfile .
  696. X.I outputfile
  697. cannot be the same as 
  698. X.I sourcefile 
  699. X(the compiler will not overwrite the source file).  The default is
  700. X.I a.pe-scam.
  701. X.br
  702. X.ne 5
  703. X.SH FILES
  704. X file                 program text file
  705. X.br
  706. X a.pe-scam            default executable file
  707. X LIB_DIR/cellfront    program which actually generates the pe-scam object code
  708. X.SH "SEE ALSO"
  709. cellview(MAN_EXT), pe-scam(MAN_EXT)
  710. X.br
  711. J Dana Eckart,
  712. X.I "A Cellular Automata Simulation System: Version 2.0"
  713. X(1992)
  714. X.br
  715. J Dana Eckart,
  716. X.I "Cellang 2.0: Language Reference Manual"
  717. X(1992)
  718. X.SH DIAGNOSTICS
  719. The diagnostics produced by cellc are intended to be
  720. self-explanatory.
  721. X.SH BUGS
  722. The current implementation does not check to ensure that the values assigned 
  723. to fields are within the associated ranges.
  724. END_OF_FILE
  725. if test 1147 -ne `wc -c <'compiler/cellc.man'`; then
  726.     echo shar: \"'compiler/cellc.man'\" unpacked with wrong size!
  727. fi
  728. # end of 'compiler/cellc.man'
  729. fi
  730. if test -f 'compiler/cellc.sh' -a "${1}" != "-c" ; then 
  731.   echo shar: Will not clobber existing file \"'compiler/cellc.sh'\"
  732. else
  733. echo shar: Extracting \"'compiler/cellc.sh'\" \(1702 characters\)
  734. sed "s/^X//" >'compiler/cellc.sh' <<'END_OF_FILE'
  735. X#!/bin/sh
  736. X#  cellc.sh
  737. X#  Copyright (C) 1992  J Dana Eckart
  738. X#
  739. X#  This program is free software; you can redistribute it and/or modify
  740. X#  it under the terms of the GNU General Public License as published by
  741. X#  the Free Software Foundation; either version 1, or (at your option)
  742. X#  any later version.
  743. X#
  744. X#  This program is distributed in the hope that it will be useful,
  745. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  746. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  747. X#  GNU General Public License for more details.
  748. X#
  749. X#  You should have received a copy of the GNU General Public License
  750. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  751. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  752. X
  753. LIB=YOUR_LIB
  754. CC=YOUR_CC
  755. CFLAGS=YOUR_CFLAGS
  756. X
  757. COMBINED=YOUR_COMBINED
  758. X
  759. C_FILE=.cellang.c
  760. H_FILE=.cellang.h
  761. X
  762. USAGE="usage: `basename $0` [-o outputfile] filename"
  763. X
  764. trap "/bin/rm -f $C_FILE $H_FILE;exit" 0
  765. X
  766. X#
  767. X# Get options and check usage
  768. X#
  769. if (test $# -lt 1) then
  770. X    echo $USAGE
  771. X    exit 1
  772. fi
  773. X
  774. while (test $# -gt 1)
  775. do
  776. X    case $1 in
  777. X        '-o')     OUT_FILE="-o $2"
  778. X            shift
  779. X            ;;
  780. X        *)     echo "Unknown flag, '$1'."
  781. X            echo $USAGE
  782. X            exit 1
  783. X            ;;
  784. X    esac
  785. X    shift
  786. done
  787. X
  788. X# By default, put the executable in "a.pe-scam".
  789. X#
  790. if test -z "$OUT_FILE"
  791. then
  792. X    OUT_FILE="-o a.pe-scam"
  793. fi
  794. X
  795. XFILE=$1
  796. X
  797. X#
  798. X# Perform conversion to C and then do a c compilation.
  799. X#
  800. if test -r $FILE
  801. then
  802. X    $LIB/cellfront < $FILE 
  803. X    if test -s $C_FILE
  804. X    then
  805. X        if test "$COMBINED" = "1"
  806. X        then
  807. X            $CC $CFLAGS $OUT_FILE $C_FILE $LIB/*.o \
  808. X                -lm -lcurses -ltermcap -lX11
  809. X        else
  810. X            $CC $CFLAGS $OUT_FILE $C_FILE
  811. X        fi
  812. X    fi
  813. else
  814. X    echo "`basename $0`: file $FILE not found"
  815. fi
  816. X
  817. X/bin/rm -f $C_FILE $H_FILE
  818. END_OF_FILE
  819. if test 1702 -ne `wc -c <'compiler/cellc.sh'`; then
  820.     echo shar: \"'compiler/cellc.sh'\" unpacked with wrong size!
  821. fi
  822. # end of 'compiler/cellc.sh'
  823. fi
  824. if test -f 'compiler/error.c' -a "${1}" != "-c" ; then 
  825.   echo shar: Will not clobber existing file \"'compiler/error.c'\"
  826. else
  827. echo shar: Extracting \"'compiler/error.c'\" \(1191 characters\)
  828. sed "s/^X//" >'compiler/error.c' <<'END_OF_FILE'
  829. X/* error.c
  830. X   Copyright (C) 1992  J Dana Eckart
  831. X  
  832. X   This program is free software; you can redistribute it and/or modify
  833. X   it under the terms of the GNU General Public License as published by
  834. X   the Free Software Foundation; either version 1, or (at your option)
  835. X   any later version.
  836. X  
  837. X   This program is distributed in the hope that it will be useful,
  838. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  839. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  840. X   GNU General Public License for more details.
  841. X  
  842. X   You should have received a copy of the GNU General Public License
  843. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  844. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  845. X*/
  846. X
  847. X#include <stdio.h>
  848. X#include <malloc.h>
  849. X#include "error.h"
  850. X
  851. X/************************************************************************/
  852. X
  853. X/* SUPPORT ROUTINE
  854. X      ACTION - Malloc's the desired amount of space, issuing an
  855. X           error message if the space is not forthcoming.
  856. X*/
  857. char* mymalloc(size) unsigned int size; {
  858. X    char *pointer = malloc(size);
  859. X    if (NULL == pointer)
  860. X        error("Out of memory", (char*) NULL);
  861. X    return pointer;
  862. X}
  863. END_OF_FILE
  864. if test 1191 -ne `wc -c <'compiler/error.c'`; then
  865.     echo shar: \"'compiler/error.c'\" unpacked with wrong size!
  866. fi
  867. # end of 'compiler/error.c'
  868. fi
  869. if test -f 'compiler/error.h' -a "${1}" != "-c" ; then 
  870.   echo shar: Will not clobber existing file \"'compiler/error.h'\"
  871. else
  872. echo shar: Extracting \"'compiler/error.h'\" \(895 characters\)
  873. sed "s/^X//" >'compiler/error.h' <<'END_OF_FILE'
  874. X/* error.h
  875. X   Copyright (C) 1992  J Dana Eckart
  876. X  
  877. X   This program is free software; you can redistribute it and/or modify
  878. X   it under the terms of the GNU General Public License as published by
  879. X   the Free Software Foundation; either version 1, or (at your option)
  880. X   any later version.
  881. X  
  882. X   This program is distributed in the hope that it will be useful,
  883. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  884. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  885. X   GNU General Public License for more details.
  886. X  
  887. X   You should have received a copy of the GNU General Public License
  888. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  889. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  890. X*/
  891. X
  892. extern void error_prefix();    /* Prints prefix for error messages. */ 
  893. extern char* mymalloc();    /* A malloc that checks for success. */
  894. END_OF_FILE
  895. if test 895 -ne `wc -c <'compiler/error.h'`; then
  896.     echo shar: \"'compiler/error.h'\" unpacked with wrong size!
  897. fi
  898. # end of 'compiler/error.h'
  899. fi
  900. if test -f 'compiler/io.h' -a "${1}" != "-c" ; then 
  901.   echo shar: Will not clobber existing file \"'compiler/io.h'\"
  902. else
  903. echo shar: Extracting \"'compiler/io.h'\" \(884 characters\)
  904. sed "s/^X//" >'compiler/io.h' <<'END_OF_FILE'
  905. X/* io.h
  906. X   Copyright (C) 1992  J Dana Eckart
  907. X  
  908. X   This program is free software; you can redistribute it and/or modify
  909. X   it under the terms of the GNU General Public License as published by
  910. X   the Free Software Foundation; either version 1, or (at your option)
  911. X   any later version.
  912. X  
  913. X   This program is distributed in the hope that it will be useful,
  914. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  915. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  916. X   GNU General Public License for more details.
  917. X  
  918. X   You should have received a copy of the GNU General Public License
  919. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  920. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  921. X*/
  922. X
  923. extern FILE *file_h;        /* Denotes the C header output stream. */
  924. extern FILE *file_c;        /* Denotes the C code output stream. */
  925. END_OF_FILE
  926. if test 884 -ne `wc -c <'compiler/io.h'`; then
  927.     echo shar: \"'compiler/io.h'\" unpacked with wrong size!
  928. fi
  929. # end of 'compiler/io.h'
  930. fi
  931. if test -f 'compiler/parse' -a "${1}" != "-c" ; then 
  932.   echo shar: Will not clobber existing file \"'compiler/parse'\"
  933. else
  934. echo shar: Extracting \"'compiler/parse'\" \(5776 characters\)
  935. sed "s/^X//" >'compiler/parse' <<'END_OF_FILE'
  936. X%{
  937. X/* parse
  938. X   Copyright (C) 1992  J Dana Eckart
  939. X  
  940. X   This program is free software; you can redistribute it and/or modify
  941. X   it under the terms of the GNU General Public License as published by
  942. X   the Free Software Foundation; either version 1, or (at your option)
  943. X   any later version.
  944. X  
  945. X   This program is distributed in the hope that it will be useful,
  946. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  947. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  948. X   GNU General Public License for more details.
  949. X  
  950. X   You should have received a copy of the GNU General Public License
  951. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  952. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  953. X*/
  954. X
  955. X#include "semantic.h"
  956. X#include "scanner.h"
  957. X%}
  958. X
  959. X%token DIMENSIONS
  960. X%token IF
  961. X%token THEN
  962. X%token ELSIF
  963. X%token ELSE
  964. X%token END
  965. X%token WHEN
  966. X%token OTHERWISE
  967. X%token OF
  968. X%token ASSIGN
  969. X%token PLUS
  970. X%token MINUS
  971. X%token TIMES
  972. X%token DIVIDE
  973. X%token MOD
  974. X%token EQUAL
  975. X%token LESSER
  976. X%token GREATER
  977. X%token LESSEQ
  978. X%token GREATEQ
  979. X%token NOTEQ
  980. X%token AND
  981. X%token OR
  982. X%token NOT
  983. X%token LEFTPAREN
  984. X%token RIGHTPAREN
  985. X%token LEFTBRACKET
  986. X%token RIGHTBRACKET
  987. X%token COMMA
  988. X%token DOTS
  989. X%token DOT
  990. X%token IDENTIFIER
  991. X%token NUMERICLITERAL
  992. X
  993. X/* Unlike most yacc specifications, the following have also been
  994. X   written in LL(1) form.  This prevents yacc from making improper
  995. X   assumptions about breaking up a production because of embedded
  996. X   actions.  It also allows the use of an LL(1) parser generator,
  997. X   hopefully sometime in the near future.
  998. X*/
  999. X
  1000. X%start program
  1001. X
  1002. X%%
  1003. program        : declare_cells { begin_rules(); } 
  1004. X            statement_list { end_rules(); }
  1005. X        |
  1006. X        ;
  1007. X
  1008. declare_cells   : number { set_dimensions(); } DIMENSIONS 
  1009. X            OF fields_or_range
  1010. X        ;
  1011. X
  1012. fields_or_range : range { declare_default_field(); }
  1013. X        | { begin_decl_cells(); } field rest_fields
  1014. X            END { end_decl_cells(); }
  1015. X        ;
  1016. X
  1017. rest_fields    : field rest_fields
  1018. X        |
  1019. X        ;
  1020. X
  1021. field        : ident_list OF range { declare_fields(); }
  1022. X        ;
  1023. X
  1024. range        : integer DOTS integer { make_range(); }
  1025. X        ;
  1026. X
  1027. ident_list    : { push_mark(); } identifier rest_ident_list
  1028. X        ;
  1029. X
  1030. rest_ident_list : COMMA identifier rest_ident_list
  1031. X        |
  1032. X        ;
  1033. X
  1034. integer        : unary_add number { mk_signed_int(); }
  1035. X        | number
  1036. X        ;
  1037. X
  1038. number        : NUMERICLITERAL { process_literal(yytext); }
  1039. X        ;
  1040. X
  1041. statement_list    : statement statement_list
  1042. X        |
  1043. X        ;
  1044. X
  1045. statement    : assign_statement
  1046. X        | if_statement
  1047. X        ;
  1048. X
  1049. assign_statement: identifier { assignable_base(); } field_option
  1050. X            ASSIGN expression rest_assign
  1051. X        ;
  1052. X
  1053. X/* rest_assign is included solely for the jump_if semantic action; which
  1054. X   for rest_when is a jump_elseif.
  1055. X*/
  1056. rest_assign    : WHEN expression { jump_if(); do_assign(); } expression_list
  1057. X        | OTHERWISE 
  1058. X            { do_assign(); end_assign(); }
  1059. X        | { do_assign(); end_assign(); }
  1060. X        ;
  1061. X
  1062. rest_when    : WHEN expression { jump_elsif(); do_assign(); } expression_list
  1063. X        | OTHERWISE 
  1064. X            { start_else(); do_assign(); end_if(); end_assign(); }
  1065. X        ;
  1066. X
  1067. expression_list : ASSIGN expression rest_when
  1068. X        | { end_if(); end_assign(); }
  1069. X        ;
  1070. X
  1071. if_statement    : IF expression { jump_if(); } THEN statement_list
  1072. X              elsif_list else { end_if(); } END
  1073. X        ;
  1074. X
  1075. elsif_list      : elsif elsif_list
  1076. X        | 
  1077. X        ;
  1078. X
  1079. elsif           : ELSIF expression { jump_elsif(); } THEN statement_list
  1080. X        ;
  1081. X
  1082. else            : ELSE { start_else(); } statement_list 
  1083. X        | 
  1084. X        ;
  1085. X
  1086. X
  1087. X/* The numbered suffix is the precedence of that expression/operator. */
  1088. X
  1089. expression    : expression_1
  1090. X        ;
  1091. X
  1092. expression_1    : expression_2 rest_expr_1
  1093. X        | unary_boolean expression_2 { unary_op(); } rest_expr_1
  1094. X        ;
  1095. rest_expr_1    : binary_boolean expression_1 { binary_op(); }
  1096. X        |
  1097. X        ;
  1098. X
  1099. expression_2    : expression_3 rest_expr_2
  1100. X        ;
  1101. rest_expr_2    : binary_relation expression_2 { binary_op(); }
  1102. X        |
  1103. X        ;
  1104. X
  1105. expression_3    : expression_4 rest_expr_3
  1106. X                | unary_add expression_4 { unary_op(); } rest_expr_3
  1107. X        ;
  1108. rest_expr_3    : binary_add expression_3 { binary_op(); }
  1109. X        |
  1110. X        ;
  1111. X
  1112. expression_4    : primary rest_expr_4
  1113. X        ;
  1114. rest_expr_4    : binary_mult expression_4 { binary_op(); }
  1115. X        |
  1116. X        ;
  1117. X
  1118. primary         : identifier { get_variable(); } field_option
  1119. X        | number
  1120. X        | LEFTPAREN expression RIGHTPAREN
  1121. X        | LEFTBRACKET { push_mark(); }
  1122. X            integer rest_index_list 
  1123. X          RIGHTBRACKET { cell_reference(); } field_option
  1124. X        ;
  1125. X
  1126. rest_index_list    : COMMA integer rest_index_list
  1127. X        |
  1128. X        ;
  1129. X
  1130. field_option    : DOT identifier { field_reference(); }
  1131. X        |
  1132. X        ;
  1133. X
  1134. identifier      : IDENTIFIER  { push(yytext); }
  1135. X        ;
  1136. X
  1137. binary_boolean    : AND     { push("&&"); }
  1138. X        | OR      { push("||"); }
  1139. X        ;
  1140. unary_boolean    : NOT      { push("!"); }
  1141. X        ;
  1142. binary_relation    : EQUAL   { push("=="); }
  1143. X        | NOTEQ   { push("!="); }
  1144. X        | LESSER  { push("<"); }
  1145. X        | GREATER { push(">"); }
  1146. X        | LESSEQ  { push("<="); }
  1147. X        | GREATEQ { push(">="); }
  1148. X        ;
  1149. binary_add    : PLUS    { push("+"); }
  1150. X        | MINUS   { push("-"); }
  1151. X        ;
  1152. unary_add    : binary_add
  1153. X        ;
  1154. binary_mult    : TIMES   { push("*"); }
  1155. X        | DIVIDE  { push("/"); }
  1156. X        | MOD     { push("%"); }
  1157. X        ;
  1158. X
  1159. X%%
  1160. X
  1161. X#include <strings.h>
  1162. X#include <stdio.h>
  1163. X#include "io.h"
  1164. X
  1165. boolean syntax_error;    /* True iff a syntax error was encountered. */
  1166. X
  1167. void main(argc, argv) int argc; char *argv[]; {
  1168. X    if (argc-1 != 0) {
  1169. X        fprintf(stderr, "%s: No argument should be given\n", argv[0]);
  1170. X        exit(0);
  1171. X    }
  1172. X
  1173. X    syntax_error = false;
  1174. X    start_up();
  1175. X
  1176. X    /* Read and compile the user's program. */
  1177. X    startscan();
  1178. X    yyparse();
  1179. X
  1180. X    /* If no errors occurred, then finishup. */
  1181. X    if (!scan_error && !syntax_error && !semantic_error)
  1182. X        finish_up();
  1183. X
  1184. X    /* If errors occurred, then empty files and indicate an error. */
  1185. X    if (scan_error || syntax_error || semantic_error) {
  1186. X        fclose(file_h);
  1187. X        fclose(file_c);
  1188. X        file_h = fopen(".cellang.h", "w");
  1189. X        fclose(file_h);
  1190. X        file_c = fopen(".cellang.c", "w");
  1191. X        fclose(file_c);
  1192. X        exit(1);
  1193. X    }
  1194. X}
  1195. X
  1196. X#include "error.h"
  1197. X
  1198. void yyerror(s) char *s; {
  1199. X    syntax_error = true;
  1200. X    error_prefix();
  1201. X    fprintf(stderr, "%s\n", s);
  1202. X}
  1203. END_OF_FILE
  1204. if test 5776 -ne `wc -c <'compiler/parse'`; then
  1205.     echo shar: \"'compiler/parse'\" unpacked with wrong size!
  1206. fi
  1207. # end of 'compiler/parse'
  1208. fi
  1209. if test -f 'compiler/scanner.h' -a "${1}" != "-c" ; then 
  1210.   echo shar: Will not clobber existing file \"'compiler/scanner.h'\"
  1211. else
  1212. echo shar: Extracting \"'compiler/scanner.h'\" \(1077 characters\)
  1213. sed "s/^X//" >'compiler/scanner.h' <<'END_OF_FILE'
  1214. X/* scanner.h
  1215. X   Copyright (C) 1992  J Dana Eckart
  1216. X  
  1217. X   This program is free software; you can redistribute it and/or modify
  1218. X   it under the terms of the GNU General Public License as published by
  1219. X   the Free Software Foundation; either version 1, or (at your option)
  1220. X   any later version.
  1221. X  
  1222. X   This program is distributed in the hope that it will be useful,
  1223. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  1224. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1225. X   GNU General Public License for more details.
  1226. X  
  1227. X   You should have received a copy of the GNU General Public License
  1228. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  1229. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1230. X*/
  1231. X
  1232. X#include "y.tab.h"
  1233. X#include "boolean.h"
  1234. X
  1235. extern boolean scan_error;    /* True iff a scanning error was encountered. */
  1236. X
  1237. extern char yytext[];        /* Holds the text of a scanned token. */
  1238. X
  1239. extern void startscan();    /* Setup for scanning a new file. */
  1240. X
  1241. extern int yylex();        /* Function used to acquire the next token. */
  1242. END_OF_FILE
  1243. if test 1077 -ne `wc -c <'compiler/scanner.h'`; then
  1244.     echo shar: \"'compiler/scanner.h'\" unpacked with wrong size!
  1245. fi
  1246. # end of 'compiler/scanner.h'
  1247. fi
  1248. if test -f 'compiler/semantic.h' -a "${1}" != "-c" ; then 
  1249.   echo shar: Will not clobber existing file \"'compiler/semantic.h'\"
  1250. else
  1251. echo shar: Extracting \"'compiler/semantic.h'\" \(2117 characters\)
  1252. sed "s/^X//" >'compiler/semantic.h' <<'END_OF_FILE'
  1253. X/* semantic.h
  1254. X   Copyright (C) 1992  J Dana Eckart
  1255. X  
  1256. X   This program is free software; you can redistribute it and/or modify
  1257. X   it under the terms of the GNU General Public License as published by
  1258. X   the Free Software Foundation; either version 1, or (at your option)
  1259. X   any later version.
  1260. X  
  1261. X   This program is distributed in the hope that it will be useful,
  1262. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  1263. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1264. X   GNU General Public License for more details.
  1265. X  
  1266. X   You should have received a copy of the GNU General Public License
  1267. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  1268. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1269. X*/
  1270. X
  1271. X/* These are the declarations for all of the semantic actions. */
  1272. X
  1273. X#include "boolean.h"
  1274. X
  1275. extern boolean semantic_error;     /* True iff a semantic error was encountered. */
  1276. X
  1277. X/* initialization and cleanup for the compilation */
  1278. extern void start_up();
  1279. extern void finish_up();
  1280. X
  1281. X/* declare the dimensionality and fields of the cells of the universe. */
  1282. extern void begin_decl_cells();
  1283. extern void end_decl_cells();
  1284. extern void declare_fields();
  1285. extern void declare_default_field();
  1286. extern void make_range();
  1287. extern void set_dimensions();
  1288. X
  1289. X/* Group the cellular automata rules into a function. */
  1290. extern void begin_rules();
  1291. extern void end_rules();
  1292. X
  1293. X/* assignment statement */
  1294. extern void do_assign();
  1295. extern void end_assign();
  1296. X
  1297. X/* when statment */
  1298. extern void jump_when();
  1299. X
  1300. X/* if-then-elsif-else statment */
  1301. extern void jump_if();
  1302. extern void jump_elsif();
  1303. extern void start_else();
  1304. extern void end_if();
  1305. X
  1306. X/* simple push operations */
  1307. extern void push_mark();
  1308. extern void push();
  1309. X
  1310. X/* simple processing */
  1311. extern void process_literal();
  1312. extern void mk_signed_int();
  1313. X
  1314. X/* setup variables (left hand side of assignments) */
  1315. extern void assignable_base();
  1316. X
  1317. X/* expressions */
  1318. extern void get_variable();
  1319. extern void binary_op();
  1320. extern void unary_op();
  1321. X
  1322. X/* Getting the value from a neighboring cell. */
  1323. extern void cell_reference();
  1324. extern void field_reference();
  1325. END_OF_FILE
  1326. if test 2117 -ne `wc -c <'compiler/semantic.h'`; then
  1327.     echo shar: \"'compiler/semantic.h'\" unpacked with wrong size!
  1328. fi
  1329. # end of 'compiler/semantic.h'
  1330. fi
  1331. if test -f 'compiler/stack.h' -a "${1}" != "-c" ; then 
  1332.   echo shar: Will not clobber existing file \"'compiler/stack.h'\"
  1333. else
  1334. echo shar: Extracting \"'compiler/stack.h'\" \(1714 characters\)
  1335. sed "s/^X//" >'compiler/stack.h' <<'END_OF_FILE'
  1336. X/* stack.h
  1337. X   Copyright (C) 1992  J Dana Eckart
  1338. X  
  1339. X   This program is free software; you can redistribute it and/or modify
  1340. X   it under the terms of the GNU General Public License as published by
  1341. X   the Free Software Foundation; either version 1, or (at your option)
  1342. X   any later version.
  1343. X  
  1344. X   This program is distributed in the hope that it will be useful,
  1345. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  1346. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1347. X   GNU General Public License for more details.
  1348. X  
  1349. X   You should have received a copy of the GNU General Public License
  1350. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  1351. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1352. X*/
  1353. X
  1354. X/* The following define the different stack_entry kinds. */
  1355. X
  1356. X#define StackMark        1
  1357. X#define StackExpr              2
  1358. X#define StackToken        3
  1359. X#define StackError            4
  1360. X#define StackRange            5
  1361. X
  1362. typedef struct {
  1363. X    char *addr;         /* Reference name of the expression. */
  1364. X    char *field;         /* Field name of the expression.  This
  1365. X                   is used only for doing the implicit
  1366. X                   variable declarations to keep the
  1367. X                   field separate from the variable until
  1368. X                   its type can be inferred.
  1369. X                */
  1370. X    boolean assignable;     /* True iff assignable. */
  1371. X    boolean pre_declared;     /* True iff identifier was previous declared. */
  1372. X    boolean unstructured;    /* True iff expr_entry is NOT structured. */
  1373. X} expr_entry;
  1374. X
  1375. typedef struct {
  1376. X    int lower_bound;    /* Lower bound of a field range. */
  1377. X    int upper_bound;    /* Upper bound of a field range. */
  1378. X} range_entry;
  1379. X
  1380. typedef struct {
  1381. X    int kind;
  1382. X    union {
  1383. X        expr_entry        expr;
  1384. X        char            *token;
  1385. X        range_entry        range;
  1386. X    } data;
  1387. X} stack_entry;
  1388. END_OF_FILE
  1389. if test 1714 -ne `wc -c <'compiler/stack.h'`; then
  1390.     echo shar: \"'compiler/stack.h'\" unpacked with wrong size!
  1391. fi
  1392. # end of 'compiler/stack.h'
  1393. fi
  1394. if test -f 'compiler/symtable.c' -a "${1}" != "-c" ; then 
  1395.   echo shar: Will not clobber existing file \"'compiler/symtable.c'\"
  1396. else
  1397. echo shar: Extracting \"'compiler/symtable.c'\" \(3217 characters\)
  1398. sed "s/^X//" >'compiler/symtable.c' <<'END_OF_FILE'
  1399. X/* symtable.c
  1400. X   Copyright (C) 1992  J Dana Eckart
  1401. X  
  1402. X   This program is free software; you can redistribute it and/or modify
  1403. X   it under the terms of the GNU General Public License as published by
  1404. X   the Free Software Foundation; either version 1, or (at your option)
  1405. X   any later version.
  1406. X  
  1407. X   This program is distributed in the hope that it will be useful,
  1408. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  1409. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1410. X   GNU General Public License for more details.
  1411. X  
  1412. X   You should have received a copy of the GNU General Public License
  1413. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  1414. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1415. X*/
  1416. X
  1417. X/* This file implements the symbol table.  Bucket hashing is used,
  1418. X   associating an attribute with each identifier.  New identifiers 
  1419. X   are always added to the front of the chain representing the bucket.  
  1420. X*/
  1421. X
  1422. X#include <stdio.h>
  1423. X#include "attribute.h"
  1424. X#include "symtable.h"
  1425. X#include "error.h"
  1426. X
  1427. X#define TableSize    27
  1428. X
  1429. typedef struct bucket_fubar {
  1430. X    char* name;
  1431. X    attr_rec *attribute;
  1432. X    struct bucket_fubar *next;
  1433. X} bucket;
  1434. X
  1435. bucket *table[TableSize];
  1436. X
  1437. X/* Initializes every bucket in the hash table to be empty. */
  1438. void initsymboltable() {
  1439. X    int i;
  1440. X    for (i = 0; i < TableSize; i++) table[i] = NULL;
  1441. X}
  1442. X
  1443. X/* Calculates a hash value for the string based upon the first and
  1444. X   last characters in the string.  If the string contains only one
  1445. X   character, then it is used as both the first and last character.
  1446. X*/
  1447. int hash(string) char *string; {
  1448. X    return ( string[0] + string[strlen(string)-1] ) % TableSize;
  1449. X}
  1450. X
  1451. X/* Returns a pointer to the bucket in the hash table corresponding to
  1452. X   the specified string and name type.  If none is found then NULL is 
  1453. X   returned.
  1454. X*/
  1455. bucket *findid(string, name_type) char *string; int name_type; {
  1456. X    bucket *entry;
  1457. X    entry = table[hash(string)];
  1458. X    while (entry != NULL && (strcmp(string, entry->name) != 0
  1459. X        || entry->attribute->field_name != name_type))
  1460. X        entry = entry->next;
  1461. X    return entry;
  1462. X}
  1463. X
  1464. X/* Returns true iff a string of name type already appears in the symbol 
  1465. X   table. 
  1466. X*/
  1467. boolean intable(string, name_type) char *string; int name_type; {
  1468. X    if (findid(string, name_type) != NULL)
  1469. X        return true;
  1470. X    else
  1471. X        return false;
  1472. X}
  1473. X
  1474. X/* Enters the identifier, string, into the symbol table along with
  1475. X   its associated attribute, attr.  A copy of the string is made.
  1476. X*/
  1477. void enterid(string, attr) char *string; attr_rec attr; {
  1478. X    bucket *entry;
  1479. X    entry = findid(string, attr.field_name);
  1480. X    /* If string is not present, then add it. */
  1481. X    if (entry == NULL) {
  1482. X        int index;
  1483. X        index = hash(string);
  1484. X        entry = (bucket*) mymalloc(sizeof(bucket));
  1485. X        entry->name = mymalloc(strlen(string) + 1);
  1486. X        strcpy(entry->name, string);
  1487. X        entry->attribute = (attr_rec*) mymalloc(sizeof(attr_rec));
  1488. X        *(entry->attribute) = attr;
  1489. X        entry->next = table[index];
  1490. X        table[index] = entry;
  1491. X    }
  1492. X}
  1493. X
  1494. X/* Returns the attribute associated with the specified string and name type. */
  1495. attr_rec *get_attribute(string, name_type) char *string; int name_type; {
  1496. X    bucket *entry;
  1497. X    entry = findid(string, name_type);
  1498. X    if (entry != NULL) return entry->attribute;
  1499. X    else return NULL;
  1500. X}
  1501. END_OF_FILE
  1502. if test 3217 -ne `wc -c <'compiler/symtable.c'`; then
  1503.     echo shar: \"'compiler/symtable.c'\" unpacked with wrong size!
  1504. fi
  1505. # end of 'compiler/symtable.c'
  1506. fi
  1507. if test -f 'compiler/symtable.h' -a "${1}" != "-c" ; then 
  1508.   echo shar: Will not clobber existing file \"'compiler/symtable.h'\"
  1509. else
  1510. echo shar: Extracting \"'compiler/symtable.h'\" \(976 characters\)
  1511. sed "s/^X//" >'compiler/symtable.h' <<'END_OF_FILE'
  1512. X/* symtable.h
  1513. X   Copyright (C) 1992  J Dana Eckart
  1514. X  
  1515. X   This program is free software; you can redistribute it and/or modify
  1516. X   it under the terms of the GNU General Public License as published by
  1517. X   the Free Software Foundation; either version 1, or (at your option)
  1518. X   any later version.
  1519. X  
  1520. X   This program is distributed in the hope that it will be useful,
  1521. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  1522. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1523. X   GNU General Public License for more details.
  1524. X  
  1525. X   You should have received a copy of the GNU General Public License
  1526. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  1527. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1528. X*/
  1529. X
  1530. X/* The exported declarations for using the symbol table. */
  1531. X
  1532. X#define VARIABLE 0
  1533. X#define FIELD     1
  1534. X
  1535. extern void initsymboltable();
  1536. extern void enterid();
  1537. extern boolean intable();
  1538. extern attr_rec *get_attribute();
  1539. END_OF_FILE
  1540. if test 976 -ne `wc -c <'compiler/symtable.h'`; then
  1541.     echo shar: \"'compiler/symtable.h'\" unpacked with wrong size!
  1542. fi
  1543. # end of 'compiler/symtable.h'
  1544. fi
  1545. if test ! -d 'driver' ; then
  1546.     echo shar: Creating directory \"'driver'\"
  1547.     mkdir 'driver'
  1548. fi
  1549. if test -f 'driver/Makefile' -a "${1}" != "-c" ; then 
  1550.   echo shar: Will not clobber existing file \"'driver/Makefile'\"
  1551. else
  1552. echo shar: Extracting \"'driver/Makefile'\" \(2056 characters\)
  1553. sed "s/^X//" >'driver/Makefile' <<'END_OF_FILE'
  1554. X#  Makefile
  1555. X#  Copyright (C) 1992  J Dana Eckart
  1556. X#
  1557. X#  This program is free software; you can redistribute it and/or modify
  1558. X#  it under the terms of the GNU General Public License as published by
  1559. X#  the Free Software Foundation; either version 1, or (at your option)
  1560. X#  any later version.
  1561. X#
  1562. X#  This program is distributed in the hope that it will be useful,
  1563. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1564. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1565. X#  GNU General Public License for more details.
  1566. X#
  1567. X#  You should have received a copy of the GNU General Public License
  1568. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  1569. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1570. X
  1571. X# Installation directories.
  1572. X#
  1573. BIN=/usr/local/bin
  1574. LIB=/usr/local/lib/cellular
  1575. MAN=/usr/man/manl
  1576. MAN_EXT=l
  1577. X
  1578. X# The default maximum size of a single dimension within Cellang programs.
  1579. X#
  1580. MAX_DIM_SIZE=64
  1581. X
  1582. X# If you want to have the Cellang compiler configured to compile the viewer 
  1583. X# into the executables then assign COMBINED the value "1", otherwise assign 
  1584. X# a "0".  This makes for faster display of many automata, though it does need
  1585. X# X11 to run them.
  1586. X#
  1587. COMBINED=0    # 0 or 1
  1588. X
  1589. X# Dependencies
  1590. X
  1591. all: pe-scam pe-scam.${MAN_EXT}
  1592. X
  1593. install: all
  1594. X    - mkdir -p ${BIN}
  1595. X    - mkdir -p ${MAN}
  1596. X
  1597. X    install pe-scam ${BIN}/pe-scam
  1598. X    install -m 644 pe-scam.${MAN_EXT} ${MAN}/pe-scam.${MAN_EXT}
  1599. X
  1600. deinstall:
  1601. X    /bin/rm -f ${BIN}/pe-scam
  1602. X    /bin/rm -f ${MAN}/pe-scam.${MAN_EXT}
  1603. X
  1604. clean:
  1605. X    /bin/rm -f *.o *.tab.h *.tab.c *.aux *.dvi *.log *.toc \
  1606. X        pe-scam core pe-scam.${MAN_EXT}
  1607. X
  1608. realclean: clean
  1609. X
  1610. pe-scam: pe-scam.sh
  1611. X    sed -e 's?YOUR_LIB?$(LIB)?' \
  1612. X        -e 's?YOUR_BIN?$(BIN)?' \
  1613. X        -e 's?YOUR_CC?$(CC)?' \
  1614. X        -e 's?YOUR_CFLAGS?$(CFLAGS)?' \
  1615. X        -e 's?YOUR_MAX_DIM_SIZE?$(MAX_DIM_SIZE)?' \
  1616. X        -e 's?YOUR_COMBINED?$(COMBINED)?' \
  1617. X    pe-scam.sh > pe-scam
  1618. X    chmod u+rx pe-scam
  1619. X
  1620. pe-scam.${MAN_EXT}: pe-scam.man
  1621. X    sed -e 's?LIB_DIR?$(LIB)?' \
  1622. X        -e 's?MAN_EXT?$(MAN_EXT)?g' \
  1623. X        -e 's?MAX_DIM_SIZE?$(MAX_DIM_SIZE)?g' \
  1624. X        pe-scam.man > pe-scam.${MAN_EXT}
  1625. END_OF_FILE
  1626. if test 2056 -ne `wc -c <'driver/Makefile'`; then
  1627.     echo shar: \"'driver/Makefile'\" unpacked with wrong size!
  1628. fi
  1629. # end of 'driver/Makefile'
  1630. fi
  1631. if test -f 'driver/pe-scam.sh' -a "${1}" != "-c" ; then 
  1632.   echo shar: Will not clobber existing file \"'driver/pe-scam.sh'\"
  1633. else
  1634. echo shar: Extracting \"'driver/pe-scam.sh'\" \(3453 characters\)
  1635. sed "s/^X//" >'driver/pe-scam.sh' <<'END_OF_FILE'
  1636. X#!/bin/sh
  1637. X#  pe-scam.sh
  1638. X#  Copyright (C) 1992  J Dana Eckart
  1639. X#
  1640. X#  This program is free software; you can redistribute it and/or modify
  1641. X#  it under the terms of the GNU General Public License as published by
  1642. X#  the Free Software Foundation; either version 1, or (at your option)
  1643. X#  any later version.
  1644. X#
  1645. X#  This program is distributed in the hope that it will be useful,
  1646. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1647. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1648. X#  GNU General Public License for more details.
  1649. X#
  1650. X#  You should have received a copy of the GNU General Public License
  1651. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  1652. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1653. X
  1654. LIB=YOUR_LIB
  1655. BIN=YOUR_BIN
  1656. CC=YOUR_CC
  1657. MAX_DIM_SIZE=YOUR_MAX_DIM_SIZE
  1658. COMBINED=YOUR_COMBINED
  1659. X
  1660. CFLAGS='YOUR_CFLAGS'
  1661. X
  1662. USAGE="usage: ... | `basename $0` [-r timefile] [-c codefile] \
  1663. X            (-o | [-curses | -x11] [-display X11_display]\
  1664. X                  [-p n] [-s n] [-map mapfile] [-f n]\
  1665. X                      [-dim [n|n..n]{,n|,n..n}])"
  1666. X
  1667. trap "exit" 0
  1668. X
  1669. CODEFILE="a.pe-scam"
  1670. X
  1671. while (test $# -gt 0)
  1672. do
  1673. X    case $1 in
  1674. X        '-o')     if test -n "$CURSES" -o \
  1675. X                -n "$X11" -o \
  1676. X                -n "$X_DISPLAY" -o \
  1677. X                -n "$MAPFILE" -o \
  1678. X                -n "$PAUSE" -o \
  1679. X                -n "$SIZE" -o \
  1680. X                -n "$FIELD"
  1681. X            then
  1682. X                echo $USAGE
  1683. X                exit 1
  1684. X            else
  1685. X                OUTPUT=yes
  1686. X            fi
  1687. X            ;;
  1688. X        '-c')     CODEFILE=$2
  1689. X            shift
  1690. X            ;;
  1691. X        '-r')     if test "$COMBINED" = "0"
  1692. X            then
  1693. X                TIMEFILE=$2
  1694. X            else
  1695. X                TIMEFILE="-r $2"
  1696. X            fi
  1697. X            shift
  1698. X            ;;
  1699. X        '-curses') 
  1700. X            if test -n "$OUTPUT"
  1701. X            then
  1702. X                echo $USAGE
  1703. X                exit 1
  1704. X            else
  1705. X                CURSES=$1
  1706. X            fi
  1707. X            ;;
  1708. X        '-x11')    if test -n "$OUTPUT"
  1709. X            then
  1710. X                echo $USAGE
  1711. X                exit 1
  1712. X            else
  1713. X                X11=$1
  1714. X            fi
  1715. X            ;;
  1716. X        '-display') 
  1717. X            if test -n "$OUTPUT"
  1718. X            then
  1719. X                echo $USAGE
  1720. X                exit 1
  1721. X            else
  1722. X                X_DISPLAY="-display $2"
  1723. X            fi
  1724. X            shift
  1725. X            ;;
  1726. X        '-map') if test -n "$OUTPUT"
  1727. X            then
  1728. X                echo $USAGE
  1729. X                exit 1
  1730. X            else
  1731. X                MAPFILE="-map $2"
  1732. X            fi
  1733. X            shift
  1734. X            ;;
  1735. X        '-p')   if test -n "$OUTPUT"
  1736. X            then
  1737. X                echo $USAGE
  1738. X                exit 1
  1739. X            else
  1740. X                PAUSE="-p $2"
  1741. X            fi
  1742. X            shift
  1743. X            ;;
  1744. X        '-s')   if test -n "$OUTPUT"
  1745. X            then
  1746. X                echo $USAGE
  1747. X                exit 1
  1748. X            else
  1749. X                SIZE="-s $2"
  1750. X            fi
  1751. X            shift
  1752. X            ;;
  1753. X        '-f')   if test -n "$OUTPUT"
  1754. X            then
  1755. X                echo $USAGE
  1756. X                exit 1
  1757. X            else
  1758. X                FIELD="-f $2"
  1759. X            fi
  1760. X            shift
  1761. X            ;;
  1762. X        '-dim') if test -n "$OUTPUT"
  1763. X            then
  1764. X                echo $USAGE
  1765. X                exit 1
  1766. X            else
  1767. X                DIM="$2"
  1768. X            fi
  1769. X            shift
  1770. X            ;;
  1771. X        *)     echo "Unknown flag, '$1'."
  1772. X            echo $USAGE
  1773. X            exit 1
  1774. X            ;;
  1775. X    esac
  1776. X    shift
  1777. done
  1778. X
  1779. X#
  1780. X# Fix up the TIMEFILE is necessary.
  1781. X#
  1782. if test "$COMBINED" = "0" -a -z "$TIMEFILE"
  1783. then
  1784. X        TIMEFILE="-"
  1785. fi
  1786. X
  1787. X#
  1788. X# Make sure there is a valid codefile
  1789. X#
  1790. if test ! -x $CODEFILE
  1791. then
  1792. X    echo $USAGE
  1793. X    exit 1
  1794. fi
  1795. X
  1796. X#
  1797. X# Perform the pe-scam simulation.
  1798. X#
  1799. if test "$OUTPUT" = "yes"
  1800. then
  1801. X    if test "$COMBINED" = "0"
  1802. X    then
  1803. X        $CODEFILE $TIMEFILE
  1804. X    else
  1805. X        $CODEFILE $TIMEFILE -o
  1806. X    fi
  1807. else
  1808. X
  1809. X    # If no -dim option given, then use the default.
  1810. X    #
  1811. X    if test -z "$DIM"
  1812. X    then
  1813. X        # Display only a small portion if using curses.
  1814. X        #
  1815. X        if test -n "$CURSES"
  1816. X        then
  1817. X            DIM=0..20,0..20
  1818. X        else
  1819. X            MAX_DIM_SIZE=`echo "$MAX_DIM_SIZE 1 - p" | dc`
  1820. X            DIM=0..${MAX_DIM_SIZE},0..${MAX_DIM_SIZE}
  1821. X        fi
  1822. X    fi
  1823. X
  1824. X    if test "$COMBINED" = "0"
  1825. X    then
  1826. X        $CODEFILE $TIMEFILE | \
  1827. X            $BIN/cellview $CURSES $X11 $MAPFILE $SIZE $PAUSE \
  1828. X            $FIELD $X_DISPLAY -dim $DIM
  1829. X    else
  1830. X        $CODEFILE $TIMEFILE \
  1831. X            $CURSES $X11 $MAPFILE $SIZE $PAUSE \
  1832. X            $FIELD $X_DISPLAY -dim $DIM
  1833. X    fi
  1834. fi
  1835. END_OF_FILE
  1836. if test 3453 -ne `wc -c <'driver/pe-scam.sh'`; then
  1837.     echo shar: \"'driver/pe-scam.sh'\" unpacked with wrong size!
  1838. fi
  1839. # end of 'driver/pe-scam.sh'
  1840. fi
  1841. if test ! -d 'examples' ; then
  1842.     echo shar: Creating directory \"'examples'\"
  1843.     mkdir 'examples'
  1844. fi
  1845. if test -f 'examples/Makefile' -a "${1}" != "-c" ; then 
  1846.   echo shar: Will not clobber existing file \"'examples/Makefile'\"
  1847. else
  1848. echo shar: Extracting \"'examples/Makefile'\" \(2393 characters\)
  1849. sed "s/^X//" >'examples/Makefile' <<'END_OF_FILE'
  1850. X#  Makefile
  1851. X#  Copyright (C) 1992  J Dana Eckart
  1852. X#
  1853. X#  This program is free software; you can redistribute it and/or modify
  1854. X#  it under the terms of the GNU General Public License as published by
  1855. X#  the Free Software Foundation; either version 1, or (at your option)
  1856. X#  any later version.
  1857. X#
  1858. X#  This program is distributed in the hope that it will be useful,
  1859. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1860. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1861. X#  GNU General Public License for more details.
  1862. X#
  1863. X#  You should have received a copy of the GNU General Public License
  1864. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  1865. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1866. X
  1867. X# The place where cellc can be found
  1868. X#
  1869. BIN=/usr/local/bin
  1870. X
  1871. X# The default (maximum) sizes associated with Cellang programs.
  1872. X#
  1873. MAX_DIM_SIZE=64
  1874. X
  1875. X# Choose a C compiler and options.
  1876. X#
  1877. CC = gcc
  1878. CFLAGS = -O -ansi -pedantic
  1879. X
  1880. X# Rules (default.mk on SunOS uses a -target option not supported by GNU C)
  1881. X#
  1882. COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
  1883. X
  1884. X# Dependencies
  1885. X
  1886. all: show \
  1887. X    bin/life bin/gas bin/dist bin/srdp bin/parity bin/cparity \
  1888. X    data/srdp data/gas data/dist
  1889. X
  1890. install: all
  1891. X    - mkdir -p ${LIB}
  1892. X
  1893. X    cp -r . ${LIB}/examples
  1894. X    /bin/rm -f ${LIB}/examples/show.sh
  1895. X    /bin/rm -f ${LIB}/examples/Makefile
  1896. X    /bin/rm -f ${LIB}/examples/gas_data_gen*
  1897. X    /bin/rm -f ${LIB}/examples/srdp_data_gen*
  1898. X    /bin/rm -f ${LIB}/examples/dist_data_gen*
  1899. X    chmod -R uog+r ${LIB}/examples
  1900. X
  1901. clean:
  1902. X    /bin/rm -f show bin/* 
  1903. X    /bin/rm -f gas_data_gen srdp_data_gen dist_data_gen
  1904. X    /bin/rm -f data/gas data/srdp data/dist
  1905. X    find . -name core -exec /bin/rm -f {} \;
  1906. X
  1907. realclean: clean
  1908. X
  1909. deinstall:
  1910. X    /bin/rm -rf ${LIB}/examples
  1911. X
  1912. show: show.sh
  1913. X    sed -e 's?YOUR_BIN?$(BIN)?' show.sh > show
  1914. X    chmod uog+rx show
  1915. X
  1916. bin/life: src/life
  1917. X    ../compiler/cellc -o bin/life src/life
  1918. X
  1919. bin/gas: src/gas
  1920. X    ../compiler/cellc -o bin/gas src/gas
  1921. X
  1922. bin/dist: src/dist
  1923. X    ../compiler/cellc -o bin/dist src/dist
  1924. X
  1925. bin/srdp: src/srdp
  1926. X    ../compiler/cellc -o bin/srdp src/srdp
  1927. X
  1928. bin/parity: src/parity
  1929. X    ../compiler/cellc -o bin/parity src/parity
  1930. X
  1931. bin/cparity: src/cparity
  1932. X    ../compiler/cellc -o bin/cparity src/cparity
  1933. X
  1934. data/srdp: srdp_data_gen
  1935. X    ./srdp_data_gen ${MAX_DIM_SIZE} > data/srdp
  1936. X
  1937. data/gas: gas_data_gen
  1938. X    ./gas_data_gen ${MAX_DIM_SIZE} > data/gas
  1939. X
  1940. data/dist: dist_data_gen
  1941. X    ./dist_data_gen ${MAX_DIM_SIZE} > data/dist
  1942. END_OF_FILE
  1943. if test 2393 -ne `wc -c <'examples/Makefile'`; then
  1944.     echo shar: \"'examples/Makefile'\" unpacked with wrong size!
  1945. fi
  1946. # end of 'examples/Makefile'
  1947. fi
  1948. if test -f 'examples/README' -a "${1}" != "-c" ; then 
  1949.   echo shar: Will not clobber existing file \"'examples/README'\"
  1950. else
  1951. echo shar: Extracting \"'examples/README'\" \(1312 characters\)
  1952. sed "s/^X//" >'examples/README' <<'END_OF_FILE'
  1953. X#  README
  1954. X#  Copyright (C) 1992  J Dana Eckart
  1955. X#
  1956. X#  This program is free software; you can redistribute it and/or modify
  1957. X#  it under the terms of the GNU General Public License as published by
  1958. X#  the Free Software Foundation; either version 1, or (at your option)
  1959. X#  any later version.
  1960. X#
  1961. X#  This program is distributed in the hope that it will be useful,
  1962. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1963. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1964. X#  GNU General Public License for more details.
  1965. X#
  1966. X#  You should have received a copy of the GNU General Public License
  1967. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  1968. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1969. X
  1970. This directory contains several sample Cellang programs. The command "show"
  1971. shows which programs are available.  To see one of them do either:
  1972. X
  1973. X    show name
  1974. or
  1975. X    show name host
  1976. X
  1977. both will run the Cellang program corresponding to name (found in the "src"
  1978. directory), but the second will assume that the results are being displayed
  1979. in X windows and should be displayed on the named host.
  1980. X
  1981. The "bin" directory contains the executables for the Cellang programs which 
  1982. appear in the "src" directory.  The input files to each automata appear in
  1983. the "data" directory.
  1984. END_OF_FILE
  1985. if test 1312 -ne `wc -c <'examples/README'`; then
  1986.     echo shar: \"'examples/README'\" unpacked with wrong size!
  1987. fi
  1988. # end of 'examples/README'
  1989. fi
  1990. if test ! -d 'examples/bin' ; then
  1991.     echo shar: Creating directory \"'examples/bin'\"
  1992.     mkdir 'examples/bin'
  1993. fi
  1994. if test ! -d 'examples/data' ; then
  1995.     echo shar: Creating directory \"'examples/data'\"
  1996.     mkdir 'examples/data'
  1997. fi
  1998. if test -f 'examples/data/cparity' -a "${1}" != "-c" ; then 
  1999.   echo shar: Will not clobber existing file \"'examples/data/cparity'\"
  2000. else
  2001. echo shar: Extracting \"'examples/data/cparity'\" \(15 characters\)
  2002. sed "s/^X//" >'examples/data/cparity' <<'END_OF_FILE'
  2003. X0
  2004. X[32, 32] = 1
  2005. END_OF_FILE
  2006. if test 15 -ne `wc -c <'examples/data/cparity'`; then
  2007.     echo shar: \"'examples/data/cparity'\" unpacked with wrong size!
  2008. fi
  2009. # end of 'examples/data/cparity'
  2010. fi
  2011. if test -f 'examples/data/life' -a "${1}" != "-c" ; then 
  2012.   echo shar: Will not clobber existing file \"'examples/data/life'\"
  2013. else
  2014. echo shar: Extracting \"'examples/data/life'\" \(713 characters\)
  2015. sed "s/^X//" >'examples/data/life' <<'END_OF_FILE'
  2016. X0
  2017. X[27, 16] = 1
  2018. X[27, 17] = 1
  2019. X[20, 17] = 1
  2020. X[20, 21] = 1
  2021. X[21, 18] = 1
  2022. X[21, 19] = 1
  2023. X[21, 20] = 1
  2024. X[22, 18] = 1
  2025. X[22, 19] = 1
  2026. X[22, 20] = 1
  2027. X[28, 23] = 1
  2028. X[29, 24] = 1
  2029. X[29, 25] = 1
  2030. X[30, 23] = 1
  2031. X[30, 24] = 1
  2032. X[28, 18] = 1
  2033. X[28, 19] = 1
  2034. X[29, 18] = 1
  2035. X[29, 19] = 1
  2036. X[30, 18] = 1
  2037. X[30, 19] = 1
  2038. X[31, 19] = 1
  2039. X[31, 20] = 1
  2040. X[27, 18] = 1
  2041. X[19, 22] = 1
  2042. X[18, 17] = 1
  2043. X[19, 16] = 1
  2044. X[17, 18] = 1
  2045. X[17, 19] = 1
  2046. X[17, 20] = 1
  2047. X[18, 21] = 1
  2048. X[6, 19] = 1
  2049. X[6, 20] = 1
  2050. X[7, 19] = 1
  2051. X[7, 20] = 1
  2052. X[28, 15] = 1
  2053. X[28, 16] = 1
  2054. X[29, 15] = 1
  2055. X[29, 16] = 1
  2056. X[30, 15] = 1
  2057. X[30, 16] = 1
  2058. X[30, 17] = 1
  2059. X[31, 14] = 1
  2060. X[31, 15] = 1
  2061. X[40, 18] = 1
  2062. X[41, 18] = 1
  2063. X[40, 17] = 1
  2064. X[41, 17] = 1
  2065. X[59, 54] = 1
  2066. X[56, 51] = 1
  2067. X[56, 52] = 1
  2068. X[57, 51] = 1
  2069. X[57, 53] = 1
  2070. X[58, 53] = 1
  2071. X[59, 53] = 1
  2072. END_OF_FILE
  2073. if test 713 -ne `wc -c <'examples/data/life'`; then
  2074.     echo shar: \"'examples/data/life'\" unpacked with wrong size!
  2075. fi
  2076. # end of 'examples/data/life'
  2077. fi
  2078. if test -f 'examples/data/parity' -a "${1}" != "-c" ; then 
  2079.   echo shar: Will not clobber existing file \"'examples/data/parity'\"
  2080. else
  2081. echo shar: Extracting \"'examples/data/parity'\" \(15 characters\)
  2082. sed "s/^X//" >'examples/data/parity' <<'END_OF_FILE'
  2083. X0
  2084. X[32, 32] = 1
  2085. END_OF_FILE
  2086. if test 15 -ne `wc -c <'examples/data/parity'`; then
  2087.     echo shar: \"'examples/data/parity'\" unpacked with wrong size!
  2088. fi
  2089. # end of 'examples/data/parity'
  2090. fi
  2091. if test -f 'examples/dist_data_gen.c' -a "${1}" != "-c" ; then 
  2092.   echo shar: Will not clobber existing file \"'examples/dist_data_gen.c'\"
  2093. else
  2094. echo shar: Extracting \"'examples/dist_data_gen.c'\" \(1457 characters\)
  2095. sed "s/^X//" >'examples/dist_data_gen.c' <<'END_OF_FILE'
  2096. X/* dist_data_gen.c
  2097. X   Copyright (C) 1992  J Dana Eckart
  2098. X
  2099. X   This program is free software; you can redistribute it and/or modify
  2100. X   it under the terms of the GNU General Public License as published by
  2101. X   the Free Software Foundation; either version 1, or (at your option)
  2102. X   any later version.
  2103. X   This program is distributed in the hope that it will be useful,
  2104. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  2105. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2106. X   GNU General Public License for more details.
  2107. X   You should have received a copy of the GNU General Public License
  2108. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2109. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2110. X*/
  2111. X
  2112. X/* Generate the input data used by dist.  A single command line argument
  2113. X   indicates the size of each of two dimensions of the cell universe.
  2114. X*/
  2115. X
  2116. X#include <stdio.h>
  2117. X
  2118. int main(argc, argv) int argc; char *argv[]; {
  2119. X    int max_size = atoi(argv[1]);
  2120. X    int x, y;
  2121. X
  2122. X    printf("0\n");
  2123. X
  2124. X    for (x = 0; x < max_size; x++)
  2125. X        for (y = 0; y < max_size; y++) {
  2126. X            /* Write cell location. */
  2127. X            printf("[%d, %d] = ", x, y);
  2128. X
  2129. X            /* Write "which" field value. */
  2130. X            if ((x+y)%2 == 0)
  2131. X                printf("1");
  2132. X            else
  2133. X                printf("0");
  2134. X
  2135. X            /* Write "dist" field value. */
  2136. X            if (x == max_size/2 && 
  2137. X                (y == max_size/2 || 
  2138. X                    y == max_size/2 + (max_size%2?1:-1)))
  2139. X                printf(", 1");
  2140. X
  2141. X            printf("\n");
  2142. X        }
  2143. X
  2144. X    return 0;
  2145. X}
  2146. END_OF_FILE
  2147. if test 1457 -ne `wc -c <'examples/dist_data_gen.c'`; then
  2148.     echo shar: \"'examples/dist_data_gen.c'\" unpacked with wrong size!
  2149. fi
  2150. # end of 'examples/dist_data_gen.c'
  2151. fi
  2152. if test -f 'examples/gas_data_gen.c' -a "${1}" != "-c" ; then 
  2153.   echo shar: Will not clobber existing file \"'examples/gas_data_gen.c'\"
  2154. else
  2155. echo shar: Extracting \"'examples/gas_data_gen.c'\" \(1640 characters\)
  2156. sed "s/^X//" >'examples/gas_data_gen.c' <<'END_OF_FILE'
  2157. X/* gas_data_gen.c
  2158. X   Copyright (C) 1992  J Dana Eckart
  2159. X
  2160. X   This program is free software; you can redistribute it and/or modify
  2161. X   it under the terms of the GNU General Public License as published by
  2162. X   the Free Software Foundation; either version 1, or (at your option)
  2163. X   any later version.
  2164. X   This program is distributed in the hope that it will be useful,
  2165. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  2166. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2167. X   GNU General Public License for more details.
  2168. X   You should have received a copy of the GNU General Public License
  2169. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2170. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2171. X*/
  2172. X
  2173. X/* Generate the input data used by gas.  A single command line argument
  2174. X   indicates the size of each of two dimensions of the cell universe.
  2175. X*/
  2176. X
  2177. X#include <stdio.h>
  2178. X
  2179. int main(argc, argv) int argc; char *argv[]; {
  2180. X    int max_size = atoi(argv[1]);
  2181. X    int x, y;
  2182. X
  2183. X    printf("0\n");
  2184. X
  2185. X    for (x = 0; x < max_size; x++)
  2186. X        for (y = 0; y < max_size; y++) {
  2187. X            /* Write cell location. */
  2188. X            printf("[%d, %d] = ", x, y);
  2189. X
  2190. X            /* Write "which" field value. */
  2191. X            if (x%2 == 0 && y%2 == 0)
  2192. X                printf("3");
  2193. X            else if (x%2 == 0 && y%2 == 1)
  2194. X                printf("1");
  2195. X            else if (x%2 == 1 && y%2 == 0)
  2196. X                printf("2");
  2197. X            else
  2198. X                printf("0");
  2199. X
  2200. X            /* Write "rand" field value. */
  2201. X            printf(", %d", random()%2);
  2202. X
  2203. X            /* Write "gas" field value. */
  2204. X            if (0.33*max_size < x && x < 0.66*max_size
  2205. X                          &&
  2206. X                0.33*max_size < y && y < 0.66*max_size)
  2207. X                printf(", 1");
  2208. X
  2209. X            printf("\n");
  2210. X        }
  2211. X
  2212. X    return 0;
  2213. X}
  2214. END_OF_FILE
  2215. if test 1640 -ne `wc -c <'examples/gas_data_gen.c'`; then
  2216.     echo shar: \"'examples/gas_data_gen.c'\" unpacked with wrong size!
  2217. fi
  2218. # end of 'examples/gas_data_gen.c'
  2219. fi
  2220. if test ! -d 'examples/map' ; then
  2221.     echo shar: Creating directory \"'examples/map'\"
  2222.     mkdir 'examples/map'
  2223. fi
  2224. if test -f 'examples/map/srdp' -a "${1}" != "-c" ; then 
  2225.   echo shar: Will not clobber existing file \"'examples/map/srdp'\"
  2226. else
  2227. echo shar: Extracting \"'examples/map/srdp'\" \(100 characters\)
  2228. sed "s/^X//" >'examples/map/srdp' <<'END_OF_FILE'
  2229. X0    65535     0     0
  2230. X1        0 65535     0
  2231. X2        0 65535 65535
  2232. X3        0     0 65535
  2233. X4    65535     0 65535
  2234. END_OF_FILE
  2235. if test 100 -ne `wc -c <'examples/map/srdp'`; then
  2236.     echo shar: \"'examples/map/srdp'\" unpacked with wrong size!
  2237. fi
  2238. # end of 'examples/map/srdp'
  2239. fi
  2240. if test -f 'examples/show.sh' -a "${1}" != "-c" ; then 
  2241.   echo shar: Will not clobber existing file \"'examples/show.sh'\"
  2242. else
  2243. echo shar: Extracting \"'examples/show.sh'\" \(2621 characters\)
  2244. sed "s/^X//" >'examples/show.sh' <<'END_OF_FILE'
  2245. X#!/bin/sh
  2246. X#  show.sh
  2247. X#  Copyright (C) 1992  J Dana Eckart
  2248. X#
  2249. X#  This program is free software; you can redistribute it and/or modify
  2250. X#  it under the terms of the GNU General Public License as published by
  2251. X#  the Free Software Foundation; either version 1, or (at your option)
  2252. X#  any later version.
  2253. X#
  2254. X#  This program is distributed in the hope that it will be useful,
  2255. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2256. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2257. X#  GNU General Public License for more details.
  2258. X#
  2259. X#  You should have received a copy of the GNU General Public License
  2260. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2261. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2262. X
  2263. X# Compile and run with the appropriate data file (if needed/available)
  2264. X# a Cellang program contained within the filename given.
  2265. X#
  2266. X
  2267. X# Location of cellview
  2268. X#
  2269. BIN=YOUR_BIN
  2270. WD=`dirname $0`
  2271. X
  2272. CC=gcc
  2273. X
  2274. X# Check the usage
  2275. X#
  2276. USAGE="usage: `basename $1` filename [ x11_display ]"
  2277. X
  2278. if test $# -eq 0
  2279. then
  2280. X    echo "The available examples are:"
  2281. X    echo " "
  2282. X    echo "     life    -- the game of life (with gun and eater)"
  2283. X    echo "     gas     -- simulates diffusion of two gases"
  2284. X    echo "     dist    -- shows distance using hexagonal neighborhood"
  2285. X    echo "     srdp    -- scissors, rock, dynamite, paper"
  2286. X    echo "     parity  -- a black & white position parity matrix"
  2287. X    echo "     cparity -- a color position parity matrix"
  2288. X    echo " "
  2289. X    exit 0
  2290. elif test $# -gt 2
  2291. then
  2292. X    echo $USAGE
  2293. X    exit 1
  2294. fi
  2295. X
  2296. X# Find the executable
  2297. X#
  2298. NAME=$1
  2299. if test ! -x $WD/bin/$NAME
  2300. then
  2301. X    if test ! -r $WD/src/$NAME
  2302. X    then
  2303. X        echo "`basename $0`: file '$WD/src/$NAME' not found"
  2304. X    else
  2305. X        echo "`basename $0`: file '$WD/src/$NAME' not compiled"
  2306. X    fi
  2307. X    exit 1
  2308. fi
  2309. X
  2310. echo "displaying results of '$NAME' ..."
  2311. X
  2312. X# Determine the type of display, use x11 if either the current terminal
  2313. X# type is an xterm, or if another machine was given on which to display
  2314. X# the results.
  2315. X#
  2316. if test "$TERM" = "xterm" -o $# -eq 2
  2317. then
  2318. X    DISPLAY=-x11
  2319. X    if (test $# -eq 2) then
  2320. X        DISPLAY="$DISPLAY -display $2:0"
  2321. X    else
  2322. X        DISPLAY="$DISPLAY -display `hostname`:0"
  2323. X    fi
  2324. else
  2325. X    DISPLAY=-curses
  2326. fi
  2327. X
  2328. X# Use the proper color map.
  2329. X#
  2330. if test "$NAME" = "srdp"
  2331. then
  2332. X    MAP="-map map/srdp"
  2333. else
  2334. X    MAP=""
  2335. fi
  2336. X
  2337. X# Display the proper field value.
  2338. X#
  2339. if test "$NAME" = "gas"
  2340. then
  2341. X    FIELD="-f 3"
  2342. elif test "$NAME" = "dist"
  2343. then
  2344. X    FIELD="-f 2"
  2345. else
  2346. X    FIELD="-f 1"
  2347. fi
  2348. X
  2349. X# Display the proper proportion for cells.
  2350. X# 
  2351. if test "$NAME" = "dist"
  2352. then
  2353. X    SIZE="-s 5,3"
  2354. else
  2355. X    SIZE="-s 3,3"
  2356. fi
  2357. X
  2358. X# Run the program(s).
  2359. X#
  2360. X$BIN/pe-scam -c $WD/bin/$NAME $DISPLAY $SIZE $FIELD $MAP < $WD/data/$NAME
  2361. END_OF_FILE
  2362. if test 2621 -ne `wc -c <'examples/show.sh'`; then
  2363.     echo shar: \"'examples/show.sh'\" unpacked with wrong size!
  2364. fi
  2365. # end of 'examples/show.sh'
  2366. fi
  2367. if test ! -d 'examples/src' ; then
  2368.     echo shar: Creating directory \"'examples/src'\"
  2369.     mkdir 'examples/src'
  2370. fi
  2371. if test -f 'examples/src/cparity' -a "${1}" != "-c" ; then 
  2372.   echo shar: Will not clobber existing file \"'examples/src/cparity'\"
  2373. else
  2374. echo shar: Extracting \"'examples/src/cparity'\" \(924 characters\)
  2375. sed "s/^X//" >'examples/src/cparity' <<'END_OF_FILE'
  2376. X#  cparity
  2377. X#  Copyright (C) 1992  J Dana Eckart
  2378. X#
  2379. X#  This program is free software; you can redistribute it and/or modify
  2380. X#  it under the terms of the GNU General Public License as published by
  2381. X#  the Free Software Foundation; either version 1, or (at your option)
  2382. X#  any later version.
  2383. X#
  2384. X#  This program is distributed in the hope that it will be useful,
  2385. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2386. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2387. X#  GNU General Public License for more details.
  2388. X#
  2389. X#  You should have received a copy of the GNU General Public License
  2390. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2391. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2392. X
  2393. X# A color version of the parity program.
  2394. X
  2395. X2 dimensions of 0..255
  2396. X
  2397. sum := [0, 1] + [1, 1] + [1, 0] + [-1, 1] + [-1, 0] + [-1, -1]
  2398. X    + [0, -1] + [1, -1]
  2399. X
  2400. cell := sum % 256
  2401. END_OF_FILE
  2402. if test 924 -ne `wc -c <'examples/src/cparity'`; then
  2403.     echo shar: \"'examples/src/cparity'\" unpacked with wrong size!
  2404. fi
  2405. # end of 'examples/src/cparity'
  2406. fi
  2407. if test -f 'examples/src/dist' -a "${1}" != "-c" ; then 
  2408.   echo shar: Will not clobber existing file \"'examples/src/dist'\"
  2409. else
  2410. echo shar: Extracting \"'examples/src/dist'\" \(2060 characters\)
  2411. sed "s/^X//" >'examples/src/dist' <<'END_OF_FILE'
  2412. X#  dist
  2413. X#  Copyright (C) 1992  J Dana Eckart
  2414. X#
  2415. X#  This program is free software; you can redistribute it and/or modify
  2416. X#  it under the terms of the GNU General Public License as published by
  2417. X#  the Free Software Foundation; either version 1, or (at your option)
  2418. X#  any later version.
  2419. X#
  2420. X#  This program is distributed in the hope that it will be useful,
  2421. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2422. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2423. X#  GNU General Public License for more details.
  2424. X#
  2425. X#  You should have received a copy of the GNU General Public License
  2426. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2427. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2428. X
  2429. X# Use a hexagonal neighborhood to compute the distance(s) from
  2430. X# established points (cells with non-zero values for the dist field).
  2431. X# The hexagonal neighborhood is composed of stagered blocks of two
  2432. X# cells stacked upon one another (imagine a hexagon which has been
  2433. X# pushed in at the sides to form a rectangle).  The which fields are
  2434. X# set according the the following scheme (with 1 being the top of a
  2435. X# hexagon and 0 the bottom).
  2436. X#
  2437. X#            0  1  0  1  0  1
  2438. X#            1  0  1  0  1  0
  2439. X#            0  1  0  1  0  1
  2440. X#            1  0  1  0  1  0
  2441. X#
  2442. X2 dimensions of 
  2443. X    which of 0..1
  2444. X    dist  of 0..255
  2445. end
  2446. X
  2447. X# Identification of the neighboring cells.
  2448. X#
  2449. if cell.which = 0 then
  2450. X    north := [0, 1]
  2451. X    ne    := [1, 0]
  2452. X    se    := [1, -1]
  2453. X    south := [0, -2]
  2454. X    sw    := [-1, -1]
  2455. X    nw    := [-1, 0]
  2456. else
  2457. X    north := [0, 2]
  2458. X    ne    := [1, 1]
  2459. X    se    := [1, 0]
  2460. X    south := [0, -1]
  2461. X    sw    := [-1, 0]
  2462. X    nw    := [-1, 1]
  2463. end
  2464. X
  2465. min_dist := 255
  2466. min_dist := north.dist when north.dist < min_dist & north.dist > 0
  2467. min_dist := ne.dist when ne.dist < min_dist & ne.dist > 0
  2468. min_dist := se.dist when se.dist < min_dist & se.dist > 0
  2469. min_dist := south.dist when south.dist < min_dist & south.dist > 0
  2470. min_dist := sw.dist when sw.dist < min_dist & sw.dist > 0
  2471. min_dist := nw.dist when nw.dist < min_dist & nw.dist > 0
  2472. X
  2473. cell.dist := min_dist+4 when cell.dist = 0 & min_dist < 255
  2474. END_OF_FILE
  2475. if test 2060 -ne `wc -c <'examples/src/dist'`; then
  2476.     echo shar: \"'examples/src/dist'\" unpacked with wrong size!
  2477. fi
  2478. # end of 'examples/src/dist'
  2479. fi
  2480. if test -f 'examples/src/gas' -a "${1}" != "-c" ; then 
  2481.   echo shar: Will not clobber existing file \"'examples/src/gas'\"
  2482. else
  2483. echo shar: Extracting \"'examples/src/gas'\" \(2712 characters\)
  2484. sed "s/^X//" >'examples/src/gas' <<'END_OF_FILE'
  2485. X#  gas
  2486. X#  Copyright (C) 1992  J Dana Eckart
  2487. X#
  2488. X#  This program is free software; you can redistribute it and/or modify
  2489. X#  it under the terms of the GNU General Public License as published by
  2490. X#  the Free Software Foundation; either version 1, or (at your option)
  2491. X#  any later version.
  2492. X#
  2493. X#  This program is distributed in the hope that it will be useful,
  2494. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2495. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2496. X#  GNU General Public License for more details.
  2497. X#
  2498. X#  You should have received a copy of the GNU General Public License
  2499. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2500. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2501. X
  2502. X# Simulate gas diffusion by `randomly' rotating the cell values in a
  2503. X# Margolus-neighborhood either clockwise or counter-clockwise.  The 
  2504. X# groupings are alternations of the two overlapping square neighborhoods:
  2505. X#
  2506. X#            0  1
  2507. X#            2  3  2
  2508. X#               1  0
  2509. X#
  2510. X2 dimensions of 
  2511. X    which of 0..3
  2512. X    rand  of 0..1
  2513. X    gas   of 0..1
  2514. end
  2515. X
  2516. X# Calculate the sum of the random fields in the neighborhood.
  2517. X#
  2518. random := cell.rand + [1, 0].rand + [1, -1].rand + [0, -1].rand
  2519. X        when (cell.which=0 & time%2=1) | (cell.which=3 & time%2=0)
  2520. X
  2521. X       := [-1, 0].rand + cell.rand + [0, -1].rand + [-1, -1].rand
  2522. X        when (cell.which=1 & time%2=1) | (cell.which=2 & time%2=0)
  2523. X
  2524. X       := [-1, 1].rand + [0, 1].rand + cell.rand + [-1, 0].rand
  2525. X        when (cell.which=3 & time%2=1) | (cell.which=0 & time%2=0)
  2526. X
  2527. X       := [0, 1].rand + [1, 1].rand + [1, 0].rand + cell.rand
  2528. X        otherwise
  2529. X
  2530. X# Alternate between the overlapping neighborhoods
  2531. X#
  2532. if time%2 = 1 then
  2533. X    if random%2 = 1 then
  2534. X        # Clockwise rotation
  2535. X        cell.gas := [0, -1].gas when cell.which = 0
  2536. X                 := [-1, 0].gas when cell.which = 1
  2537. X                 := [0, 1].gas when cell.which = 3
  2538. X                 := [1, 0].gas when cell.which = 2
  2539. X    else
  2540. X        # Counter-clockwise rotation
  2541. X        cell.gas := [1, 0].gas when cell.which = 0
  2542. X                 := [0, -1].gas when cell.which = 1
  2543. X                 := [-1, 0].gas when cell.which = 3
  2544. X                 := [0, 1].gas when cell.which = 2
  2545. X    end
  2546. else
  2547. X    if random%2 = 1 then
  2548. X        # Clockwise rotation
  2549. X        cell.gas := [0, -1].gas when cell.which = 3
  2550. X                 := [-1, 0].gas when cell.which = 2
  2551. X                 := [0, 1].gas when cell.which = 0
  2552. X                 := [1, 0].gas when cell.which = 1
  2553. X    else
  2554. X        # Counter-clockwise rotation
  2555. X        cell.gas := [1, 0].gas when cell.which = 3
  2556. X                 := [0, -1].gas when cell.which = 2
  2557. X                 := [-1, 0].gas when cell.which = 0
  2558. X                 := [0, 1].gas when cell.which = 1
  2559. X    end
  2560. end
  2561. X
  2562. X# Stir the random values, so that they keep changing.
  2563. X#
  2564. cell.rand := ([1, 0].rand + [0, 1].rand + [-1, 0].rand + [0, -1].rand
  2565. X        + cell.rand)%2
  2566. END_OF_FILE
  2567. if test 2712 -ne `wc -c <'examples/src/gas'`; then
  2568.     echo shar: \"'examples/src/gas'\" unpacked with wrong size!
  2569. fi
  2570. # end of 'examples/src/gas'
  2571. fi
  2572. if test -f 'examples/src/life' -a "${1}" != "-c" ; then 
  2573.   echo shar: Will not clobber existing file \"'examples/src/life'\"
  2574. else
  2575. echo shar: Extracting \"'examples/src/life'\" \(982 characters\)
  2576. sed "s/^X//" >'examples/src/life' <<'END_OF_FILE'
  2577. X#  life
  2578. X#  Copyright (C) 1992  J Dana Eckart
  2579. X#
  2580. X#  This program is free software; you can redistribute it and/or modify
  2581. X#  it under the terms of the GNU General Public License as published by
  2582. X#  the Free Software Foundation; either version 1, or (at your option)
  2583. X#  any later version.
  2584. X#
  2585. X#  This program is distributed in the hope that it will be useful,
  2586. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2587. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2588. X#  GNU General Public License for more details.
  2589. X#
  2590. X#  You should have received a copy of the GNU General Public License
  2591. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2592. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2593. X
  2594. X# This program implements a 2 dimensional game of life.
  2595. X
  2596. X2 dimensions of 0..1
  2597. X
  2598. sum := [0, 1] + [1, 1] + [1, 0] + [-1, 1] + [-1, 0] + [-1, -1]
  2599. X    + [0, -1] + [1, -1]
  2600. X
  2601. cell := 1 when (sum = 2 & cell = 1) | sum = 3
  2602. X     := 0 otherwise
  2603. END_OF_FILE
  2604. if test 982 -ne `wc -c <'examples/src/life'`; then
  2605.     echo shar: \"'examples/src/life'\" unpacked with wrong size!
  2606. fi
  2607. # end of 'examples/src/life'
  2608. fi
  2609. if test -f 'examples/src/parity' -a "${1}" != "-c" ; then 
  2610.   echo shar: Will not clobber existing file \"'examples/src/parity'\"
  2611. else
  2612. echo shar: Extracting \"'examples/src/parity'\" \(904 characters\)
  2613. sed "s/^X//" >'examples/src/parity' <<'END_OF_FILE'
  2614. X#  parity
  2615. X#  Copyright (C) 1992  J Dana Eckart
  2616. X#
  2617. X#  This program is free software; you can redistribute it and/or modify
  2618. X#  it under the terms of the GNU General Public License as published by
  2619. X#  the Free Software Foundation; either version 1, or (at your option)
  2620. X#  any later version.
  2621. X#
  2622. X#  This program is distributed in the hope that it will be useful,
  2623. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2624. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2625. X#  GNU General Public License for more details.
  2626. X#
  2627. X#  You should have received a copy of the GNU General Public License
  2628. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2629. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2630. X
  2631. X# A simple parity program
  2632. X
  2633. X2 dimensions of 0..1
  2634. X
  2635. sum := [0, 1] + [1, 1] + [1, 0] + [-1, 1] + [-1, 0] + [-1, -1]
  2636. X    + [0, -1] + [1, -1]
  2637. X
  2638. cell := sum % 2
  2639. END_OF_FILE
  2640. if test 904 -ne `wc -c <'examples/src/parity'`; then
  2641.     echo shar: \"'examples/src/parity'\" unpacked with wrong size!
  2642. fi
  2643. # end of 'examples/src/parity'
  2644. fi
  2645. if test -f 'examples/src/srdp' -a "${1}" != "-c" ; then 
  2646.   echo shar: Will not clobber existing file \"'examples/src/srdp'\"
  2647. else
  2648. echo shar: Extracting \"'examples/src/srdp'\" \(1967 characters\)
  2649. sed "s/^X//" >'examples/src/srdp' <<'END_OF_FILE'
  2650. X#  srdp
  2651. X#  Copyright (C) 1992  J Dana Eckart
  2652. X#
  2653. X#  This program is free software; you can redistribute it and/or modify
  2654. X#  it under the terms of the GNU General Public License as published by
  2655. X#  the Free Software Foundation; either version 1, or (at your option)
  2656. X#  any later version.
  2657. X#
  2658. X#  This program is distributed in the hope that it will be useful,
  2659. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2660. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2661. X#  GNU General Public License for more details.
  2662. X#
  2663. X#  You should have received a copy of the GNU General Public License
  2664. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2665. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2666. X
  2667. X# scissors (0), rock (1), dynamite (2), paper (3)
  2668. X
  2669. X2 dimensions of 0..2
  2670. X
  2671. X# Get the Moore neighborhood
  2672. X#
  2673. north := [0, 1]
  2674. ne := [1, 1]
  2675. east := [1, 0]
  2676. se := [1, -1]
  2677. south := [0, -1]
  2678. sw := [-1, -1]
  2679. west := [-1, 0]
  2680. nw := [-1, 1]
  2681. X
  2682. threshold := 3
  2683. X
  2684. scissors := 0
  2685. rock     := 1
  2686. dynamite := 2
  2687. paper    := 3
  2688. X
  2689. scissors_sum := (north = scissors) + (ne = scissors) + (east = scissors) + 
  2690. X        (se = scissors) + (south = scissors) + (sw = scissors) + 
  2691. X        (west = scissors) + (nw = scissors)
  2692. X
  2693. rock_sum     := (north = rock) + (ne = rock) + (east = rock) + (se = rock) + 
  2694. X        (south = rock) + (sw = rock) + (west = rock) + (nw = rock)
  2695. X
  2696. dynamite_sum := (north = dynamite) + (ne = dynamite) + (east = dynamite) + 
  2697. X        (se = dynamite) + (south = dynamite) + (sw = dynamite) + 
  2698. X        (west = dynamite) + (nw = dynamite)
  2699. X
  2700. paper_sum    := (north = paper) + (ne = paper) + (east = paper) + (se = paper) + 
  2701. X        (south = paper) + (sw = paper) + (west = paper) + (nw = paper)
  2702. X
  2703. X
  2704. X# Find out who lives and who dies.
  2705. cell := scissors when scissors_sum >= threshold & cell = paper
  2706. X     := rock when rock_sum >= threshold & cell = scissors
  2707. X     := dynamite when dynamite_sum >= threshold & cell = rock
  2708. X     := paper when paper_sum >= threshold & cell = dynamite
  2709. END_OF_FILE
  2710. if test 1967 -ne `wc -c <'examples/src/srdp'`; then
  2711.     echo shar: \"'examples/src/srdp'\" unpacked with wrong size!
  2712. fi
  2713. # end of 'examples/src/srdp'
  2714. fi
  2715. if test -f 'examples/srdp_data_gen.c' -a "${1}" != "-c" ; then 
  2716.   echo shar: Will not clobber existing file \"'examples/srdp_data_gen.c'\"
  2717. else
  2718. echo shar: Extracting \"'examples/srdp_data_gen.c'\" \(1166 characters\)
  2719. sed "s/^X//" >'examples/srdp_data_gen.c' <<'END_OF_FILE'
  2720. X/* srdp_data_gen.c
  2721. X   Copyright (C) 1992  J Dana Eckart
  2722. X
  2723. X   This program is free software; you can redistribute it and/or modify
  2724. X   it under the terms of the GNU General Public License as published by
  2725. X   the Free Software Foundation; either version 1, or (at your option)
  2726. X   any later version.
  2727. X   This program is distributed in the hope that it will be useful,
  2728. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  2729. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2730. X   GNU General Public License for more details.
  2731. X   You should have received a copy of the GNU General Public License
  2732. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2733. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2734. X*/
  2735. X
  2736. X/* Generate the input data used by srdp.  A single command line argument
  2737. X   indicates the size of each of two dimensions of the cell universe.
  2738. X*/
  2739. X
  2740. X#include <stdio.h>
  2741. X
  2742. int main(argc, argv) int argc; char *argv[]; {
  2743. X    int max_size = atoi(argv[1]);
  2744. X    int x, y;
  2745. X
  2746. X    printf("0\n");
  2747. X
  2748. X    for (x = 0; x < max_size; x++)
  2749. X        for (y = 0; y < max_size; y++)
  2750. X            printf("[%d, %d] = %d\n", x, y, random()%4);
  2751. X
  2752. X    return 0;
  2753. X}
  2754. END_OF_FILE
  2755. if test 1166 -ne `wc -c <'examples/srdp_data_gen.c'`; then
  2756.     echo shar: \"'examples/srdp_data_gen.c'\" unpacked with wrong size!
  2757. fi
  2758. # end of 'examples/srdp_data_gen.c'
  2759. fi
  2760. if test ! -d 'viewer' ; then
  2761.     echo shar: Creating directory \"'viewer'\"
  2762.     mkdir 'viewer'
  2763. fi
  2764. if test -f 'viewer/Makefile' -a "${1}" != "-c" ; then 
  2765.   echo shar: Will not clobber existing file \"'viewer/Makefile'\"
  2766. else
  2767. echo shar: Extracting \"'viewer/Makefile'\" \(2650 characters\)
  2768. sed "s/^X//" >'viewer/Makefile' <<'END_OF_FILE'
  2769. X#  Makefile
  2770. X#  Copyright (C) 1992  J Dana Eckart
  2771. X#
  2772. X#  This program is free software; you can redistribute it and/or modify
  2773. X#  it under the terms of the GNU General Public License as published by
  2774. X#  the Free Software Foundation; either version 1, or (at your option)
  2775. X#  any later version.
  2776. X#
  2777. X#  This program is distributed in the hope that it will be useful,
  2778. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2779. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2780. X#  GNU General Public License for more details.
  2781. X#
  2782. X#  You should have received a copy of the GNU General Public License
  2783. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2784. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2785. X
  2786. X# Installation directories.
  2787. X#
  2788. BIN=/usr/local/bin
  2789. LIB=/usr/local/lib/cellular
  2790. MAN=/usr/man/manl
  2791. MAN_EXT=l
  2792. X
  2793. X# If you want to have the Cellang compiler configured to compile the viewer 
  2794. X# into the executables then assign COMBINED the value "1", otherwise assign 
  2795. X# a "0".  This makes for faster display of many automata, though it does need
  2796. X# X11 to run them.
  2797. X#
  2798. COMBINED=0    # 0 or 1
  2799. X
  2800. X# Choose a C compiler and options.
  2801. X#
  2802. CC = gcc
  2803. CFLAGS = -O -ansi -pedantic 
  2804. CDEFINES= -DLIB_DIR=\"${LIB}\"
  2805. CLIB = -lm -lcurses -ltermcap -lX11
  2806. X
  2807. X# Rules (default.mk on SunOS uses a -target option not supported by GNU C)
  2808. X#
  2809. COMPILE.c=$(CC) $(CFLAGS) $(CDEFINES) $(CPPFLAGS) -c
  2810. X
  2811. X# Dependencies
  2812. X
  2813. all: cellview cellview.${MAN_EXT}
  2814. X
  2815. install: all
  2816. X    - mkdir -p ${BIN}
  2817. X    - mkdir -p ${LIB}
  2818. X    - mkdir -p ${MAN}
  2819. X
  2820. X    install cellview ${BIN}/cellview
  2821. X    install -m 644 color-map ${LIB}/color-map
  2822. X    install -m 644 bw-map ${LIB}/bw-map
  2823. X    install -m 644 curses-map ${LIB}/curses-map
  2824. X    install -m 644 cellview.${MAN_EXT} ${MAN}/cellview.${MAN_EXT}
  2825. X
  2826. X    make CC='$(CC)' CFLAGS='$(CFLAGS)' \
  2827. X        CDEFINES='${CDEFINES} -DCOMBINED=${COMBINED}' \
  2828. X        MAN_EXT='${MAN_EXT}' LIB='${LIB}' ${COMBINED}
  2829. X
  2830. deinstall:
  2831. X    /bin/rm -f ${BIN}/cellview
  2832. X    /bin/rm -f ${MAN}/cellview.${MAN_EXT}
  2833. X    /bin/rm -f ${LIB}/color-map
  2834. X    /bin/rm -f ${LIB}/bw-map
  2835. X    /bin/rm -f ${LIB}/curses-map
  2836. X    /bin/rm -f ${LIB}/*.o
  2837. X
  2838. clean:
  2839. X    /bin/rm -f *.o core cellview cellview.${MAN_EXT}
  2840. X
  2841. realclean: clean
  2842. X
  2843. cellview: curses.o x11.o view.o
  2844. X    ${CC} ${CFLAGS} -o cellview *.o ${CLIB}
  2845. X
  2846. cellview.${MAN_EXT}: cellview.man
  2847. X    sed -e 's?LIB_DIR?$(LIB)?' \
  2848. X        -e 's?MAN_EXT?$(MAN_EXT)?g' cellview.man > cellview.${MAN_EXT}
  2849. X
  2850. view.o: view.c view.h curses.h x11.h boolean.h
  2851. X
  2852. curses.o: curses.c curses.h view.h boolean.h
  2853. X
  2854. x11.o: x11.c x11.h view.h boolean.h
  2855. X
  2856. object_files: curses.o x11.o view.o
  2857. X
  2858. X1:
  2859. X    make clean
  2860. X    make CC='$(CC)' CFLAGS='$(CFLAGS)' CDEFINES='$(CDEFINES)' object_files
  2861. X    install *.o ${LIB}
  2862. X    make clean
  2863. X
  2864. X0:
  2865. END_OF_FILE
  2866. if test 2650 -ne `wc -c <'viewer/Makefile'`; then
  2867.     echo shar: \"'viewer/Makefile'\" unpacked with wrong size!
  2868. fi
  2869. # end of 'viewer/Makefile'
  2870. fi
  2871. if test -f 'viewer/README' -a "${1}" != "-c" ; then 
  2872.   echo shar: Will not clobber existing file \"'viewer/README'\"
  2873. else
  2874. echo shar: Extracting \"'viewer/README'\" \(1379 characters\)
  2875. sed "s/^X//" >'viewer/README' <<'END_OF_FILE'
  2876. X#  README
  2877. X#  Copyright (C) 1992  J Dana Eckart
  2878. X#
  2879. X#  This program is free software; you can redistribute it and/or modify
  2880. X#  it under the terms of the GNU General Public License as published by
  2881. X#  the Free Software Foundation; either version 1, or (at your option)
  2882. X#  any later version.
  2883. X#
  2884. X#  This program is distributed in the hope that it will be useful,
  2885. X#  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2886. X#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2887. X#  GNU General Public License for more details.
  2888. X#
  2889. X#  You should have received a copy of the GNU General Public License
  2890. X#  along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2891. X#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2892. X
  2893. To install the cellview cellular automata viewer, edit the Makefile to 
  2894. reflect the proper values of:
  2895. X
  2896. X     BIN     - installation directory for executables
  2897. X     LIB     - installation directory for supporting software
  2898. X     MAN     - installation directory for manual pages
  2899. X     MAX_EXT - manual page extension to use for installation
  2900. X
  2901. Do "make install" to build and install the viewer.  In addition, the 
  2902. Makefile also supports the targets:
  2903. X
  2904. X    all: compile, but not install, the software
  2905. X  deinstall: remove an installation
  2906. X      clean: remove all but the distributed files within this directory
  2907. X  realclean: (same as clean)
  2908. END_OF_FILE
  2909. if test 1379 -ne `wc -c <'viewer/README'`; then
  2910.     echo shar: \"'viewer/README'\" unpacked with wrong size!
  2911. fi
  2912. # end of 'viewer/README'
  2913. fi
  2914. if test -f 'viewer/boolean.h' -a "${1}" != "-c" ; then 
  2915.   echo shar: Will not clobber existing file \"'viewer/boolean.h'\"
  2916. else
  2917. echo shar: Extracting \"'viewer/boolean.h'\" \(817 characters\)
  2918. sed "s/^X//" >'viewer/boolean.h' <<'END_OF_FILE'
  2919. X/* boolean.h
  2920. X   Copyright (C) 1992  J Dana Eckart
  2921. X  
  2922. X   This program is free software; you can redistribute it and/or modify
  2923. X   it under the terms of the GNU General Public License as published by
  2924. X   the Free Software Foundation; either version 1, or (at your option)
  2925. X   any later version.
  2926. X  
  2927. X   This program is distributed in the hope that it will be useful,
  2928. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  2929. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2930. X   GNU General Public License for more details.
  2931. X  
  2932. X   You should have received a copy of the GNU General Public License
  2933. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  2934. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2935. X*/
  2936. X
  2937. X#define boolean int
  2938. X
  2939. X#define true     1
  2940. X#define false     0
  2941. END_OF_FILE
  2942. if test 817 -ne `wc -c <'viewer/boolean.h'`; then
  2943.     echo shar: \"'viewer/boolean.h'\" unpacked with wrong size!
  2944. fi
  2945. # end of 'viewer/boolean.h'
  2946. fi
  2947. if test -f 'viewer/bw-map' -a "${1}" != "-c" ; then 
  2948.   echo shar: Will not clobber existing file \"'viewer/bw-map'\"
  2949. else
  2950. echo shar: Extracting \"'viewer/bw-map'\" \(8 characters\)
  2951. sed "s/^X//" >'viewer/bw-map' <<'END_OF_FILE'
  2952. X0    1
  2953. X1    0
  2954. END_OF_FILE
  2955. if test 8 -ne `wc -c <'viewer/bw-map'`; then
  2956.     echo shar: \"'viewer/bw-map'\" unpacked with wrong size!
  2957. fi
  2958. # end of 'viewer/bw-map'
  2959. fi
  2960. if test -f 'viewer/color-map' -a "${1}" != "-c" ; then 
  2961.   echo shar: Will not clobber existing file \"'viewer/color-map'\"
  2962. else
  2963. echo shar: Extracting \"'viewer/color-map'\" \(5522 characters\)
  2964. sed "s/^X//" >'viewer/color-map' <<'END_OF_FILE'
  2965. X0        0     0     0
  2966. X1    65535  1542     0
  2967. X2    65535  3084     0
  2968. X3    65535  4626     0
  2969. X4    65535  6168     0
  2970. X5    65535  7710     0
  2971. X6    65535  9252     0
  2972. X7    65535 10794     0
  2973. X8    65535 12336     0
  2974. X9    65535 13878     0
  2975. X10    65535 15420     0
  2976. X11    65535 16962     0
  2977. X12    65535 18504     0
  2978. X13    65535 20046     0
  2979. X14    65535 21588     0
  2980. X15    65535 23130     0
  2981. X16    65535 24672     0
  2982. X17    65535 26214     0
  2983. X18    65535 27756     0
  2984. X19    65535 29298     0
  2985. X20    65535 30840     0
  2986. X21    65535 32382     0
  2987. X22    65535 33924     0
  2988. X23    65535 35466     0
  2989. X24    65535 37008     0
  2990. X25    65535 38550     0
  2991. X26    65535 40092     0
  2992. X27    65535 41634     0
  2993. X28    65535 43176     0
  2994. X29    65535 44718     0
  2995. X30    65535 46260     0
  2996. X31    65535 47802     0
  2997. X32    65535 49344     0
  2998. X33    65535 50886     0
  2999. X34    65535 52428     0
  3000. X35    65535 53970     0
  3001. X36    65535 55512     0
  3002. X37    65535 57054     0
  3003. X38    65535 58596     0
  3004. X39    65535 60138     0
  3005. X40    65535 61680     0
  3006. X41    65535 63222     0
  3007. X42    65535 64764     0
  3008. X43    65535 65535     0
  3009. X44    65535 65535     0
  3010. X45    65535 65535     0
  3011. X46    65535 65535     0
  3012. X47    65535 65535     0
  3013. X48    65535 65535     0
  3014. X49    65535 65535     0
  3015. X50    65535 65535     0
  3016. X51    65535 65535     0
  3017. X52    65535 65535     0
  3018. X53    65535 65535     0
  3019. X54    65535 65535     0
  3020. X55    65535 65535     0
  3021. X56    65535 65535     0
  3022. X57    65535 65535     0
  3023. X58    65535 65535     0
  3024. X59    65535 65535     0
  3025. X60    65535 65535     0
  3026. X61    63993 65535     0
  3027. X62    62451 65535     0
  3028. X63    60909 65535     0
  3029. X64    59367 65535     0
  3030. X65    57825 65535     0
  3031. X66    56283 65535     0
  3032. X67    54741 65535     0
  3033. X68    53199 65535     0
  3034. X69    51657 65535     0
  3035. X70    50115 65535     0
  3036. X71    48573 65535     0
  3037. X72    47031 65535     0
  3038. X73    45489 65535     0
  3039. X74    43947 65535     0
  3040. X75    42405 65535     0
  3041. X76    40863 65535     0
  3042. X77    39321 65535     0
  3043. X78    37779 65535     0
  3044. X79    36237 65535     0
  3045. X80    34695 65535     0
  3046. X81    33153 65535     0
  3047. X82    31611 65535     0
  3048. X83    30069 65535     0
  3049. X84    28527 65535     0
  3050. X85    26985 65535     0
  3051. X86    25443 65535     0
  3052. X87    23901 65535     0
  3053. X88    22359 65535     0
  3054. X89    20817 65535     0
  3055. X90    19275 65535     0
  3056. X91    17733 65535     0
  3057. X92    16191 65535     0
  3058. X93    14649 65535     0
  3059. X94    13107 65535     0
  3060. X95    11565 65535     0
  3061. X96    10023 65535     0
  3062. X97     8481 65535     0
  3063. X98     6939 65535     0
  3064. X99     5397 65535     0
  3065. X100     3855 65535     0
  3066. X101     2313 65535     0
  3067. X102      771 65535     0
  3068. X103        0 65535     0
  3069. X104        0 65535     0
  3070. X105        0 65535     0
  3071. X106        0 65535  1542
  3072. X107        0 65535  3084
  3073. X108        0 65535  4626
  3074. X109        0 65535  6168
  3075. X110        0 65535  7710
  3076. X111        0 65535  9252
  3077. X112        0 65535 10794
  3078. X113        0 65535 12336
  3079. X114        0 65535 13878
  3080. X115        0 65535 15420
  3081. X116        0 65535 16962
  3082. X117        0 65535 18504
  3083. X118        0 65535 20046
  3084. X119        0 65535 21588
  3085. X120        0 65535 23130
  3086. X121        0 65535 24672
  3087. X122        0 65535 26214
  3088. X123        0 65535 27756
  3089. X124        0 65535 29298
  3090. X125        0 65535 30840
  3091. X126        0 65535 32382
  3092. X127        0 65535 33924
  3093. X128        0 65535 35466
  3094. X129        0 65535 37008
  3095. X130        0 65535 38550
  3096. X131        0 65535 40092
  3097. X132        0 65535 41634
  3098. X133        0 65535 43176
  3099. X134        0 65535 44718
  3100. X135        0 65535 46260
  3101. X136        0 65535 47802
  3102. X137        0 65535 49344
  3103. X138        0 65535 50886
  3104. X139        0 65535 52428
  3105. X140        0 65535 53970
  3106. X141        0 65535 55512
  3107. X142        0 65535 57054
  3108. X143        0 65535 58596
  3109. X144        0 65535 60138
  3110. X145        0 65535 61680
  3111. X146        0 65535 63222
  3112. X147        0 65535 64764
  3113. X148        0 65535 65535
  3114. X149        0 65535 65535
  3115. X150        0 65535 65535
  3116. X151        0 65535 65535
  3117. X152        0 65535 65535
  3118. X153        0 65535 65535
  3119. X154        0 65535 65535
  3120. X155        0 65535 65535
  3121. X156        0 65535 65535
  3122. X157        0 65535 65535
  3123. X158        0 65535 65535
  3124. X159        0 65535 65535
  3125. X160        0 65535 65535
  3126. X161        0 65535 65535
  3127. X162        0 65535 65535
  3128. X163        0 65535 65535
  3129. X164        0 65535 65535
  3130. X165        0 65535 65535
  3131. X166        0 63993 65535
  3132. X167        0 62451 65535
  3133. X168        0 60909 65535
  3134. X169        0 59367 65535
  3135. X170        0 57825 65535
  3136. X171        0 56283 65535
  3137. X172        0 54741 65535
  3138. X173        0 53199 65535
  3139. X174        0 51657 65535
  3140. X175        0 50115 65535
  3141. X176        0 48573 65535
  3142. X177        0 47031 65535
  3143. X178        0 45489 65535
  3144. X179        0 43947 65535
  3145. X180        0 42405 65535
  3146. X181        0 40863 65535
  3147. X182        0 39321 65535
  3148. X183        0 37779 65535
  3149. X184        0 36237 65535
  3150. X185        0 34695 65535
  3151. X186        0 33153 65535
  3152. X187        0 31611 65535
  3153. X188        0 30069 65535
  3154. X189        0 28527 65535
  3155. X190        0 26985 65535
  3156. X191        0 25443 65535
  3157. X192        0 23901 65535
  3158. X193        0 22359 65535
  3159. X194        0 20817 65535
  3160. X195        0 19275 65535
  3161. X196        0 17733 65535
  3162. X197        0 16191 65535
  3163. X198        0 14649 65535
  3164. X199        0 13107 65535
  3165. X200        0 11565 65535
  3166. X201        0 10023 65535
  3167. X202        0  8481 65535
  3168. X203        0  6939 65535
  3169. X204        0  5397 65535
  3170. X205        0  3855 65535
  3171. X206        0  2313 65535
  3172. X207        0   771 65535
  3173. X208        0     0 65535
  3174. X209        0     0 65535
  3175. X210        0     0 65535
  3176. X211     1542     0 65535
  3177. X212     3084     0 65535
  3178. X213     4626     0 65535
  3179. X214     6168     0 65535
  3180. X215     7710     0 65535
  3181. X216     9252     0 65535
  3182. X217    10794     0 65535
  3183. X218    12336     0 65535
  3184. X219    13878     0 65535
  3185. X220    15420     0 65535
  3186. X221    16962     0 65535
  3187. X222    18504     0 65535
  3188. X223    20046     0 65535
  3189. X224    21588     0 65535
  3190. X225    23130     0 65535
  3191. X226    24672     0 65535
  3192. X227    26214     0 65535
  3193. X228    27756     0 65535
  3194. X229    29298     0 65535
  3195. X230    30840     0 65535
  3196. X231    32382     0 65535
  3197. X232    33924     0 65535
  3198. X233    35466     0 65535
  3199. X234    37008     0 65535
  3200. X235    38550     0 65535
  3201. X236    40092     0 65535
  3202. X237    41634     0 65535
  3203. X238    43176     0 65535
  3204. X239    44718     0 65535
  3205. X240    46260     0 65535
  3206. X241    47802     0 65535
  3207. X242    49344     0 65535
  3208. X243    50886     0 65535
  3209. X244    52428     0 65535
  3210. X245    53970     0 65535
  3211. X246    55512     0 65535
  3212. X247    57054     0 65535
  3213. X248    58596     0 65535
  3214. X249    60138     0 65535
  3215. X250    61680     0 65535
  3216. X251    63222     0 65535
  3217. X252    64764     0 65535
  3218. X253    65535     0 65535
  3219. X254    65535     0 65535
  3220. X255    65535 65535 65535
  3221. END_OF_FILE
  3222. if test 5522 -ne `wc -c <'viewer/color-map'`; then
  3223.     echo shar: \"'viewer/color-map'\" unpacked with wrong size!
  3224. fi
  3225. # end of 'viewer/color-map'
  3226. fi
  3227. if test -f 'viewer/curses-map' -a "${1}" != "-c" ; then 
  3228.   echo shar: Will not clobber existing file \"'viewer/curses-map'\"
  3229. else
  3230. echo shar: Extracting \"'viewer/curses-map'\" \(1938 characters\)
  3231. sed "s/^X//" >'viewer/curses-map' <<'END_OF_FILE'
  3232. X0    '-'
  3233. X1    '+'
  3234. X2    'o'
  3235. X3    'x'
  3236. X4    '#'
  3237. X5    '*'
  3238. X6    '+'
  3239. X7    'o'
  3240. X8    'x'
  3241. X9    '#'
  3242. X10    '*'
  3243. X11    '+'
  3244. X12    'o'
  3245. X13    'x'
  3246. X14    '#'
  3247. X15    '*'
  3248. X16    '+'
  3249. X17    'o'
  3250. X18    'x'
  3251. X19    '#'
  3252. X20    '*'
  3253. X21    '+'
  3254. X22    'o'
  3255. X23    'x'
  3256. X24    '#'
  3257. X25    '*'
  3258. X26    '+'
  3259. X27    'o'
  3260. X28    'x'
  3261. X29    '#'
  3262. X30    '*'
  3263. X31    '+'
  3264. X32    'o'
  3265. X33    'x'
  3266. X34    '#'
  3267. X35    '*'
  3268. X36    '+'
  3269. X37    'o'
  3270. X38    'x'
  3271. X39    '#'
  3272. X40    '*'
  3273. X41    '+'
  3274. X42    'o'
  3275. X43    'x'
  3276. X44    '#'
  3277. X45    '*'
  3278. X46    '+'
  3279. X47    'o'
  3280. X48    'x'
  3281. X49    '#'
  3282. X50    '*'
  3283. X51    '+'
  3284. X52    'o'
  3285. X53    'x'
  3286. X54    '#'
  3287. X55    '*'
  3288. X56    '+'
  3289. X57    'o'
  3290. X58    'x'
  3291. X59    '#'
  3292. X60    '*'
  3293. X61    '+'
  3294. X62    'o'
  3295. X63    'x'
  3296. X64    '#'
  3297. X65    '*'
  3298. X66    '+'
  3299. X67    'o'
  3300. X68    'x'
  3301. X69    '#'
  3302. X70    '*'
  3303. X71    '+'
  3304. X72    'o'
  3305. X73    'x'
  3306. X74    '#'
  3307. X75    '*'
  3308. X76    '+'
  3309. X77    'o'
  3310. X78    'x'
  3311. X79    '#'
  3312. X80    '*'
  3313. X81    '+'
  3314. X82    'o'
  3315. X83    'x'
  3316. X84    '#'
  3317. X85    '*'
  3318. X86    '+'
  3319. X87    'o'
  3320. X88    'x'
  3321. X89    '#'
  3322. X90    '*'
  3323. X91    '+'
  3324. X92    'o'
  3325. X93    'x'
  3326. X94    '#'
  3327. X95    '*'
  3328. X96    '+'
  3329. X97    'o'
  3330. X98    'x'
  3331. X99    '#'
  3332. X100    '*'
  3333. X101    '+'
  3334. X102    'o'
  3335. X103    'x'
  3336. X104    '#'
  3337. X105    '*'
  3338. X106    '+'
  3339. X107    'o'
  3340. X108    'x'
  3341. X109    '#'
  3342. X110    '*'
  3343. X111    '+'
  3344. X112    'o'
  3345. X113    'x'
  3346. X114    '#'
  3347. X115    '*'
  3348. X116    '+'
  3349. X117    'o'
  3350. X118    'x'
  3351. X119    '#'
  3352. X120    '*'
  3353. X121    '+'
  3354. X122    'o'
  3355. X123    'x'
  3356. X124    '#'
  3357. X125    '*'
  3358. X126    '+'
  3359. X127    'o'
  3360. X128    'x'
  3361. X129    '#'
  3362. X130    '*'
  3363. X131    '+'
  3364. X132    'o'
  3365. X133    'x'
  3366. X134    '#'
  3367. X135    '*'
  3368. X136    '+'
  3369. X137    'o'
  3370. X138    'x'
  3371. X139    '#'
  3372. X140    '*'
  3373. X141    '+'
  3374. X142    'o'
  3375. X143    'x'
  3376. X144    '#'
  3377. X145    '*'
  3378. X146    '+'
  3379. X147    'o'
  3380. X148    'x'
  3381. X149    '#'
  3382. X150    '*'
  3383. X151    '+'
  3384. X152    'o'
  3385. X153    'x'
  3386. X154    '#'
  3387. X155    '*'
  3388. X156    '+'
  3389. X157    'o'
  3390. X158    'x'
  3391. X159    '#'
  3392. X160    '*'
  3393. X161    '+'
  3394. X162    'o'
  3395. X163    'x'
  3396. X164    '#'
  3397. X165    '*'
  3398. X166    '+'
  3399. X167    'o'
  3400. X168    'x'
  3401. X169    '#'
  3402. X170    '*'
  3403. X171    '+'
  3404. X172    'o'
  3405. X173    'x'
  3406. X174    '#'
  3407. X175    '*'
  3408. X176    '+'
  3409. X177    'o'
  3410. X178    'x'
  3411. X179    '#'
  3412. X180    '*'
  3413. X181    '+'
  3414. X182    'o'
  3415. X183    'x'
  3416. X184    '#'
  3417. X185    '*'
  3418. X186    '+'
  3419. X187    'o'
  3420. X188    'x'
  3421. X189    '#'
  3422. X190    '*'
  3423. X191    '+'
  3424. X192    'o'
  3425. X193    'x'
  3426. X194    '#'
  3427. X195    '*'
  3428. X196    '+'
  3429. X197    'o'
  3430. X198    'x'
  3431. X199    '#'
  3432. X200    '*'
  3433. X201    '+'
  3434. X202    'o'
  3435. X203    'x'
  3436. X204    '#'
  3437. X205    '*'
  3438. X206    '+'
  3439. X207    'o'
  3440. X208    'x'
  3441. X209    '#'
  3442. X210    '*'
  3443. X211    '+'
  3444. X212    'o'
  3445. X213    'x'
  3446. X214    '#'
  3447. X215    '*'
  3448. X216    '+'
  3449. X217    'o'
  3450. X218    'x'
  3451. X219    '#'
  3452. X220    '*'
  3453. X221    '+'
  3454. X222    'o'
  3455. X223    'x'
  3456. X224    '#'
  3457. X225    '*'
  3458. X226    '+'
  3459. X227    'o'
  3460. X228    'x'
  3461. X229    '#'
  3462. X230    '*'
  3463. X231    '+'
  3464. X232    'o'
  3465. X233    'x'
  3466. X234    '#'
  3467. X235    '*'
  3468. X236    '+'
  3469. X237    'o'
  3470. X238    'x'
  3471. X239    '#'
  3472. X240    '*'
  3473. X241    '+'
  3474. X242    'o'
  3475. X243    'x'
  3476. X244    '#'
  3477. X245    '*'
  3478. X246    '+'
  3479. X247    'o'
  3480. X248    'x'
  3481. X249    '#'
  3482. X250    '*'
  3483. X251    '+'
  3484. X252    'o'
  3485. X253    'x'
  3486. X254    '#'
  3487. X255    '*'
  3488. END_OF_FILE
  3489. if test 1938 -ne `wc -c <'viewer/curses-map'`; then
  3490.     echo shar: \"'viewer/curses-map'\" unpacked with wrong size!
  3491. fi
  3492. # end of 'viewer/curses-map'
  3493. fi
  3494. if test -f 'viewer/curses.c' -a "${1}" != "-c" ; then 
  3495.   echo shar: Will not clobber existing file \"'viewer/curses.c'\"
  3496. else
  3497. echo shar: Extracting \"'viewer/curses.c'\" \(4139 characters\)
  3498. sed "s/^X//" >'viewer/curses.c' <<'END_OF_FILE'
  3499. X/* curses.c
  3500. X   Copyright (C) 1992  J Dana Eckart
  3501. X  
  3502. X   This program is free software; you can redistribute it and/or modify
  3503. X   it under the terms of the GNU General Public License as published by
  3504. X   the Free Software Foundation; either version 1, or (at your option)
  3505. X   any later version.
  3506. X  
  3507. X   This program is distributed in the hope that it will be useful,
  3508. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  3509. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3510. X   GNU General Public License for more details.
  3511. X  
  3512. X   You should have received a copy of the GNU General Public License
  3513. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  3514. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  3515. X*/
  3516. X
  3517. X#include <stdio.h>
  3518. X#include <stdlib.h>
  3519. X#include <malloc.h>
  3520. X#include <string.h>
  3521. X#include <curses.h>
  3522. X#include "view.h"
  3523. X#include "boolean.h"
  3524. X
  3525. X/* The ratio of the number of columns/lines to be used to make a reasonablly
  3526. X   nice (squarish) display.
  3527. X*/
  3528. X#define aspect_ratio    2
  3529. X
  3530. X/* When exiting curses, move the cursor to the bottom of the screen, 
  3531. X   refresh the screen and exit.
  3532. X*/
  3533. void finish_curses() {
  3534. X    erase();
  3535. X    refresh();
  3536. X    echo();
  3537. X    nl();
  3538. X    move(0, 0);
  3539. X    refresh();
  3540. X    endwin();
  3541. X}
  3542. X
  3543. X/* Updates a single cell in the display, but no refresh is done.  Use 
  3544. X   the lower left hand corner of the screen as the origin.
  3545. X*/
  3546. void update_curses(x, y, c) long int x, y; char c; {
  3547. X    int i = x - lower[range_dim_1_index];
  3548. X    int j = y - lower[range_dim_2_index];
  3549. X
  3550. X    /* Ignore moves off of the screen area and remember to save
  3551. X       the extra line for printing the time step value. 
  3552. X    */
  3553. X          if (ERR != move(LINES-j-2, i*aspect_ratio))
  3554. X               addch(c);
  3555. X}
  3556. X
  3557. X/* Display all the cell_vals in the universe. */
  3558. void display_curses_cells() {
  3559. X        refresh();
  3560. X}
  3561. X
  3562. X/* Does the necessary setup so that everything works correctly. */
  3563. void setup_curses(map_name) char *map_name; {
  3564. X    /* The "real" curses setup. */
  3565. X    initscr();
  3566. X    noecho();
  3567. X
  3568. X    /* Make sure the desired cell_vals will fit in a curses view of
  3569. X       the world.  Unfortunately, this view is limited because
  3570. X       stdin is already being used to get the cell values from,
  3571. X       and thus cannot be used to get commands for moving the
  3572. X       window into the cellular universe around.  Remember to
  3573. X       save an extra line for displaying the time step.
  3574. X    */
  3575. X    if (range[range_dim_1_index]*aspect_ratio-1 > COLS) {
  3576. X        fprintf(stderr, 
  3577. X            "First dimension is limited to %d indices.\n",
  3578. X            COLS/aspect_ratio);
  3579. X        finish_curses();
  3580. X        exit(1);
  3581. X    }
  3582. X    if (range_dim_given == 2 && range[range_dim_2_index] > LINES-1) {
  3583. X        fprintf(stderr, 
  3584. X            "Second dimension is limited to %d indices.\n",
  3585. X            LINES-1);
  3586. X        finish_curses();
  3587. X        exit(1);
  3588. X    }
  3589. X
  3590. X    /* If a map file was given, read it; otherwise use the default. */
  3591. X    if (NULL == map_name) {
  3592. X        char *default_file = "curses-map";
  3593. X        map_name = (char*) malloc((unsigned int) (strlen(LIB_DIR) + 
  3594. X                        strlen(default_file) + 2));
  3595. X        if (NULL == map_name)
  3596. X            error("Out of memory", (char*) NULL);
  3597. X        sprintf(map_name, "%s/%s", LIB_DIR, default_file);
  3598. X    }
  3599. X    read_map(map_name, MAX_MAP_SIZE);
  3600. X}
  3601. X
  3602. X/* Display the cell_vals visible within the curses window. */
  3603. void display_curses (field) int field; {
  3604. X    long int i, j;
  3605. X
  3606. X    /* Initialize the curses positions to the character values. */
  3607. X    for (i = lower[range_dim_1_index]; i <= upper[range_dim_1_index]; i++)
  3608. X        for (j = lower[range_dim_2_index]; j <= upper[range_dim_2_index]; j++)
  3609. X            update_curses(i, j, (char)
  3610. X                      map_value(cell_vals[(i - 
  3611. X                        lower[range_dim_1_index]) *
  3612. X                        range[range_dim_2_index] +
  3613. X                        j - lower[range_dim_2_index]]));
  3614. X    display_curses_cells();
  3615. X
  3616. X    while (1) {
  3617. X#if !COMBINED
  3618. X        if (next_time >= 0) 
  3619. X#endif
  3620. X        {
  3621. X            char string[MAX_STRING_SIZE];
  3622. X
  3623. X            /* Write out the current time step. */
  3624. X            sprintf(string, "time = %d", _time);
  3625. X            move(LINES-1, 0);
  3626. X            addstr(string);
  3627. X
  3628. X            /* Read and display the cell_vals. */
  3629. X#if COMBINED
  3630. X            cellang_main(false, field);
  3631. X#else
  3632. X            read_cell_block();
  3633. X#endif
  3634. X            display_curses_cells();
  3635. X
  3636. X#if !COMBINED
  3637. X            if (next_time >= 0) _time++;
  3638. X#endif
  3639. X
  3640. X            /* Pause times of 0 or less are ignored. */
  3641. X            if (pause_time > 0) sleep((unsigned int) pause_time);
  3642. X        }
  3643. X    }
  3644. X}
  3645. END_OF_FILE
  3646. if test 4139 -ne `wc -c <'viewer/curses.c'`; then
  3647.     echo shar: \"'viewer/curses.c'\" unpacked with wrong size!
  3648. fi
  3649. # end of 'viewer/curses.c'
  3650. fi
  3651. if test -f 'viewer/curses.h' -a "${1}" != "-c" ; then 
  3652.   echo shar: Will not clobber existing file \"'viewer/curses.h'\"
  3653. else
  3654. echo shar: Extracting \"'viewer/curses.h'\" \(878 characters\)
  3655. sed "s/^X//" >'viewer/curses.h' <<'END_OF_FILE'
  3656. X/* curses.h
  3657. X   Copyright (C) 1992  J Dana Eckart
  3658. X  
  3659. X   This program is free software; you can redistribute it and/or modify
  3660. X   it under the terms of the GNU General Public License as published by
  3661. X   the Free Software Foundation; either version 1, or (at your option)
  3662. X   any later version.
  3663. X  
  3664. X   This program is distributed in the hope that it will be useful,
  3665. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  3666. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3667. X   GNU General Public License for more details.
  3668. X  
  3669. X   You should have received a copy of the GNU General Public License
  3670. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  3671. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  3672. X*/
  3673. X
  3674. extern void finsih_curses();
  3675. extern void setup_curses();
  3676. extern void display_curses();
  3677. extern void update_curses();
  3678. END_OF_FILE
  3679. if test 878 -ne `wc -c <'viewer/curses.h'`; then
  3680.     echo shar: \"'viewer/curses.h'\" unpacked with wrong size!
  3681. fi
  3682. # end of 'viewer/curses.h'
  3683. fi
  3684. if test -f 'viewer/view.h' -a "${1}" != "-c" ; then 
  3685.   echo shar: Will not clobber existing file \"'viewer/view.h'\"
  3686. else
  3687. echo shar: Extracting \"'viewer/view.h'\" \(1823 characters\)
  3688. sed "s/^X//" >'viewer/view.h' <<'END_OF_FILE'
  3689. X/* view.h
  3690. X   Copyright (C) 1992  J Dana Eckart
  3691. X  
  3692. X   This program is free software; you can redistribute it and/or modify
  3693. X   it under the terms of the GNU General Public License as published by
  3694. X   the Free Software Foundation; either version 1, or (at your option)
  3695. X   any later version.
  3696. X  
  3697. X   This program is distributed in the hope that it will be useful,
  3698. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  3699. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3700. X   GNU General Public License for more details.
  3701. X  
  3702. X   You should have received a copy of the GNU General Public License
  3703. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  3704. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  3705. X*/
  3706. X
  3707. X#include <stdio.h>
  3708. X#include <strings.h>
  3709. X#include "boolean.h"
  3710. X
  3711. X#define MAX_STRING_SIZE    256
  3712. X#define MAX_MAP_SIZE    256
  3713. X
  3714. X/* Contains the current time. */
  3715. extern unsigned long int _time;
  3716. X
  3717. X#if !COMBINED
  3718. X/* Contains the next time at which to read data. */
  3719. extern long int next_time;
  3720. X#endif
  3721. X
  3722. X/* Time to pause between time steps, in order to slow things down. */
  3723. extern long int pause_time;
  3724. X
  3725. X/* The cellular universe which contains the colors/characters that
  3726. X   correspond to the cell values which are read.
  3727. X*/
  3728. typedef long int celltype;
  3729. extern celltype *cell_vals;
  3730. X
  3731. X/* The following variables are the lower and upper bounds of the
  3732. X   dimensions to display.
  3733. X*/
  3734. X#define MAX_DIMS    256
  3735. extern int dim_given, range_dim_given, range_dim_1_index, range_dim_2_index;
  3736. extern long int lower[], upper[], range[];
  3737. X
  3738. X/* Holds the number of character/color map entries given. */
  3739. extern int max_map_entry;
  3740. X
  3741. extern void read_cell_block();
  3742. extern void read_map();
  3743. extern void error();
  3744. extern celltype map_value();
  3745. X
  3746. X#if COMBINED
  3747. X    extern void cellang_main();
  3748. X    extern void init_cells();
  3749. X#endif
  3750. END_OF_FILE
  3751. if test 1823 -ne `wc -c <'viewer/view.h'`; then
  3752.     echo shar: \"'viewer/view.h'\" unpacked with wrong size!
  3753. fi
  3754. # end of 'viewer/view.h'
  3755. fi
  3756. if test -f 'viewer/x11.h' -a "${1}" != "-c" ; then 
  3757.   echo shar: Will not clobber existing file \"'viewer/x11.h'\"
  3758. else
  3759. echo shar: Extracting \"'viewer/x11.h'\" \(891 characters\)
  3760. sed "s/^X//" >'viewer/x11.h' <<'END_OF_FILE'
  3761. X/* x11.h
  3762. X   Copyright (C) 1992  J Dana Eckart
  3763. X  
  3764. X   This program is free software; you can redistribute it and/or modify
  3765. X   it under the terms of the GNU General Public License as published by
  3766. X   the Free Software Foundation; either version 1, or (at your option)
  3767. X   any later version.
  3768. X  
  3769. X   This program is distributed in the hope that it will be useful,
  3770. X   but WITHOUT ANY WARRANTY; without even the implied warranty of
  3771. X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3772. X   GNU General Public License for more details.
  3773. X  
  3774. X   You should have received a copy of the GNU General Public License
  3775. X   along with CELLULAR-2.0; see the file COPYING.  If not, write to the 
  3776. X   Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  3777. X*/
  3778. X
  3779. extern celltype setcolor();
  3780. extern void finish_x11();
  3781. extern void setup_x11();
  3782. extern void display_x11();
  3783. extern void update_x11();
  3784. END_OF_FILE
  3785. if test 891 -ne `wc -c <'viewer/x11.h'`; then
  3786.     echo shar: \"'viewer/x11.h'\" unpacked with wrong size!
  3787. fi
  3788. # end of 'viewer/x11.h'
  3789. fi
  3790. echo shar: End of archive 1 \(of 3\).
  3791. cp /dev/null ark1isdone
  3792. MISSING=""
  3793. for I in 1 2 3 ; do
  3794.     if test ! -f ark${I}isdone ; then
  3795.     MISSING="${MISSING} ${I}"
  3796.     fi
  3797. done
  3798. if test "${MISSING}" = "" ; then
  3799.     echo You have unpacked all 3 archives.
  3800.     rm -f ark[1-9]isdone
  3801. else
  3802.     echo You still need to unpack the following archives:
  3803.     echo "        " ${MISSING}
  3804. fi
  3805. ##  End of shell archive.
  3806. exit 0
  3807.