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?



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).

  • $\begingroup$ I see, then I have to check with who gave me the productions. $\endgroup$ – Novicegrammer Apr 12 '20 at 10:50
  • $\begingroup$ 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). $\endgroup$ – vonbrand Apr 12 '20 at 15:33
  • $\begingroup$ @vonbrand Yes, however I did not list the entire grammar here. $\endgroup$ – Novicegrammer Apr 15 '20 at 20: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.