lex/yacc question

Chris Torek chris at mimsy.umd.edu
Sun Dec 3 02:42:08 AEST 1989


In article <21582 at adm.BRL.MIL> thoth!jbd0 at gte.com (Jeffrey B. DeLeo) writes:
>Once you have identified your lexical primitives you should be all
>set.  These will be the nonterminals for your grammar; the grammar
>being defined in the yacc source file.

Since no one else has said anything yet, I will point out that these
are the terminals.  The nonterminals are the other words in the grammar:

	%token BAR BAZ FOO THE
	%%
	grammar: sentence | grammar sentence;
	sentence: FOO rest '.';
	rest: /* empty */ | THE object;
	object: BAR | BAZ;
	%%

Here there are 7 terminals (BAR, BAZ, FOO, and THE, and 3 unnamed:
$end, $error [a yacc internal thing, not actually used here], and the
period `.') and 4 nonterminals (grammar, sentence, rest, and object).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list