oracle.javatools.parser
Class AbstractSyntaxRecognizer

The AbstractSyntaxRecognizer is a basic abstract
implementation which takes care of common functionality across
SyntaxRecognizers for LL(1) parsers. It's primarily designed
as an error-tolerant parser framework.

getCode

getDataValue

setDataValue

getContextString

protected java.lang.String getContextString()

setContextString

protected void setContextString(java.lang.String contextString)

copyStartOffset

protected void copyStartOffset()

Saves the start offset of the top production so that the next child
(presumably created with the current top as the parent) will inherit
the same start offset.
Example use: While parsing a class in a Java file, the modifiers
precede the field/method declaration. Until we get past the
modifiers we won't know which type of parse tree symbol to
instantiate. But we need some sort of "holder" parse tree symbol
to catch the modifiers when they fly by. Thus, we start a parent
"holder" symbol, parse modifiers, and then copy the start offset
of the parent when we create either the method or field parse
tree symbol as a child of the "holder".

curTokenToString

protected java.lang.String curTokenToString()

Some parser grammars switch on identifiers that are not
keywords. For example, in PL/SQL, "replace" is not a keyword, but
requires special handling in the parser. This is intended to be
used in those cases.

peekToken

protected final int peekToken()

Lookaheand one token.

nextToken

protected final boolean nextToken(int token)

Require the current token to be equal to the parameter value.
If yes, skip it. If no, generate a syntax error.

nextToken

protected final boolean nextToken(int primary,
int secondary)

If neither is present, the error-expecting syntax error will be
thrown for the primary token.

optionalToken

protected final boolean optionalToken(int token)

Skips the current token if equal to the parameter value. Does
nothing otherwise.

Returns:

True if a token was skipped. False otherwise.

skipToken

protected final void skipToken()

Skips the current token.

start

protected final void start(int code)

Begins a new production and generates a token.

startQuiet

protected final void startQuiet(int code)

Begins a new production and does not generate a token.

finishInherit

protected final void finishInherit()

Finishes the current production and inherits its end offset from
the last child.

finish

protected final void finish()

Finishes the current production and takes the current token as
its last token, but does NOT advance the lexer. Should very
rarely be used...

finishToken

protected final void finishToken()

Finishes the current production and takes the current token as
its last token. Advances the lexer.

finishToken

protected final void finishToken(int token)

Finishes the current production and takes the current token as
its last token. Requires that the last token be of a certain
value. If yes, advances the lexer. If no, it generates an
error-expecting syntax error and does not advance the lexer.

finishToken

protected final void finishToken(int primary,
int secondary)

Just like nextToken( int, int ) except that we're finishing.
So, if the current token is either the primary or secondary,
we finish with the current token as the last token. If not,
it generates an error-expecting syntax error on the primary token
and does not advance the lexer.

_codeToString

public java.lang.String _codeToString(int syntaxCode)

Converts the syntax code into a string.

errorCheckpoint

protected final boolean errorCheckpoint()

The idea is that on certain syntactic elements, we'll just go 'round
and 'round saying, "Expecting this" or "Expecting that" and never
actually consuming a token. So, what we do here is introduce some sort
of checkpoint. If we ever checkpoint twice on the same lexer token,
then this will generate an errorUnexpected.

I came up with the term "error checkpoint" because I didn't know what
the heck else to call it. :P (acyu 9/19/2002)

Returns:

True if the checkpoint is fine, i.e. no error was generated.
This happens if this is the first time we're checkpointing on
this lexer token. False otherwise.

notImplementedYet

protected void notImplementedYet(java.lang.String msg)

Generic way of throwing a "Not implemented yet" error.

errorExpecting

protected void errorExpecting(int token)

Generates an error-expecting token. Sub-classes should override
and report a more descriptive syntax error.

errorUnexpected

protected void errorUnexpected()

Generates an error-unexpected token. This typically occurs when you
have a token that makes absolutely no sense in the current context and
so we're going to try to consume it and move on in life.

errorUnexpected

protected void errorUnexpected(boolean consumeToken)

Generates an error-unexpected token. Consumes a token if directed
to do so.

inheritEndOffset - Use the end offset of the last token + 1. For
example, when reporting a java "Expecting ;" error, you want
the error offset to be where you expect the semicolon to be,
i.e. right after the last token. Don't set the offset to be
the next token as is expected usually.

internalError

protected void internalError(java.lang.String errorMsg)

Report an internal error. This also provides the syntax code,
resolve level, and current token in the error output.