NVelocity.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.

Field Summary
NVelocity.Runtime.Parser.Token jj_nt
bool lookingAhead
NVelocity.Runtime.Parser.Token token
NVelocity.Runtime.Parser.ParserTokenManager token_source

Constructor Summary
Parser(NVelocity.Runtime.RuntimeServices rs)
         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(NVelocity.Runtime.Parser.CharStream stream)
Parser(NVelocity.Runtime.Parser.ParserTokenManager tm)

Property Summary
System.Collections.Hashtable Directives
NVelocity.Runtime.Parser.Token NextToken

Method Summary
void AdditiveExpression()
void Assignment()
void Comment()
void ConditionalAndExpression()
void ConditionalOrExpression()
NVelocity.Runtime.Parser.Node.SimpleNode Directive()
         Supports the Pluggable Directives #foo( arg+ )
void DirectiveArg()
         Supports the arguments for the Pluggable Directives We add whitespace in here as a token so the VMs can easily reconstruct a macro body from the token stream See Directive()
void disable_tracing()
void ElseIfStatement()
void ElseStatement()
void enable_tracing()
void EqualityExpression()
void Escape()
void 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.
void Expression()
void False()
NVelocity.Runtime.Parser.ParseException generateParseException()
NVelocity.Runtime.Directive.Directive getDirective(string directive)
         This method gets a Directive from the directives Hashtable
NVelocity.Runtime.Parser.Token getToken(int index)
void Identifier()
         This method corresponds to variable references in Velocity templates. The following are examples of variable references that may be found in a template: * $foo $bar *
void IfStatement()
void IntegerRange()
         supports the [n..m] vector generator for use in the #foreach() to generate measured ranges w/o needing explicit support from the app/servlet
bool isDirective(string directive)
         This method finds out of the directive exists in the directives Hashtable.
void Method()
         This method has yet to be fully implemented but will allow arbitrarily nested method calls
void MultiplicativeExpression()
void NumberLiteral()
void ObjectArray()
void Parameter()
         This method has yet to be fully implemented but will allow arbitrarily nested method calls
NVelocity.Runtime.Parser.Node.SimpleNode parse(System.IO.TextReader reader, string templateName)
         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.
void PrimaryExpression()
NVelocity.Runtime.Parser.Node.SimpleNode 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
void Reference()
void ReInit(NVelocity.Runtime.Parser.ParserTokenManager tm)
void ReInit(NVelocity.Runtime.Parser.CharStream stream)
void RelationalExpression()
void SetDirective()
         Currently support both types of set : #set( expr ) #set expr
void Statement()
         These are the types of statements that are acceptable in Velocity templates.
void StopStatement()
         This method corresponds to the #stop directive which just simulates and EOF so that parsing stops. The #stop directive is useful for end-user debugging purposes.
void StringLiteral()
void Text()
         This method is responsible for allowing all non-grammar text to pass through unscathed.
void True()
void UnaryExpression()
void Word()

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString


Field Detail

jj_nt

public NVelocity.Runtime.Parser.Token jj_nt


lookingAhead

public bool lookingAhead


token

public NVelocity.Runtime.Parser.Token token


token_source

public NVelocity.Runtime.Parser.ParserTokenManager token_source

Constructor Detail

Parser

public Parser(NVelocity.Runtime.RuntimeServices rs)

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

public Parser(NVelocity.Runtime.Parser.CharStream stream)


Parser

public Parser(NVelocity.Runtime.Parser.ParserTokenManager tm)

Property Detail

Directives

public System.Collections.Hashtable Directives


NextToken

public NVelocity.Runtime.Parser.Token NextToken

Method Detail

AdditiveExpression

public void AdditiveExpression()


Assignment

public void Assignment()


Comment

public void Comment()


ConditionalAndExpression

public void ConditionalAndExpression()


ConditionalOrExpression

public void ConditionalOrExpression()


Directive

public NVelocity.Runtime.Parser.Node.SimpleNode Directive()

Supports the Pluggable Directives #foo( arg+ )


DirectiveArg

public void DirectiveArg()

Supports the arguments for the Pluggable Directives We add whitespace in here as a token so the VMs can easily reconstruct a macro body from the token stream See Directive()


disable_tracing

public void disable_tracing()


ElseIfStatement

public void ElseIfStatement()


ElseStatement

public void ElseStatement()


enable_tracing

public void enable_tracing()


EqualityExpression

public void EqualityExpression()


Escape

public void Escape()


EscapedDirective

public void 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.


Expression

public void Expression()


False

public void False()


generateParseException

public NVelocity.Runtime.Parser.ParseException generateParseException()


getDirective

public NVelocity.Runtime.Directive.Directive getDirective(string directive)

This method gets a Directive from the directives Hashtable


getToken

public NVelocity.Runtime.Parser.Token getToken(int index)


Identifier

public void Identifier()

This method corresponds to variable references in Velocity templates. The following are examples of variable references that may be found in a template: * $foo $bar *


IfStatement

public void IfStatement()


IntegerRange

public void IntegerRange()

supports the [n..m] vector generator for use in the #foreach() to generate measured ranges w/o needing explicit support from the app/servlet


isDirective

public bool isDirective(string directive)

This method finds out of the directive exists in the directives Hashtable.


Method

public void Method()

This method has yet to be fully implemented but will allow arbitrarily nested method calls


MultiplicativeExpression

public void MultiplicativeExpression()


NumberLiteral

public void NumberLiteral()


ObjectArray

public void ObjectArray()


Parameter

public void Parameter()

This method has yet to be fully implemented but will allow arbitrarily nested method calls


parse

public NVelocity.Runtime.Parser.Node.SimpleNode parse(System.IO.TextReader reader,
                                                      string templateName)

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.


PrimaryExpression

public void PrimaryExpression()


process

public NVelocity.Runtime.Parser.Node.SimpleNode 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


Reference

public void Reference()


ReInit

public void ReInit(NVelocity.Runtime.Parser.ParserTokenManager tm)


ReInit

public void ReInit(NVelocity.Runtime.Parser.CharStream stream)


RelationalExpression

public void RelationalExpression()


SetDirective

public void SetDirective()

Currently support both types of set : #set( expr ) #set expr


Statement

public void Statement()

These are the types of statements that are acceptable in Velocity templates.


StopStatement

public void StopStatement()

This method corresponds to the #stop directive which just simulates and EOF so that parsing stops. The #stop directive is useful for end-user debugging purposes.


StringLiteral

public void StringLiteral()


Text

public void Text()

This method is responsible for allowing all non-grammar text to pass through unscathed.


True

public void True()


UnaryExpression

public void UnaryExpression()


Word

public void Word()