# How can I determine the start non-terminal of a CFG?

Suppose I have a grammar such that there exist $$n$$ production rules which contain only terminal symbols, and none of these rules produce the same terminal (disjoint).

$$A ::= x|y|z$$

$$B ::= a|b|c$$

...

$$N ::= l|m|k$$

Further suppose that I cannot simply merge these production rules together as they are used in different parts of the grammar.

How can I hence determine or rather choose, the start non-terminal $$S$$, for purposes of $$LL(1)$$ parsing?

Thanks

## 1 Answer

By definition a grammar is a tuple $$(N,T,P,S)$$ where $$N$$ is the set of non-terminals, $$T$$ is the set of terminals, $$P$$ is the set of productions, and $$S \in N$$ is the start symbol.

Therefore if you have a grammar you already have $$S$$ (and if you don't know $$S$$ then you don't have a grammar).

• I see, then I have to check with who gave me the productions. – Novicegrammer Apr 12 '20 at 10:50
• A common convention is that the non-terminal at the left hand side of the first production is start symbol. But the given grammar makes no sense, it just generates a set of words from one non-terminal, all the others are useless (as they can't be used at all). – vonbrand Apr 12 '20 at 15:33
• @vonbrand Yes, however I did not list the entire grammar here. – Novicegrammer Apr 15 '20 at 20:47