C# Class NVelocity.Runtime.Parser.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.
显示文件 Open project: rasmus-toftdahl-olesen/NVelocity Class Usage Examples

Public Properties

Property Type Description
lookingAhead bool
token Token
token_source ParserTokenManager

Protected Properties

Property Type Description
directiveStack Stack

Public Methods

Method Description
AdditiveExpression ( ) : void
Assignment ( ) : void
Comment ( ) : void
ConditionalAndExpression ( ) : void
ConditionalOrExpression ( ) : void
Directive ( ) : NVelocity.Runtime.Parser.Node.SimpleNode

Supports the Pluggable Directives #foo( arg+ )

DirectiveArg ( ) : void

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()

ElseIfStatement ( ) : void
ElseStatement ( ) : void
EqualityExpression ( ) : void
Escape ( ) : void

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 #<directive> and here we don't. We just want the escapes to render correctly

EscapedDirective ( ) : void

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 ( ) : void
False ( ) : void
GenerateParseException ( ) : ParseException
GetToken ( int index ) : Token
Identifier ( ) : void

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 ( ) : void
IntegerRange ( ) : void

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 ( String directive ) : bool

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

Method ( ) : void

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

MultiplicativeExpression ( ) : void
NumberLiteral ( ) : void
ObjectArray ( ) : void
Parameter ( ) : void

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

Parse ( TextReader reader, String templateName ) : NVelocity.Runtime.Parser.Node.SimpleNode

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.

Parser ( ICharStream stream ) : System
Parser ( IRuntimeServices rs ) : System

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 ( ParserTokenManager tm ) : System
PrimaryExpression ( ) : void
Process ( ) : NVelocity.Runtime.Parser.Node.SimpleNode

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

ReInit ( ICharStream stream ) : void
ReInit ( ParserTokenManager tm ) : void
Reference ( ) : void
RelationalExpression ( ) : void
SetDirective ( ) : void

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

Statement ( ) : void

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

StopStatement ( ) : void

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 ( ) : void
Text ( ) : void

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

True ( ) : void
UnaryExpression ( ) : void
Word ( ) : void

Private Methods

Method Description
AddErrorToken ( int kind, int position ) : void
ConsumeToken ( int kind ) : Token
ConsumeWhiteSpaces ( ) : void
EscapedDirective ( String strImage ) : String

Produces a processed output for an escaped control or pluggable directive

GetCurrentTokenKind ( ) : int
InitBlock ( ) : void
RescanToken ( ) : void
Save ( int index, int xla ) : void
ScanToken ( int kind ) : bool
ToRefactor1 ( ) : bool
jj_2_1 ( int xla ) : bool
jj_2_10 ( int xla ) : bool
jj_2_11 ( int xla ) : bool
jj_2_12 ( int xla ) : bool
jj_2_2 ( int xla ) : bool
jj_2_3 ( int xla ) : bool
jj_2_4 ( int xla ) : bool
jj_2_5 ( int xla ) : bool
jj_2_6 ( int xla ) : bool
jj_2_7 ( int xla ) : bool
jj_2_8 ( int xla ) : bool
jj_2_9 ( int xla ) : bool
jj_3R_100 ( int ge, bool r_91 ) : bool
jj_3R_101 ( ) : bool
jj_3R_19 ( ) : bool
jj_3R_29 ( ) : bool
jj_3R_31 ( ) : bool
jj_3R_33 ( ) : bool
jj_3R_38 ( ) : bool
jj_3R_39 ( ) : bool
jj_3R_40 ( ) : bool
jj_3R_41 ( ) : bool
jj_3R_42 ( ) : bool
jj_3R_50 ( bool b ) : bool
jj_3R_51 ( ) : bool
jj_3R_52 ( ) : bool
jj_3R_54 ( ) : bool
jj_3R_55 ( ) : bool
jj_3R_56 ( ) : bool
jj_3R_57 ( ) : bool
jj_3R_58 ( ) : bool
jj_3R_59 ( ) : bool
jj_3R_60 ( ) : bool
jj_3R_77 ( ) : bool
jj_3R_81 ( ) : bool
jj_3R_82 ( ) : bool
jj_3R_84 ( ) : bool
jj_3R_86 ( ) : bool
jj_3R_89 ( ) : bool
jj_3R_90 ( ) : bool
jj_3R_91 ( ) : bool
jj_3R_92 ( ) : bool
jj_3R_95 ( ) : bool
jj_3R_96 ( ) : bool
jj_3_10 ( ) : bool
jj_3_11 ( ) : bool
jj_3_12 ( ) : bool
jj_3_2 ( ) : bool
jj_3_3 ( ) : bool
jj_3_4 ( ) : bool
jj_3_7 ( ) : bool
jj_ntk ( ) : int

Method Details

AdditiveExpression() public method

public AdditiveExpression ( ) : void
return void

Assignment() public method

public Assignment ( ) : void
return void

Comment() public method

public Comment ( ) : void
return void

ConditionalAndExpression() public method

public ConditionalAndExpression ( ) : void
return void

ConditionalOrExpression() public method

public ConditionalOrExpression ( ) : void
return void

Directive() public method

Supports the Pluggable Directives #foo( arg+ )
public Directive ( ) : NVelocity.Runtime.Parser.Node.SimpleNode
return NVelocity.Runtime.Parser.Node.SimpleNode

DirectiveArg() public method

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()
public DirectiveArg ( ) : void
return void

ElseIfStatement() public method

public ElseIfStatement ( ) : void
return void

ElseStatement() public method

public ElseStatement ( ) : void
return void

EqualityExpression() public method

public EqualityExpression ( ) : void
return void

Escape() public method

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 #<directive> and here we don't. We just want the escapes to render correctly
public Escape ( ) : void
return void

EscapedDirective() public method

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.
public EscapedDirective ( ) : void
return void

Expression() public method

public Expression ( ) : void
return void

False() public method

public False ( ) : void
return void

GenerateParseException() public method

public GenerateParseException ( ) : ParseException
return ParseException

GetToken() public method

public GetToken ( int index ) : Token
index int
return Token

Identifier() public method

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 *
public Identifier ( ) : void
return void

IfStatement() public method

public IfStatement ( ) : void
return void

IntegerRange() public method

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

IsDirective() public method

This method finds out of the directive exists in the directives Hashtable.
public IsDirective ( String directive ) : bool
directive String
return bool

Method() public method

This method has yet to be fully implemented but will allow arbitrarily nested method calls
public Method ( ) : void
return void

MultiplicativeExpression() public method

public MultiplicativeExpression ( ) : void
return void

NumberLiteral() public method

public NumberLiteral ( ) : void
return void

ObjectArray() public method

public ObjectArray ( ) : void
return void

Parameter() public method

This method has yet to be fully implemented but will allow arbitrarily nested method calls
public Parameter ( ) : void
return void

Parse() public method

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.
public Parse ( TextReader reader, String templateName ) : NVelocity.Runtime.Parser.Node.SimpleNode
reader System.IO.TextReader
templateName String
return NVelocity.Runtime.Parser.Node.SimpleNode

Parser() public method

public Parser ( ICharStream stream ) : System
stream ICharStream
return System

Parser() public method

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.
public Parser ( IRuntimeServices rs ) : System
rs IRuntimeServices
return System

Parser() public method

public Parser ( ParserTokenManager tm ) : System
tm ParserTokenManager
return System

PrimaryExpression() public method

public PrimaryExpression ( ) : void
return void

Process() public method

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
public Process ( ) : NVelocity.Runtime.Parser.Node.SimpleNode
return NVelocity.Runtime.Parser.Node.SimpleNode

ReInit() public method

public ReInit ( ICharStream stream ) : void
stream ICharStream
return void

ReInit() public method

public ReInit ( ParserTokenManager tm ) : void
tm ParserTokenManager
return void

Reference() public method

public Reference ( ) : void
return void

RelationalExpression() public method

public RelationalExpression ( ) : void
return void

SetDirective() public method

Currently support both types of set : #set( expr ) #set expr
public SetDirective ( ) : void
return void

Statement() public method

These are the types of statements that are acceptable in Velocity templates.
public Statement ( ) : void
return void

StopStatement() public method

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.
public StopStatement ( ) : void
return void

StringLiteral() public method

public StringLiteral ( ) : void
return void

Text() public method

This method is responsible for allowing all non-grammar text to pass through unscathed.
public Text ( ) : void
return void

True() public method

public True ( ) : void
return void

UnaryExpression() public method

public UnaryExpression ( ) : void
return void

Word() public method

public Word ( ) : void
return void

Property Details

directiveStack protected_oe property

protected Stack directiveStack
return Stack

lookingAhead public_oe property

public bool lookingAhead
return bool

token public_oe property

public Token,NVelocity.Runtime.Parser token
return Token

token_source public_oe property

public ParserTokenManager,NVelocity.Runtime.Parser token_source
return ParserTokenManager