Subject: Spidery Scheme

From: [email-masked]
Date: Mon, 5 Jun 89 15:00:16 EDT

I was playing with the idea of generating WEB for Scheme.  There are
many problem, especially the fact that Scheme users like a pretty
printed format that seems not generatable by WEB's algorithm.  While I
was playing, I found two bugs.

(1) In WebMakefile: the make command makes common.o and pathopen.o
even if they exist.

huxley% make
cc -DDEBUG -g -DSTAT -c /usr/src/local/tex/mitre/Spiderweb/master/common.c
mv common.o /usr/src/local/tex/mitre/Spiderweb/master/`arch`
cc -DDEBUG -g -DSTAT -c /usr/src/local/tex/mitre/Spiderweb/master/pathopen.c
mv pathopen.o /usr/src/local/tex/mitre/Spiderweb/master/`arch`
echo "date" `date` | cat - scheme.spider | awk -f /usr/src/local/tex/mitre/Spiderweb/master/spider.awk
Warning: numeric constants and strings are identified in this WEAVE.
awk: tokentest is not an array
 record number 30
*** Error code 2
make: Fatal error: Command failed for target `grammar.web'

(2) Spider.awk fails as input to GNU's version of make:

huxley% echo "date" `date` | cat - scheme.spider | gawk -f /usr/src/local/tex/mitre/Spiderweb/master/spider.awk
gawk:  syntax error near line 1221:
temp=sprintf"strncmp("%s",loc-1,%d)==0=0",$2,length($2)

                                           ^ parse error

The problem is gawk's sprintf expects a parenthesized argument list.
Using gawk is prefered because the error messages are better an Sun
awk does not always run spider.awk correctly.  The input file 

scheme.spider:
-------------
## A very broken attempt at scheme.

language Scheme extension scm

module definition exp use exp
# use as stmt is unavoidable since tangle introduces line breaks

comment begin <";"> end newline

line begin <";"-space-"line"> end <"">

default translation <*> mathness no

# identifiers are wrong -- no hope here.
token identifier category exp mathness yes
token number category exp mathness yes
token newline category newline translation <> mathness no
token pseudo_semi category semi mathness maybe translation <"\\relax">

semi <force> --> exp

token ( category open
token ) category close
#token . category binop translation <".\\,"-opt-3>

open exp --> call
call exp --> call
call close --> exp

#newline --> ignore_scrap

? ignore_scrap --> #1

-------------------

gives this output: (all is okay using gawk)

huxley% echo "date" `date` | cat - scheme.spider | awk -f /usr/src/local/tex/mitre/Spiderweb/master/spider.awk
Warning: numeric constants and strings are identified in this WEAVE.
awk: tokentest is not an array
 record number 27

---------------------

Thank you for making your software available.  I like Levy's CWEB and
am looking forward to using your version of CWEB.
John

---

From: nr (Norman Ramsey)
Date: Sat, 17 Jun 89 11:02:25 EDT

> From [email-masked] Mon Jun  5 15:02:30 1989
> printed format that seems not generatable by WEB's algorithm.  

What is the difficulty?  Are there some lexical elements that WEB
can't recognize, or does one need semantic information to prettyprint
Scheme?  I have only a nodding acquaintance with Lisp and know even
less about Scheme, but I shouldn't have expected too much difficulty.

> While I

The problem is in your use of `arch` and exposes a flaw in make.  Make
is looking for a file common.o in a directory `arch` and not finding
it, so it makes the target.  You can cure the problem by replacing
`arch` with $(ARCH) in the Makefile and using ARCH=`arch` in the make
script that calls /bin/make.  I don't know of anything better.

> awk does not always run spider.awk correctly.  

I am reluctant to move to gawk because in the past I have found it
buggy and unstable.  BSD awk is buggy but at least is stable.
Spider.awk contains a number of workarounds.  I will look into the
tokentest problem.

> am looking forward to using your version of CWEB.

I'm glad to hear it.  Sorry I took so long getting back to you; I've
been out of town and things piled up while I was away.

Norman