Look-ahead buffer

Top  Previous  Next

User interface > Main menu > Menu: Options > Project options > Parser/Scanner > Global scanner > Look-ahead buffer

 

By buffering of the look-ahead tokens parsing can be accelerated if look-ahead productions are used. If at first a look-ahead is tested in a production, then the tokens found are put on a stack and read from there again if the initial production is further executed.

 

Example:

 

Prod1 ::= IF( Prod2() ) "a" "b" ...

Prod2 ::= "a" "b"

 

If Prod2 has been tested, the tokens "a" and "b" are already anylsed from the text.

 

This method can work only, if some restrictions of the otherwise existing possibilities are accepted. E.g. the following then doesn't work any more:

 

Prod1 ::= IF( Prod2() ) ID+ ...

Prod2 ::= "a" "b"

 

It can be recommended often, to use ANY instead of SKIP. A sequence of tokens recognized with ANY+ in a look-ahead is reproduced correctly as a sequence of the specific tokens which were subsumed under ANY when reading the stack.

 

In the semantic actions sub-expressions cannot be accessed from the tokens fetched from the stack.  Inclusions cannot be used in combination with the look-ahead buffer.

 

 

 



This page belongs to the TextTransformer Documentation

Home  Content  German