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!
How to call something that can be either a terminal or a nonterminal?
terminology;formal grammars;compilers
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.