Class Parser

java.lang.Object
org.glassfish.rmic.tools.java.Scanner
org.glassfish.rmic.tools.java.Parser
All Implemented Interfaces:
Constants, ParserActions, RuntimeConstants
Direct Known Subclasses:
BatchParser

public class Parser extends Scanner implements ParserActions, Constants
This class is used to parse Java statements and expressions. The result is a parse tree.

This class implements an operator precedence parser. Errors are reported to the Environment object, if the error can't be resolved immediately, a SyntaxError exception is thrown.

Error recovery is implemented by catching SyntaxError exceptions and discarding input tokens until an input token is reached that is possibly a legal continuation.

The parse tree that is constructed represents the input exactly (no rewrites to simpler forms). This is important if the resulting tree is to be used for code formatting in a programming environment. Currently only documentation comments are retained.

The parsing algorithm does NOT use any type information. Changes in the type system do not affect the structure of the parse tree. This restriction does introduce an ambiguity an expression of the form: (e1) e2 is assumed to be a cast if e2 does not start with an operator. That means that (a) - b is interpreted as subtract b from a and not cast negative b to type a. However, if a is a simple type (byte, int, ...) then it is assumed to be a cast.

WARNING: The contents of this source file are not part of any supported API. Code that depends on them does so at its own risk: they are subject to change or removal without notice.