home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
historic
/
v92.tgz
/
v92.tar
/
v92
/
src
/
icont
/
mkkwd.icn
< prev
next >
Wrap
Text File
|
1996-03-22
|
1KB
|
53 lines
# mkkwd.icn
#
# reads: standard input (typically ../runtime/keywords.r)
#
# writes: keyword.c
# keyword.h
# kdefs.h
procedure main()
local kywds, klist, line, f, k, i
# load keywords
kywds := set()
while line := read() do {
line ? {
if ="keyword" then {
tab(find("}")+1)
tab(many(' \t'))
insert(kywds,tab(0))
}
}
}
klist := sort(kywds)
# write defined constants to keyword.h
hfile := wopen("keyword.h", "Keyword manifest constants")
lfile := wopen("../h/kdefs.h", "Keyword list")
i := 0
every k := !klist do {
kname := "K_" || map(k,&lcase,&ucase)
write(hfile, "#define ", left(kname,13), right(i+:=1,3))
write(lfile, "KDef(", k, ",", kname, ")")
}
end
# wopen(fname,comment) -- open file for writing
#
# opens and returns file; writes header comment; writes message to stdout
procedure wopen(fname,comment)
local f
f := open(fname, "w") | stop ("can't open ", fname, " for writing")
write(f, "/*")
write(f, " * ", fname, " -- ", comment, ".")
write(f, " *")
write(f, " * Created mechanically by mkkwd.icn -- DO NOT EDIT.")
write(f, " */")
write(f)
write(" writing ", fname)
return f
end