Alex Rivera | Logout

Javacc parser option LOOKAHEAD, Java

Asked 2010-02-20T16:46:25.377
9

I've recently started to play around with grammatical analyzers using javacc and one of the fields is the options one...I have a code like the folowing:

options
{
  LOOKAHEAD=1;
}
PARSER_BEGIN(Calculator)

public class Calculator
{
 ...
}
PARSER_END(Calculator)

What exactly does it mean the LOOKAHEAD option? Thanks

Edit
Report

1 Answer

2

The LOOKAHEAD value tells the generated parser how many unprocessed (i.e., future) tokens to use to decide what state to transition to. In a tightly-constrained language, only one lookahead token is necessary. The more ambiguous a language is, the more lookahead tokens are needed to determine which state transition to make.

I think this is covered in the javacc(1) tutorial.

answered 2010-02-20T16:59:13.493

Your Answer