teeny.c: // #include has to be done *during* lexing. // Should all # directives also be done then? // Everything except #include *could* be done // between lexing and parsing as a scan through c[]. // I would *much* prefer to handle it outside the // lexer, as it adds unnecessary cmplexity to the // line reconstruction phase as I really want that // to be simple and fast... takeon.c: Takeon generates a grammar in gram[]. Phrases are numbered sequentially from 512 upwards, with a lookup table from this sequential numbering into gram indexes stored in phrase[]. We *could* make the phrase numbers sparse, and have only the gram table without the phrase table - the only reason to do it this way is so that the phrasename[] table is compact. If we didn't do the indirection (thus saving the phrase[] table) then the phrasename table would be as big as the gram table, which is much worse. Of course, the downside is that we only really need the phrasename table for diagnostics, so in a production compiler it's true that we do have a slight unnecessary overhead. In our first example, a semicolon after the first end was a syntax error. ============================= int i, j, k procedure jim(int k) begin int l, m i = k * 2 + j end; program begin int endwhile99 for (j = 1; j < k; j = j+1) jim(2) jim(3) while (i <= 23) k = 44 endwhile99 = 7 endwhile endfor k = j end ============================= Next, we have some sensitivity to where a #define may be allowed. Looks like before initial decls is OK but after is bad... int i, j, k #define kdef 1 procedure jim(int k) begin int l, m i = k * $0002 + j end; program begin int endwhile99 for (j = 1; j < k; j = j+1) jim(2) jim(3) while (i <= 23) #ifdef kdef k = 44 #endif endwhile99 = 7 endwhile endfor k = j j = '@' j = "address of string" end