Start and successor of nullable structures

Top  Previous  Next

Grammar tests > Start and successor of nullable structures

 

The warning

 

LL(1) Warning: "X" is the start and successor of nullable structures

 

appears, if a nullable structure begins with the terminal symbol "X" and the same terminal symbol can follow this structure. Nullable structures are (...)? and (...)*.  An example is the following rule for recognition of a (German) number with possible fractional digits:

 

Number ::= ( Digits "," )? Digits

//LL(1) Warning: Digits is the start and successor of nullable structures

 

If the parser meets some digits, the nullable structure will be tested. If no comma follows the program will be finished with an error message. The rule should be written reversed:

 

Number ::= Digits ( "," Digits )? 

 

Because it depends on the chosen start rule which productions will be parsed, it also can depend on the start rule, if a token is start and successor of nullable structures or not.

 

An example of this sentence can be obtained by a little extension of the last example. So it's conceivable that the number production is part of a number pair production in which two numbers shall be separated by commas. E.g.:

 

Pair  ::= Number "," Digits

 

This is a serious conflict.

 

 

The creation of this warning can be suppressed by an according checkbox in the project options.

 

 

Another example is known in the literature as dangling else. The following two rules are hurting the LL(1)-condition:

 

Statement ::= IfStatement | ...

 

IfStatement ::= "if" Expression "then" Statement

                   ( "else" Statement )?

            

The instruction:

 

if a then if b then c else d

 

would be interpreted by TETRA as follows:

 

if a then

{

  if b then

     c

     else

     d

}     

 

that means, TETRA would arrange the else-branch to the if b. In a logical point of view the following arrangement would be possible too:

 

if a then

{

  if b then

     c

}      

else

d

 

 

 



This page belongs to the TextTransformer Documentation

Home  Content  German