I had written a compiler compiler a few years ago and I'm now cleaning it up, improving it, and turning it into C.

I came across a terminology problem however that I remember in the past I couldn't solve it either.

Imagine an LL(k) stack. In this stack, you may have terminals, that are expected to be matched with the next token, or non-terminals that would expand based on the next token. In either case, there is a string in the stack.

The word I am looking for, is a term that means either a terminal or non-terminal. Wikipedia was of no help.

To clarify a bit more, imagine a grammar with $t = \{a \mid a \text{ terminal}\}$ and $T = \{A \mid A \text{ non-terminal}\}$. If you have a set $X = \{x | x \in t \vee x \in T\}$, how would you refer to an element of $X$? "Grammar symbol"? "Grammar element"? "Terminal or non-terminal symbol"?

I am in particular looking for a name as short and to the point as possible, since this will end up becoming a variable name!


1 Answer 1


The long forms "terminal symbol" and "nonterminal symbol" suggest that you are dealing first and foremost with "symbols"; "terminal" and "non-terminal" are qualifiying attributes that specify a symbol's role in the grammar. A symbol that can be either one of terminal and non-terminal is, almost by virtue of logics, just an arbitrary symbol.

Therefore, "symbol" seems to be the natural choice. I am pretty sure it is the term usually used, too, but such statements are hard to validate.

If you want to stress that a given symbol can be either kind (in text), you can always use "arbitrary symbol (of grammar $G$)", or define $X \subseteq t \cup T$ explicitly. In source code, I'd just use "symbol".

  • 2
    $\begingroup$ It is what Aho and Ullman are using in their theory of parsing, translation and compiling. $\endgroup$ Jul 23, 2012 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.