Search code examples
ll-grammar

LL grammar and FIRST


Suppose a chunk of LL grammar

STATEMENT ::= ε | R
R         :: = print (variable)

And I try to find the FIRST(Statement)

FIRST(STATEMENT) = FIRST(ε) + FIRST(R)
FIRST(R) = { print (variable) } 

My question is. Is the FIRST(R) correct ? Or the below:

FIRST(R) = {print}

Solution

  • No, FIRST(R) is just print, assuming that print is a token.