All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----epp.Parser
Parser.java
file defines methods of the EPP preprocessor
that are used for the parser portion of the Java language.
Note: This class is provided for the sake of creating javadocs. It does not exist in the actual EPP source code.
By extending the behaviour of each method using the SystemMixin
syntax from with a plug-in, you can extend the grammar of the Java
language that EPP processes.
The parser of EPP is written in recursive descent style.
A recursive descent parser is a parser written in a style where
each non-terminal is described as a single function.
The funtion will parse one non-terminal and return a tree.
For example, in EPP, the method expression()
starts parsing assuming that an "expression" begins from
the current token and returns the parsed result as
an abstract syntax tree.
Most non-terminals are defined using the
EPP provides a mechanism for back tracking while parsing.
While a pure single token peek ahead recursive descent syntax parser can
only handle LL(1) grammer, it can handle a broarder ranges
by back traking.
This method is automatically defined by the
This method is automatically defined by the
This method is automatically defined by the
For the sake of implementation, the
For the plug-in to introduce a new "type description", you will need
to extend the
The canonical form of a type is defined as follows.
If the passed argument is not an appropriate abstract syntax tree
describing a type, an
defineNonterminal
macro. This macro automatically defines methods including xxxTop
,
xxxLeft
, and xxxRight. Plug-ins may also add new
alternatives to the non-terminal by extending these methods.
For a list of non-terminals, see
"Java grammar accepted by EPP".
Type
and returns the result.
Parser
public Parser()
xxx
public Tree xxx()
xxxTop
statement
, expression
,
classBodyDeclaration
, etc.)
Normally, plug-ins should not extend/redefine this method.
(Doing so, may confuse line number processing.)
If you wish to extend the syntax, extend the methods named
xxxTop
, xxxRight
, and
xxxLeft
.
public Tree xxxTop()
xxxRight
defineNonterminal
macro.
public Tree xxxRight(Tree tree)
xxxLeft
tree
is the parsed result of the left hand side
of the binary operator.
defineNonterminal
macro.
public Tree xxxLeft(Tree tree)
xxx1
tree
is the parsed result of the non-terminal xxx.
defineNonterminal
macro.
public Tree xxx1()
type
public Tree type()
convertExpressionToType
Type
and returns the result.
type
method first
calls the primary
method, then converts the result value
into a canonical form that describes a type and returns it.
In order to convert the result value into a canonical form, this
method calls the convertExpressionToType
method.
primaryTop
method and the
convertExpressionToType
method.
public Tree convertExpressionToType(Tree exp)
CanonicalType:
(name Identifier Identifier*)
(arrayOf CanonicalType)
<extended alternatives>
EppUserError
will be thrown.
All Packages Class Hierarchy This Package Previous Next Index