anyone played with yacc? - (nf)

abe at ism780.UUCP abe at ism780.UUCP
Wed Jun 13 14:24:35 AEST 1984


#R:clyde:-45000:ism780:14400010:000:1031
ism780!abe    Jun 11 11:00:00 1984

In addition to having a very large yacc executable, this approach has
the drawback of not being able to compile your system on anything but
your own local hacked-yacc.

Another approach, if you are somewhere near the 127-terminal limit,
is to have various local rules do their own keyword-parsing.  E.g. if
you had something like:

type_specifier:
		INT
	     |  LONG
	     |  CHAR
	     |  SHORT
		.
		.
		.

and the INT, LONG, etc. are not used elsewhere as terminals, you can
remove the definitions of these as tokens, and do something like:

type_specifier:	identifier
		{
			if (equal(yytext, "int"))
				...
			else if (equal(yytext, "long"))
				...

			else (printf("illegal type specifier\n"));
		}

Of course, you have to be careful that this doesn't introduce ambiguities
into the grammar.  The above example is probably bad since it deals with
a pretty significant part of the language; but innocuous areas where the
above procedure can be used are probably present, especially if you've gone
over the 127-token limit!



More information about the Comp.unix.wizards mailing list