Next: , Previous: , Up: D Parsers   [Contents][Index]


10.2.8 D Push Parser Interface

Normally, Bison generates a pull parser for D. The following Bison declaration says that you want the parser to be a push parser (see %define Summary):

%define api.push-pull push

Most of the discussion about the D pull Parser Interface, (see D Parser Interface) applies to the push parser interface as well.

When generating a push parser, the method pushParse is created with the following signature:

Method on YYParser: int pushParse (Symbol sym)

The primary difference with respect to a pull parser is that the parser method pushParse is invoked repeatedly to parse each token. This function is available if either the ‘%define api.push-pull push’ or ‘%define api.push-pull both’ declaration is used (see %define Summary).

The value returned by the pushParse method is one of the following: ACCEPT, ABORT, or PUSH_MORE. This new value, PUSH_MORE, may be returned if more input is required to finish parsing the input.

If api.push-pull is defined as both, then the generated parser class will also implement the parse method. This method’s body is a loop that repeatedly invokes the scanner and then passes the values obtained from the scanner to the pushParse method.