|
|
1.1 root 1: # mkkeytab - builds keyword.c, which is structure of keywords and
2: # their identification numbers. also builds keyword.h, which has
3: # defined constants giving keyword identification numbers.
4: # input is list of keyword/identfication number pairs, (alphabetic
5: # order-one pair per line) in file 'keywords', elements of a pair
6: # are separated by one or more blanks or tabs.
7:
8: procedure main(args)
9: local df, f, input, word, atab
10:
11: input := open("keywords") | stop("unable to open 'keywords'")
12: f := open("keyword.c","w")
13: df := open("../h/keyword.h","w")
14: write(df,"/*")
15: write(df," * Keyword definitions.")
16: write(df," */\n")
17:
18: write(f, "#include \"../h/keyword.h\"") # put out table header
19: write(f, "#include \"sym.h\"")
20: write(f, "")
21: write(f, "/*")
22: write(f, " * Keyword table.")
23: write(f, " */")
24: write(f, "")
25: write(f, "struct keyent keytab[] = {")
26:
27: every # put out table body
28: trim(!input) ?
29: if word := tab(upto(' \t')) then {
30: tab(many(' \t'))
31: if *word < 6 then atab := "\t\t" else atab := "\t"
32: write(df, "#define K_",ucase(word),atab,right(tab(0),2))
33: write(f," \"",word,"\",\tK_",ucase(word),",")
34: }
35: else
36: write(&errout, "bad input: ", &subject)
37:
38: write(f," \"\"\t\t-1")
39: write(f, " };")
40:
41: end
42:
43: procedure ucase(name)
44: return map(name,&lcase,&ucase)
45: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.