Class Parser
java.lang.Object
org.apache.velocity.runtime.parser.Parser
- All Implemented Interfaces:
ParserConstants
,ParserTreeConstants
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.
- Version:
- $Id: Parser.java 928463 2010-03-28 18:11:34Z nbubna $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionName of current template we are parsing.private final Parser.JJCalls[]
private int
private List
private int[]
private int
private int
private int
private int
private final int[]
private static int[]
private static int[]
private static int[]
private Token
private int[]
private final Parser.LookaheadSuccess
Next token.private int
private boolean
private Token
protected JJTParserState
private Map
Keep track of defined macros, used for escape processingprivate RuntimeServices
boolean
Set to true if the property RuntimeConstants.RUNTIME_REFERENCES_STRICT_ESCAPE is set to trueCurrent token.Generated Token Manager.(package private) VelocityCharStream
Fields inherited from interface org.apache.velocity.runtime.parser.ParserConstants
ALPHA_CHAR, ALPHANUM_CHAR, BRACKETED_WORD, COLON, COMMA, DEFAULT, DIGIT, DIRECTIVE, DIRECTIVE_CHAR, DIRECTIVE_TERMINATOR, DIVIDE, DOLLAR, DOLLARBANG, DOT, DOUBLE_ESCAPE, DOUBLEDOT, ELSE_DIRECTIVE, ELSEIF_DIRECTIVE, EMPTY_INDEX, END, EOF, EQUALS, ESCAPE, ESCAPE_DIRECTIVE, EXPONENT, FALSE, FLOATING_POINT_LITERAL, FORMAL_COMMENT, HASH, IDENTIFIER, IDENTIFIER_CHAR, IF_DIRECTIVE, IN_FORMAL_COMMENT, IN_MULTI_LINE_COMMENT, IN_SINGLE_LINE_COMMENT, IN_TEXTBLOCK, INDEX_LBRACKET, INDEX_RBRACKET, INTEGER_LITERAL, LBRACKET, LCURLY, LEFT_CURLEY, LETTER, LOGICAL_AND, LOGICAL_EQUALS, LOGICAL_GE, LOGICAL_GT, LOGICAL_LE, LOGICAL_LT, LOGICAL_NOT, LOGICAL_NOT_EQUALS, LOGICAL_OR, LPAREN, MINUS, MODULUS, MULTI_LINE_COMMENT, MULTIPLY, NEWLINE, PLUS, PRE_DIRECTIVE, RBRACKET, RCURLY, REFERENCE, REFERENCE_TERMINATOR, REFINDEX, REFMOD, REFMOD2, REFMOD2_RPAREN, REFMODIFIER, RIGHT_CURLEY, RPAREN, SET_DIRECTIVE, SINGLE_LINE_COMMENT, SINGLE_LINE_COMMENT_START, STRING_LITERAL, TEXT, TEXTBLOCK, tokenImage, TRUE, WHITESPACE, WORD
Fields inherited from interface org.apache.velocity.runtime.parser.ParserTreeConstants
JJTADDNODE, JJTANDNODE, JJTASSIGNMENT, JJTBLOCK, JJTCOMMENT, JJTDIRECTIVE, JJTDIVNODE, JJTELSEIFSTATEMENT, JJTELSESTATEMENT, JJTEQNODE, JJTESCAPE, JJTESCAPEDDIRECTIVE, JJTEXPRESSION, JJTFALSE, JJTFLOATINGPOINTLITERAL, JJTGENODE, JJTGTNODE, JJTIDENTIFIER, JJTIFSTATEMENT, JJTINDEX, JJTINTEGERLITERAL, JJTINTEGERRANGE, JJTLENODE, JJTLTNODE, JJTMAP, JJTMETHOD, JJTMODNODE, JJTMULNODE, JJTNENODE, jjtNodeName, JJTNOTNODE, JJTOBJECTARRAY, JJTORNODE, JJTPROCESS, JJTREFERENCE, JJTSETDIRECTIVE, JJTSTRINGLITERAL, JJTSUBTRACTNODE, JJTTEXT, JJTTEXTBLOCK, JJTTRUE, JJTVOID, JJTWORD
-
Constructor Summary
ConstructorsConstructorDescriptionParser
(CharStream stream) Constructor with user supplied CharStream.Constructor with generated Token Manager.This constructor was added to allow the re-use of parsers. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
final void
final void
Comment()
final void
final void
final SimpleNode
Supports the Pluggable Directives #foo( arg+ )final int
Supports the arguments for the Pluggable Directivesfinal void
Disable tracing.final void
final void
final void
Enable tracing.final void
final void
Escape()
Used to catch and process escape sequences in grammatical constructs as escapes outside of VTL are just characters.private String
escapedDirective
(String strImage) Produces a processed output for an escaped control or pluggable directivefinal 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.final void
final void
False()
final void
Generate ParseException.getDirective
(String directive) This method gets a Directive from the directives Hashtablefinal Token
Get the next Token.final Token
getToken
(int index) Get the specific Token.final void
This method corresponds to variable references in Velocity templates.final void
final void
Index()
final void
A Simplified parameter more suitable for an index position: $foo[$index]final void
final void
supports the [n..m] vector generator for use in the #foreach() to generate measured ranges w/o needing explicit support from the app/servletboolean
isDirective
(String directive) This method finds out of the directive exists in the directives Map.private boolean
Check whether there is a left parenthesis with leading optional whitespaces.private boolean
jj_2_1
(int xla) private boolean
jj_2_10
(int xla) private boolean
jj_2_11
(int xla) private boolean
jj_2_12
(int xla) private boolean
jj_2_2
(int xla) private boolean
jj_2_3
(int xla) private boolean
jj_2_4
(int xla) private boolean
jj_2_5
(int xla) private boolean
jj_2_6
(int xla) private boolean
jj_2_7
(int xla) private boolean
jj_2_8
(int xla) private boolean
jj_2_9
(int xla) private boolean
jj_3_1()
private boolean
jj_3_10()
private boolean
jj_3_11()
private boolean
jj_3_12()
private boolean
jj_3_2()
private boolean
jj_3_3()
private boolean
jj_3_4()
private boolean
jj_3_5()
private boolean
jj_3_6()
private boolean
jj_3_7()
private boolean
jj_3_8()
private boolean
jj_3_9()
private boolean
private boolean
private boolean
jj_3R_24()
private boolean
jj_3R_25()
private boolean
jj_3R_26()
private boolean
jj_3R_27()
private boolean
jj_3R_28()
private boolean
jj_3R_29()
private boolean
jj_3R_30()
private boolean
jj_3R_31()
private boolean
jj_3R_32()
private boolean
jj_3R_33()
private boolean
jj_3R_34()
private boolean
jj_3R_35()
private boolean
jj_3R_36()
private boolean
jj_3R_37()
private boolean
jj_3R_38()
private boolean
jj_3R_39()
private boolean
jj_3R_40()
private boolean
jj_3R_41()
private boolean
jj_3R_42()
private boolean
jj_3R_43()
private boolean
jj_3R_44()
private boolean
jj_3R_45()
private boolean
jj_3R_46()
private boolean
jj_3R_47()
private boolean
jj_3R_48()
private boolean
jj_3R_49()
private boolean
jj_3R_50()
private boolean
jj_3R_51()
private boolean
jj_3R_52()
private boolean
jj_3R_53()
private boolean
jj_3R_54()
private boolean
jj_3R_55()
private boolean
jj_3R_56()
private boolean
jj_3R_57()
private boolean
jj_3R_58()
private boolean
jj_3R_59()
private boolean
jj_3R_60()
private boolean
jj_3R_61()
private boolean
jj_3R_62()
private boolean
jj_3R_63()
private boolean
jj_3R_64()
private boolean
jj_3R_65()
private boolean
jj_3R_66()
private boolean
jj_3R_67()
private boolean
jj_3R_68()
private boolean
jj_3R_69()
private boolean
jj_3R_70()
private boolean
jj_3R_71()
private boolean
jj_3R_72()
private boolean
jj_3R_73()
private boolean
jj_3R_74()
private boolean
jj_3R_75()
private boolean
jj_3R_76()
private boolean
jj_3R_77()
private boolean
jj_3R_78()
private boolean
jj_3R_79()
private boolean
jj_3R_80()
private boolean
jj_3R_81()
private boolean
jj_3R_82()
private boolean
jj_3R_83()
private boolean
jj_3R_84()
private boolean
jj_3R_85()
private boolean
jj_3R_86()
private boolean
jj_3R_87()
private boolean
jj_3R_88()
private boolean
jj_3R_89()
private boolean
jj_3R_90()
private boolean
jj_3R_91()
private boolean
jj_3R_92()
private boolean
jj_3R_93()
private boolean
jj_3R_94()
private boolean
jj_3R_95()
private boolean
jj_3R_96()
private boolean
jj_3R_97()
private boolean
jj_3R_98()
private boolean
jj_3R_99()
private void
jj_add_error_token
(int kind, int pos) private Token
jj_consume_token
(int kind) private static void
private static void
private static void
private int
jj_ntk()
private void
private void
jj_save
(int index, int xla) private boolean
jj_scan_token
(int kind) final void
Map()
for creating a map in a #set #set($foo = {$foo : $bar, $blargh : $thingy})final void
Method()
This method has yet to be fully implemented but will allow arbitrarily nested method callsfinal void
final void
final void
This method has yet to be fully implemented but will allow arbitrarily nested method callsThis was also added to allow parsers to be re-usable.final void
final SimpleNode
process()
This method is what starts the whole parsing process.final void
void
ReInit
(CharStream stream) Reinitialise.void
Reinitialise.final void
final void
Currently support both types of set : #set( expr ) #set exprfinal void
These are the types of statements that are acceptable in Velocity templates.final void
final void
Text()
This method is responsible for allowing all non-grammar text to pass through unscathed.final void
final void
True()
final void
final void
Word()
-
Field Details
-
jjtree
-
macroNames
Keep track of defined macros, used for escape processing -
currentTemplateName
Name of current template we are parsing. Passed to us in parse() -
strictEscape
public boolean strictEscapeSet to true if the property RuntimeConstants.RUNTIME_REFERENCES_STRICT_ESCAPE is set to true -
velcharstream
VelocityCharStream velcharstream -
rsvc
-
token_source
Generated Token Manager. -
token
Current token. -
jj_nt
Next token. -
jj_ntk
private int jj_ntk -
jj_scanpos
-
jj_lastpos
-
jj_la
private int jj_la -
jj_gen
private int jj_gen -
jj_la1
private final int[] jj_la1 -
jj_la1_0
private static int[] jj_la1_0 -
jj_la1_1
private static int[] jj_la1_1 -
jj_la1_2
private static int[] jj_la1_2 -
jj_2_rtns
-
jj_rescan
private boolean jj_rescan -
jj_gc
private int jj_gc -
jj_ls
-
jj_expentries
-
jj_expentry
private int[] jj_expentry -
jj_kind
private int jj_kind -
jj_lasttokens
private int[] jj_lasttokens -
jj_endpos
private int jj_endpos
-
-
Constructor Details
-
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
Constructor with user supplied CharStream. -
Parser
Constructor with generated Token Manager.
-
-
Method Details
-
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.- Throws:
ParseException
-
getDirective
This method gets a Directive from the directives Hashtable -
isDirective
This method finds out of the directive exists in the directives Map. -
escapedDirective
Produces a processed output for an escaped control or pluggable directive -
isLeftParenthesis
private boolean isLeftParenthesis()Check whether there is a left parenthesis with leading optional whitespaces. This method is used in the semantic look ahead of Directive method. This is done in code instead of as a production for simplicity and efficiency. -
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- Throws:
ParseException
-
Statement
These are the types of statements that are acceptable in Velocity templates.- Throws:
ParseException
-
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.- Throws:
ParseException
-
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 - Throws:
ParseException
-
Comment
- Throws:
ParseException
-
Textblock
- Throws:
ParseException
-
FloatingPointLiteral
- Throws:
ParseException
-
IntegerLiteral
- Throws:
ParseException
-
StringLiteral
- Throws:
ParseException
-
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- Throws:
ParseException
-
Word
- Throws:
ParseException
-
DirectiveArg
Supports the arguments for the Pluggable Directives- Throws:
ParseException
-
Directive
Supports the Pluggable Directives #foo( arg+ )- Throws:
ParseException
-
Map
for creating a map in a #set #set($foo = {$foo : $bar, $blargh : $thingy})- Throws:
ParseException
-
ObjectArray
- Throws:
ParseException
-
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- Throws:
ParseException
-
IndexParameter
A Simplified parameter more suitable for an index position: $foo[$index]- Throws:
ParseException
-
Parameter
This method has yet to be fully implemented but will allow arbitrarily nested method calls- Throws:
ParseException
-
Method
This method has yet to be fully implemented but will allow arbitrarily nested method calls- Throws:
ParseException
-
Index
- Throws:
ParseException
-
Reference
- Throws:
ParseException
-
True
- Throws:
ParseException
-
False
- Throws:
ParseException
-
Text
This method is responsible for allowing all non-grammar text to pass through unscathed.- Throws:
ParseException
-
IfStatement
- Throws:
ParseException
-
ElseStatement
- Throws:
ParseException
-
ElseIfStatement
- Throws:
ParseException
-
SetDirective
Currently support both types of set : #set( expr ) #set expr- Throws:
ParseException
-
Expression
- Throws:
ParseException
-
Assignment
- Throws:
ParseException
-
ConditionalOrExpression
- Throws:
ParseException
-
ConditionalAndExpression
- Throws:
ParseException
-
EqualityExpression
- Throws:
ParseException
-
RelationalExpression
- Throws:
ParseException
-
AdditiveExpression
- Throws:
ParseException
-
MultiplicativeExpression
- Throws:
ParseException
-
UnaryExpression
- Throws:
ParseException
-
PrimaryExpression
- Throws:
ParseException
-
jj_2_1
private boolean jj_2_1(int xla) -
jj_2_2
private boolean jj_2_2(int xla) -
jj_2_3
private boolean jj_2_3(int xla) -
jj_2_4
private boolean jj_2_4(int xla) -
jj_2_5
private boolean jj_2_5(int xla) -
jj_2_6
private boolean jj_2_6(int xla) -
jj_2_7
private boolean jj_2_7(int xla) -
jj_2_8
private boolean jj_2_8(int xla) -
jj_2_9
private boolean jj_2_9(int xla) -
jj_2_10
private boolean jj_2_10(int xla) -
jj_2_11
private boolean jj_2_11(int xla) -
jj_2_12
private boolean jj_2_12(int xla) -
jj_3_7
private boolean jj_3_7() -
jj_3R_61
private boolean jj_3R_61() -
jj_3R_39
private boolean jj_3R_39() -
jj_3R_40
private boolean jj_3R_40() -
jj_3R_88
private boolean jj_3R_88() -
jj_3R_87
private boolean jj_3R_87() -
jj_3R_86
private boolean jj_3R_86() -
jj_3R_38
private boolean jj_3R_38() -
jj_3R_85
private boolean jj_3R_85() -
jj_3R_84
private boolean jj_3R_84() -
jj_3R_83
private boolean jj_3R_83() -
jj_3R_67
private boolean jj_3R_67() -
jj_3R_24
private boolean jj_3R_24() -
jj_3R_82
private boolean jj_3R_82() -
jj_3R_81
private boolean jj_3R_81() -
jj_3R_80
private boolean jj_3R_80() -
jj_3R_79
private boolean jj_3R_79() -
jj_3R_72
private boolean jj_3R_72() -
jj_3R_73
private boolean jj_3R_73() -
jj_3R_35
private boolean jj_3R_35() -
jj_3_11
private boolean jj_3_11() -
jj_3R_62
private boolean jj_3R_62() -
jj_3_6
private boolean jj_3_6() -
jj_3R_33
private boolean jj_3R_33() -
jj_3R_59
private boolean jj_3R_59() -
jj_3R_58
private boolean jj_3R_58() -
jj_3R_57
private boolean jj_3R_57() -
jj_3R_56
private boolean jj_3R_56() -
jj_3R_55
private boolean jj_3R_55() -
jj_3R_54
private boolean jj_3R_54() -
jj_3R_53
private boolean jj_3R_53() -
jj_3R_52
private boolean jj_3R_52() -
jj_3R_51
private boolean jj_3R_51() -
jj_3R_29
private boolean jj_3R_29() -
jj_3R_100
private boolean jj_3R_100() -
jj_3R_96
private boolean jj_3R_96() -
jj_3R_95
private boolean jj_3R_95() -
jj_3R_94
private boolean jj_3R_94() -
jj_3R_93
private boolean jj_3R_93() -
jj_3R_92
private boolean jj_3R_92() -
jj_3R_99
private boolean jj_3R_99() -
jj_3_2
private boolean jj_3_2() -
jj_3R_76
private boolean jj_3R_76() -
jj_3R_101
private boolean jj_3R_101() -
jj_3R_91
private boolean jj_3R_91() -
jj_3R_98
private boolean jj_3R_98() -
jj_3R_75
private boolean jj_3R_75() -
jj_3R_78
private boolean jj_3R_78() -
jj_3R_66
private boolean jj_3R_66() -
jj_3R_26
private boolean jj_3R_26() -
jj_3R_69
private boolean jj_3R_69() -
jj_3R_77
private boolean jj_3R_77() -
jj_3_5
private boolean jj_3_5() -
jj_3R_25
private boolean jj_3R_25() -
jj_3R_68
private boolean jj_3R_68() -
jj_3_1
private boolean jj_3_1() -
jj_3R_50
private boolean jj_3R_50() -
jj_3R_90
private boolean jj_3R_90() -
jj_3R_49
private boolean jj_3R_49() -
jj_3_3
private boolean jj_3_3() -
jj_3R_48
private boolean jj_3R_48() -
jj_3R_89
private boolean jj_3R_89() -
jj_3R_47
private boolean jj_3R_47() -
jj_3R_46
private boolean jj_3R_46() -
jj_3R_45
private boolean jj_3R_45() -
jj_3R_34
private boolean jj_3R_34() -
jj_3R_37
private boolean jj_3R_37() -
jj_3R_32
private boolean jj_3R_32() -
jj_3R_44
private boolean jj_3R_44() -
jj_3R_27
private boolean jj_3R_27() -
jj_3R_43
private boolean jj_3R_43() -
jj_3R_42
private boolean jj_3R_42() -
jj_3R_36
private boolean jj_3R_36() -
jj_3R_41
private boolean jj_3R_41() -
jj_3R_28
private boolean jj_3R_28() -
jj_3_10
private boolean jj_3_10() -
jj_3R_64
private boolean jj_3R_64() -
jj_3R_31
private boolean jj_3R_31() -
jj_3_8
private boolean jj_3_8() -
jj_3R_74
private boolean jj_3R_74() -
jj_3R_60
private boolean jj_3R_60() -
jj_3R_97
private boolean jj_3R_97() -
jj_3R_71
private boolean jj_3R_71() -
jj_3_4
private boolean jj_3_4() -
jj_3R_63
private boolean jj_3R_63() -
jj_3R_30
private boolean jj_3R_30() -
jj_3R_70
private boolean jj_3R_70() -
jj_3_9
private boolean jj_3_9() -
jj_3_12
private boolean jj_3_12() -
jj_3R_65
private boolean jj_3R_65() -
jj_la1_init_0
private static void jj_la1_init_0() -
jj_la1_init_1
private static void jj_la1_init_1() -
jj_la1_init_2
private static void jj_la1_init_2() -
ReInit
Reinitialise. -
ReInit
Reinitialise. -
jj_consume_token
- Throws:
ParseException
-
jj_scan_token
private boolean jj_scan_token(int kind) -
getNextToken
Get the next Token. -
getToken
Get the specific Token. -
jj_ntk
private int jj_ntk() -
jj_add_error_token
private void jj_add_error_token(int kind, int pos) -
generateParseException
Generate ParseException. -
enable_tracing
public final void enable_tracing()Enable tracing. -
disable_tracing
public final void disable_tracing()Disable tracing. -
jj_rescan_token
private void jj_rescan_token() -
jj_save
private void jj_save(int index, int xla)
-