org.apache.velocity.runtime.parser
Class Parser

This class is responsible for parsing a Velocity
template. This class was generated by JavaCC using
the JJTree extension to produce an Abstract
Syntax Tree (AST) of the template.
Please look at the Parser.jjt file which is
what controls the generation of this class.

token_source

token

jj_nt

Parser

This constructor was added to allow the re-use of parsers.
The normal constructor takes a single argument which
an InputStream. This simply creates a re-usable parser
object, we satisfy the requirement of an InputStream
by using a newline character as an input stream.

Parser

parse

This was also added to allow parsers to be
re-usable. Normal JavaCC use entails passing an
input stream to the constructor and the parsing
process is carried out once. We want to be able
to re-use parsers: we do this by adding this
method and re-initializing the lexer with
the new stream that we want parsed.

isDirective

process

This method is what starts the whole parsing
process. After the parsing is complete and
the template has been turned into an AST,
this method returns the root of AST which
can subsequently be traversed by a visitor
which implements the ParserVisitor interface
which is generated automatically by JavaCC

EscapedDirective

used to separate the notion of a valid directive that has been
escaped, versus something that looks like a directive and
is just schmoo. This is important to do as a separate production
that creates a node, because we want this, in either case, to stop
the further parsing of the Directive() tree.

Escape

Used to catch and process escape sequences in grammatical constructs
as escapes outside of VTL are just characters. Right now we have both
this and the EscapeDirective() construction because in the EscapeDirective()
case, we want to suck in the # and here we don't. We just want
the escapes to render correctly