In C++ the declaration of floating point variables starts with the type name float or double, followed by the name of the variable, and terminates with a semicolon. It is possible to declare multiple variables separated by commas in one statement. The following statements present examples,

float z;
double z, w;

The following partial grammar represents the specification for C++ style variable declaration. In this grammar, the letters z and w are terminals that represent two variable names. The non-terminal S is the start symbol.

S=TV;
V = cx
X= , V|E
T = float double
C = z|w

1. Determine Nullable values for the LHS and RHS of all rules. Please note, your answer includes all Nullable functions for LHS and RHS, in addition to the resulting values.
2. Using the Nullable values that you calculated in part 1, and using the FIRST sets that you calculated in part 2, determine the FOLLOW sets for all non-terminals, i.e. LHS of the rules. Please note, your answer includes all FOLLOW relations in addition to the resulting sets.

Respuesta :

Answer:

The given grammar is :

S = T V ;

V = C X

X = , V | ε

T = float | double

C = z | w

1.

Nullable variables are the variables which generate ε ( epsilon ) after one or more steps.

From the given grammar,

Nullable variable is X as it generates ε ( epsilon ) in the production rule : X -> ε.

No other variables generate variable X or ε.

So, only variable X is nullable.

2.

First of nullable variable X is First (X ) = , and ε (epsilon).

L.H.S.

The first of other varibles are :

First (S) = {float, double }

First (T) = {float, double }

First (V) = {z, w}

First (C) = {z, w}

R.H.S.

First (T V ; ) = {float, double }

First ( C X ) = {z, w}

First (, V) = ,

First ( ε ) = ε

First (float) = float

First (double) = double

First (z) = z

First (w) = w

Explanation:

ACCESS MORE