2017-02-14 15:49:54 -08:00
|
|
|
options {
|
2017-02-14 14:31:07 -08:00
|
|
|
USER_CHAR_STREAM = true;
|
|
|
|
NODE_USES_PARSER=true;
|
|
|
|
UNICODE_INPUT=true;
|
2017-02-14 15:49:54 -08:00
|
|
|
FORCE_LA_CHECK = false;
|
|
|
|
IGNORE_CASE = true;
|
|
|
|
STATIC = false;
|
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
MULTI=true;
|
|
|
|
VISITOR=true;
|
2017-02-14 15:49:54 -08:00
|
|
|
}
|
2017-02-14 14:31:07 -08:00
|
|
|
|
2020-02-15 09:15:36 +01:00
|
|
|
PARSER_BEGIN(VfParserImpl)
|
2024-02-23 15:47:37 +01:00
|
|
|
package net.sourceforge.pmd.lang.visualforce.ast;
|
2017-02-14 14:31:07 -08:00
|
|
|
|
2024-07-25 12:23:04 +02:00
|
|
|
/**
|
|
|
|
* @deprecated Since 7.5.0. VfParserImpl should have been package private because this is an implementation class
|
|
|
|
* that should not be used directly.
|
|
|
|
*/
|
|
|
|
@Deprecated
|
2020-02-15 09:15:36 +01:00
|
|
|
public class VfParserImpl {
|
2017-02-14 14:31:07 -08:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Counter used to keep track of unclosed tags
|
|
|
|
*/
|
|
|
|
private OpenTagRegister tagRegister = new OpenTagRegister();
|
2017-02-14 15:49:54 -08:00
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
/**
|
|
|
|
* Return the contents of a quote.
|
|
|
|
* @param quote String - starting and ending with " or '
|
|
|
|
* @return String a substring of quote: quote without the first and list
|
|
|
|
* character.
|
|
|
|
*/
|
|
|
|
private static String quoteContent(String quote) {
|
|
|
|
return quote.substring(1, quote.length()-1);
|
|
|
|
}
|
2017-02-14 15:49:54 -08:00
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
/**
|
|
|
|
* Return the contents of a EL expression.
|
|
|
|
* @param expression String - starting with ${ or #{ and ending with }
|
|
|
|
* @return String a substring of expression: expression without the first two and list
|
|
|
|
* characters.
|
|
|
|
*/
|
|
|
|
private static String expressionContent(String expression) {
|
|
|
|
return expression.substring(2, expression.length()-1).trim();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-15 09:15:36 +01:00
|
|
|
PARSER_END(VfParserImpl)
|
2017-02-14 14:31:07 -08:00
|
|
|
|
2017-02-14 15:49:54 -08:00
|
|
|
/** ************************* VF LEXICON **************************** */
|
2017-02-14 14:31:07 -08:00
|
|
|
|
|
|
|
<*> TOKEN :
|
|
|
|
{
|
|
|
|
<#ALPHA_CHAR: [
|
|
|
|
"\u0024",
|
|
|
|
"\u0041"-"\u005a",
|
|
|
|
"\u005f",
|
|
|
|
"\u0061"-"\u007a",
|
|
|
|
"\u00c0"-"\u00d6",
|
|
|
|
"\u00d8"-"\u00f6",
|
|
|
|
"\u00f8"-"\u00ff"
|
|
|
|
] >
|
|
|
|
| <#NUM_CHAR: [
|
|
|
|
"\u0030"-"\u0039"
|
|
|
|
] >
|
|
|
|
| <#ALPHANUM_CHAR: ( <ALPHA_CHAR> | <NUM_CHAR> ) >
|
2017-02-21 12:59:52 -08:00
|
|
|
| <#IDENTIFIER_CHAR: ( <ALPHANUM_CHAR> | [ "_", "-", ":" ] ) >
|
2017-02-14 14:31:07 -08:00
|
|
|
| <#IDENTIFIER: <ALPHA_CHAR> (<IDENTIFIER_CHAR>)* >
|
2020-09-22 10:29:47 -07:00
|
|
|
| <#IDENTIFIER_DOTTED: <IDENTIFIER> (<DOT> <IDENTIFIER>)+ >
|
2017-02-14 14:31:07 -08:00
|
|
|
| <#XMLNAME: (<ALPHA_CHAR> | "_" | ":") (<IDENTIFIER_CHAR>)* >
|
2017-02-14 15:49:54 -08:00
|
|
|
| <#QUOTED_STRING_NO_BREAKS: ( "'" ( ~["'", "\r", "\n"] )* "'" )
|
2017-02-14 14:31:07 -08:00
|
|
|
| ( "\"" ( ~["\"", "\r", "\n"] )* "\"" ) >
|
2017-04-11 13:42:06 -07:00
|
|
|
| <#QUOTED_STRING: ( "'" ( ~["'"] )* "'" ) | ( "\"" ( ~["\""] | "\\\"" )* "\"" ) >
|
2017-02-14 14:31:07 -08:00
|
|
|
| <#WHITESPACE: ( " " | "\t" | "\n" | "\r" ) >
|
|
|
|
| <#NEWLINE: ( "\r\n" | "\r" | "\n" ) >
|
|
|
|
| <#QUOTE: ( "'" | "\"" )>
|
2017-02-16 15:34:38 -08:00
|
|
|
| <#NO_WHITESPACE_OR_LT_OR_DOLLAR: (~[" ", "\t", "\n", "\r", "<"])>
|
2017-02-14 14:31:07 -08:00
|
|
|
| <#NO_BANG: (~["!"])>
|
|
|
|
| <#OPENBRACE: ("{") >
|
|
|
|
| <#NO_LT_OR_OPENBRACE: (~["<","{"])>
|
|
|
|
| <#NO_ENDTAG_START: (~["<"]~["/"]) >
|
|
|
|
| <#TEXT_IN_EL: (~["}", "'", "\""])+ >
|
2017-02-21 12:59:52 -08:00
|
|
|
| <#CLOSEBRACE: ("}")>
|
|
|
|
| <#DOT: "." >
|
2017-04-12 09:42:35 -07:00
|
|
|
| <#COMMNT_START: "/*" >
|
|
|
|
| <#COMMNT_END: "*/" >
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<DEFAULT> SKIP :
|
|
|
|
{
|
|
|
|
< (<WHITESPACE>)+ >
|
|
|
|
}
|
|
|
|
|
2017-04-11 13:42:06 -07:00
|
|
|
<AfterTagState, InTagState, HtmlScriptContentState, ElTagState, ElAttribTagStateSQ, ElAttribTagStateDQ, ElInScriptState > SPECIAL_TOKEN:
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
|
|
|
< (<WHITESPACE>)+ >
|
|
|
|
}
|
|
|
|
|
2017-02-14 15:49:54 -08:00
|
|
|
<DEFAULT, AfterTagState> TOKEN :
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
|
|
|
<TAG_START: "<" > : StartTagState
|
|
|
|
| <ENDTAG_START: "</" > : StartTagState
|
|
|
|
| <COMMENT_START: "<!--" > : CommentState
|
|
|
|
| <DECL_START: "<?" > : StartTagState
|
|
|
|
| <DOCTYPE_DECL_START: "<!DOCTYPE" > : DocTypeState
|
|
|
|
| <CDATA_START: "<![CDATA[" > : CDataState
|
|
|
|
| <HTML_SCRIPT_START: "<script" > : InTagState
|
2017-02-16 14:32:36 -08:00
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
<AfterTagState> TOKEN :
|
2017-02-14 15:49:54 -08:00
|
|
|
{
|
2017-02-21 12:59:52 -08:00
|
|
|
<EL_EXPRESSION: "{!" > : ElTagState
|
2017-02-14 14:31:07 -08:00
|
|
|
| <UNPARSED_TEXT: ( <NO_LT_OR_OPENBRACE>|<OPENBRACE><NO_BANG>)+ >
|
|
|
|
}
|
|
|
|
|
2017-03-01 10:54:35 -08:00
|
|
|
<ElTagState, ElAttribTagStateSQ, ElAttribTagStateDQ, ElAttribTagStateNQ, ElInScriptState> TOKEN :
|
2017-02-21 12:59:52 -08:00
|
|
|
{
|
2017-04-11 16:34:01 -07:00
|
|
|
<NULL: "null" >
|
2017-02-21 12:59:52 -08:00
|
|
|
| <TRUE: "true" >
|
|
|
|
| <FALSE: "false" >
|
|
|
|
| <LPAREN: "(" >
|
|
|
|
| <RPAREN: ")" >
|
|
|
|
| <COMMA: "," >
|
|
|
|
| <LSQUARE: "[" >
|
|
|
|
| <RSQUARE: "]" >
|
|
|
|
| <EXP_DOT: <DOT> >
|
|
|
|
| <AMP_AMP: "&&" >
|
|
|
|
| <CONCATEQ: "&=">
|
|
|
|
| <CONCAT: "&" >
|
|
|
|
| <POW: "^" >
|
|
|
|
| <DIVEQ: "/=" >
|
|
|
|
| <DIV: "/" >
|
|
|
|
| <PLUSEQ: "+=" >
|
|
|
|
| <PLUS: "+" >
|
|
|
|
| <MINUSEQ: "-=">
|
|
|
|
| <MINUS: "-" >
|
|
|
|
| <MULEQ: "*=" >
|
|
|
|
| <MUL: "*" >
|
|
|
|
| <PERCENT: "%">
|
|
|
|
| <DOUBLE_EQ: "==" >
|
|
|
|
| <EQ: "=" >
|
|
|
|
| <NOT_EQ: ("<>" | "!=" ) >
|
|
|
|
| <LE: "<=" >
|
|
|
|
| <GE: ">=" >
|
|
|
|
| <LT: "<" >
|
|
|
|
| <GT: ">" >
|
2017-04-26 15:35:53 -07:00
|
|
|
| <EXCL: ("!"|"~"|"NOT") >
|
2017-02-21 12:59:52 -08:00
|
|
|
| <PIPE_PIPE: "||" >
|
|
|
|
| <STRING_LITERAL: <QUOTED_STRING> >
|
2017-02-21 16:29:45 -08:00
|
|
|
| <DIGITS: (<NUM_CHAR>)+ (<DOT> (<NUM_CHAR>)+)? >
|
2017-02-21 12:59:52 -08:00
|
|
|
| <IDENTIFIER_EL: <IDENTIFIER> >
|
|
|
|
| <COLON: ":">
|
|
|
|
| <QQ: "?">
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
<ElTagState> TOKEN :
|
|
|
|
{
|
|
|
|
<END_OF_EL: (<WHITESPACES>)? <CLOSEBRACE> > : AfterTagState
|
|
|
|
}
|
|
|
|
|
|
|
|
<ElAttribTagStateSQ> TOKEN :
|
|
|
|
{
|
2020-02-17 08:26:28 +01:00
|
|
|
<COMMENT_OPEN_SQ: <COMMNT_START> > : InlineCommentStateSQ
|
2017-04-12 09:42:35 -07:00
|
|
|
| <END_OF_EL_ATTRIB_SQ: (<WHITESPACES>)? <CLOSEBRACE> > : AttrValueBetweenSingleQuotesState
|
2017-02-21 12:59:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
<ElAttribTagStateDQ> TOKEN :
|
2020-02-17 08:26:28 +01:00
|
|
|
{
|
|
|
|
<COMMENT_OPEN_DQ: <COMMNT_START> > : InlineCommentStateDQ
|
2017-04-12 09:42:35 -07:00
|
|
|
| <END_OF_EL_ATTRIB_DQ: (<WHITESPACES>)? <CLOSEBRACE> > : AttrValueBetweenDoubleQuotesState
|
2017-02-21 12:59:52 -08:00
|
|
|
}
|
|
|
|
|
2017-02-22 09:47:07 -08:00
|
|
|
<ElAttribTagStateNQ> TOKEN :
|
|
|
|
{
|
2017-04-11 16:34:01 -07:00
|
|
|
<END_OF_EL_ATTRIB_NQ: (<WHITESPACES>)? <CLOSEBRACE> > : AttrValueNoQuotesState
|
2017-02-22 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
2017-03-01 10:54:35 -08:00
|
|
|
<ElInScriptState> TOKEN :
|
|
|
|
{
|
2017-04-12 09:42:35 -07:00
|
|
|
<COMMENT_OPEN_SCRIPT: <COMMNT_START> > : InlineCommentStateScript
|
2017-04-11 16:34:01 -07:00
|
|
|
| <END_OF_EL_SCRIPT: (<WHITESPACES>)? <CLOSEBRACE> > : HtmlScriptContentState
|
2017-03-01 10:54:35 -08:00
|
|
|
}
|
|
|
|
|
2017-02-14 15:49:54 -08:00
|
|
|
<DocTypeState, DocTypeExternalIdState> TOKEN :
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
|
|
|
<WHITESPACES: (<WHITESPACE>)+ >
|
|
|
|
}
|
|
|
|
|
|
|
|
<DocTypeState> TOKEN:
|
|
|
|
{
|
|
|
|
<NAME: (<XMLNAME>) > : DocTypeExternalIdState
|
|
|
|
}
|
|
|
|
|
|
|
|
<DocTypeExternalIdState> TOKEN:
|
|
|
|
{
|
|
|
|
<PUBLIC: "PUBLIC">
|
|
|
|
| <SYSTEM: "SYSTEM">
|
|
|
|
| <DOCTYPE_DECL_END: ">" > : AfterTagState
|
|
|
|
| <QUOTED_LITERAL: (<QUOTED_STRING>) >
|
|
|
|
}
|
|
|
|
|
|
|
|
<CDataState> TOKEN :
|
|
|
|
{
|
|
|
|
<UNPARSED: (~[]) >
|
|
|
|
| <CDATA_END: ("]]>") > : AfterTagState
|
|
|
|
}
|
|
|
|
|
|
|
|
<StartTagState> TOKEN :
|
|
|
|
{
|
|
|
|
<TAG_NAME: <IDENTIFIER> > : InTagState
|
|
|
|
| <LST_ERROR: ~[]> : DEFAULT
|
|
|
|
}
|
|
|
|
|
|
|
|
<InTagState> TOKEN :
|
|
|
|
{
|
2020-09-22 10:29:47 -07:00
|
|
|
<ATTR_NAME: <IDENTIFIER> | <IDENTIFIER_DOTTED> >
|
2017-02-14 14:31:07 -08:00
|
|
|
| <TAG_END: ">" > : AfterTagState
|
|
|
|
| <DECL_END: ("?>" | "!>") > : AfterTagState
|
2017-02-16 15:30:35 -08:00
|
|
|
| <TAG_SLASHEND: ("/>" | "/ >") > : AfterTagState
|
2017-02-14 14:31:07 -08:00
|
|
|
| <ATTR_EQ: "=" > : AttrValueState
|
2017-02-15 11:48:08 -08:00
|
|
|
| <IN_TAG_ERROR: ~[] >
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
<AttrValueState> TOKEN :
|
|
|
|
{
|
2017-02-16 13:08:52 -08:00
|
|
|
<SINGLE_QUOTE: (<WHITESPACES>)? "'"> : AttrValueBetweenSingleQuotesState
|
|
|
|
| <DOUBLE_QUOTE: (<WHITESPACES>)? "\"">: AttrValueBetweenDoubleQuotesState
|
2017-02-22 09:47:07 -08:00
|
|
|
| <NO_QUOTE_NO_WHITESPACE: ~["\"","'"," "] > { input_stream.backup(1);} : AttrValueNoQuotesState
|
2017-02-14 14:31:07 -08:00
|
|
|
| <IN_ATTR_WHITESPACE: [" "] > : InTagState //support for empty attributes
|
|
|
|
}
|
|
|
|
|
2017-02-22 09:47:07 -08:00
|
|
|
<AttrValueNoQuotesState> TOKEN :
|
|
|
|
{
|
|
|
|
<ENDING_WHITESPACE: " " >: InTagState
|
|
|
|
| <EL_EXPRESSION_IN_ATTRIBUTE_NQ: "{!" (<WHITESPACES>)? > : ElAttribTagStateNQ
|
2017-04-11 16:34:01 -07:00
|
|
|
| <UNPARSED_TEXT_NO_WHITESPACE: ( ~["{", " "] | (["{"] ~["!"]) )+ >
|
2017-02-22 09:47:07 -08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
<AttrValueBetweenSingleQuotesState> TOKEN :
|
|
|
|
{
|
|
|
|
<ENDING_SINGLE_QUOTE: "'"> : InTagState
|
2017-02-21 12:59:52 -08:00
|
|
|
| <EL_EXPRESSION_IN_ATTRIBUTE_SQ: "{!" (<WHITESPACES>)? > : ElAttribTagStateSQ
|
2017-02-14 15:49:54 -08:00
|
|
|
| <UNPARSED_TEXT_NO_SINGLE_QUOTES:
|
2017-02-15 11:53:31 -08:00
|
|
|
( (~["{", "'"]) | (["{"] ~["!", "'"]) )+ >
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
<AttrValueBetweenDoubleQuotesState> TOKEN :
|
|
|
|
{
|
2017-04-12 10:54:42 -07:00
|
|
|
<ENDING_DOUBLE_QUOTE: "\""> : InTagState
|
2017-02-21 12:59:52 -08:00
|
|
|
| <EL_EXPRESSION_IN_ATTRIBUTE_DQ: "{!" (<WHITESPACES>)? > : ElAttribTagStateDQ
|
2017-04-12 10:54:42 -07:00
|
|
|
| <UNPARSED_TEXT_NO_DOUBLE_QUOTES:
|
2017-02-15 11:53:31 -08:00
|
|
|
( (~["{", "\""]) | (["{"] ~["!", "\""]) )+ >
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
|
2017-02-14 15:49:54 -08:00
|
|
|
<CommentState> TOKEN :
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
2017-04-11 13:42:06 -07:00
|
|
|
< COMMENT_END: ("--" (" ")* ">" ) > : AfterTagState
|
2017-02-14 14:31:07 -08:00
|
|
|
| < COMMENT_TEXT: (~[]) >
|
|
|
|
}
|
|
|
|
|
2017-04-11 16:34:01 -07:00
|
|
|
<InlineCommentStateScript> TOKEN :
|
|
|
|
{
|
2020-02-17 08:26:28 +01:00
|
|
|
< COMMENT_CLOSE_SCRIPT: (<COMMNT_END>) > : ElInScriptState
|
2017-04-11 16:34:01 -07:00
|
|
|
| < COMMENT_INNER_TEXT_SCRIPT: (~[]) >
|
|
|
|
}
|
|
|
|
|
2017-04-12 09:42:35 -07:00
|
|
|
<InlineCommentStateSQ> TOKEN :
|
|
|
|
{
|
2020-02-17 08:26:28 +01:00
|
|
|
< COMMENT_CLOSE_SQ: (<COMMNT_END>) > : ElAttribTagStateSQ
|
2017-04-12 09:42:35 -07:00
|
|
|
| < COMMENT_INNER_TEXT_SQ: (~[]) >
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<InlineCommentStateDQ> TOKEN :
|
|
|
|
{
|
2020-02-17 08:26:28 +01:00
|
|
|
< COMMENT_CLOSE_DQ: (<COMMNT_END>) > : ElAttribTagStateDQ
|
2017-04-12 09:42:35 -07:00
|
|
|
| < COMMENT_INNER_TEXT_DQ: (~[]) >
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
<HtmlScriptContentState> TOKEN :
|
|
|
|
{
|
2017-03-01 15:44:55 -08:00
|
|
|
<HTML_SCRIPT_END_TAG : "</script>" > : AfterTagState
|
2017-03-01 10:54:35 -08:00
|
|
|
| <EL_EXPRESSION_IN_SCRIPT: "{!" (<WHITESPACES>)? > : ElInScriptState
|
2017-03-01 13:51:07 -08:00
|
|
|
| <HTML_SCRIPT_CONTENT: ( (~["{"]) | (["{"] ~["!"]) ) >
|
2017-02-16 14:32:36 -08:00
|
|
|
}
|
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
/** ************************* VF GRAMMAR **************************** */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The root of the AST of a VF.
|
|
|
|
*/
|
|
|
|
ASTCompilationUnit CompilationUnit() :
|
|
|
|
{}
|
|
|
|
{
|
2017-02-16 15:30:35 -08:00
|
|
|
(Bom())?
|
2017-02-14 14:31:07 -08:00
|
|
|
Prolog()
|
2017-02-14 15:49:54 -08:00
|
|
|
|
|
|
|
Content() <EOF>
|
2017-02-14 14:31:07 -08:00
|
|
|
{ return jjtThis; }
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The optional prolog of a VF, including (xml) declarations and DTD.
|
|
|
|
*/
|
|
|
|
void Prolog() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
(
|
|
|
|
LOOKAHEAD( ( CommentTag() )* Declaration() )
|
|
|
|
( CommentTag() )*
|
|
|
|
Declaration()
|
|
|
|
)?
|
2017-02-14 15:49:54 -08:00
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
(
|
|
|
|
LOOKAHEAD( ( CommentTag() )* DoctypeDeclaration() )
|
|
|
|
( CommentTag() )*
|
|
|
|
DoctypeDeclaration()
|
|
|
|
)?
|
|
|
|
}
|
|
|
|
|
2017-02-16 15:30:35 -08:00
|
|
|
void Bom() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
<BYTE_ORDER_MARK: "\ufeff" >
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
/**
|
|
|
|
* Everything between a start-tag and the corresponding end-tag of an element (if an end tag exists).
|
|
|
|
*/
|
2017-02-21 15:57:57 -08:00
|
|
|
void Content() :
|
2017-02-14 14:31:07 -08:00
|
|
|
{}
|
2017-02-14 15:49:54 -08:00
|
|
|
{
|
2017-02-21 14:45:10 -08:00
|
|
|
( ElOrText() | ContentElement() )*
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A single (non-text) element that can occur between a start-tag and end-tag of an element.
|
2017-02-14 15:49:54 -08:00
|
|
|
*
|
2017-02-14 14:31:07 -08:00
|
|
|
*/
|
|
|
|
void ContentElement() #void :
|
|
|
|
{}
|
|
|
|
{
|
2017-02-14 15:49:54 -08:00
|
|
|
(
|
2017-04-11 13:42:06 -07:00
|
|
|
CommentTag()
|
2017-02-14 15:49:54 -08:00
|
|
|
| Element()
|
|
|
|
| CData()
|
2017-04-11 13:42:06 -07:00
|
|
|
| HtmlScript()
|
2017-02-14 14:31:07 -08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This production groups all characters between two tags, where
|
|
|
|
* tag is an xml-tag "<...>" or CDATA "<![CDATA[...]]>".
|
|
|
|
* Text consists of unparsed text and/or Expression Language expressions.
|
|
|
|
*/
|
2017-02-21 14:45:10 -08:00
|
|
|
void ElOrText() #void :
|
2017-02-21 12:59:52 -08:00
|
|
|
{}
|
2017-02-14 15:49:54 -08:00
|
|
|
{
|
2017-02-21 16:50:34 -08:00
|
|
|
( ElExpression() | Text() )+
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
|
2017-03-01 13:09:35 -08:00
|
|
|
void Text() :
|
2017-02-14 14:31:07 -08:00
|
|
|
{ Token t; }
|
2017-02-14 15:49:54 -08:00
|
|
|
{
|
|
|
|
t = <UNPARSED_TEXT>
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
2017-02-14 15:49:54 -08:00
|
|
|
jjtThis.setImage(t.image);
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-22 09:47:07 -08:00
|
|
|
|
2017-03-01 13:09:35 -08:00
|
|
|
void UnparsedTextNoWhitespace() #Text :
|
2017-02-22 09:47:07 -08:00
|
|
|
{ Token t;}
|
|
|
|
{
|
|
|
|
(
|
|
|
|
t = <UNPARSED_TEXT_NO_WHITESPACE>
|
|
|
|
)
|
|
|
|
{
|
|
|
|
jjtThis.setImage(t.image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
/**
|
|
|
|
* Text that contains no single quotes, and that does not contain the start
|
|
|
|
* of a EL expression.
|
|
|
|
*/
|
2017-03-01 13:09:35 -08:00
|
|
|
void UnparsedTextNoSingleQuotes() #Text :
|
2017-02-14 14:31:07 -08:00
|
|
|
{ Token t; }
|
|
|
|
{
|
2017-02-14 15:49:54 -08:00
|
|
|
t = <UNPARSED_TEXT_NO_SINGLE_QUOTES>
|
|
|
|
{
|
|
|
|
jjtThis.setImage(t.image);
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Text that contains no double quotes, and that does not contain the start
|
|
|
|
* of a EL expression.
|
|
|
|
*/
|
2017-03-01 13:09:35 -08:00
|
|
|
void UnparsedTextNoDoubleQuotes() #Text :
|
2017-02-14 14:31:07 -08:00
|
|
|
{ Token t; }
|
|
|
|
{
|
2017-02-14 15:49:54 -08:00
|
|
|
t = <UNPARSED_TEXT_NO_DOUBLE_QUOTES>
|
|
|
|
{
|
|
|
|
jjtThis.setImage(t.image);
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An EL expression, not within an attribute value.
|
|
|
|
*/
|
2017-02-21 12:59:52 -08:00
|
|
|
void ElExpression() :
|
|
|
|
{}
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
2017-02-21 12:59:52 -08:00
|
|
|
<EL_EXPRESSION>
|
|
|
|
(Expression())+
|
|
|
|
<END_OF_EL>
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
|
2017-02-21 12:59:52 -08:00
|
|
|
void Expression() :
|
|
|
|
{}
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
2017-04-11 16:34:01 -07:00
|
|
|
ConditionalExpression() [ AssignmentOperator() Expression() ]
|
2017-04-12 09:42:35 -07:00
|
|
|
| CommentExpression() ( ConditionalExpression() | CommentExpression() )*
|
|
|
|
| ELDQCommentExpression() ( ConditionalExpression() | ELDQCommentExpression() )*
|
|
|
|
| ELSQCommentExpression() ( ConditionalExpression() | ELSQCommentExpression() )*
|
|
|
|
|
2017-02-21 12:59:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AssignmentOperator() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
<MULEQ> | <DIVEQ> | <CONCATEQ> | <PLUSEQ> | <MINUSEQ> | <EQ>
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConditionalExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
ConditionalOrExpression() [ <QQ> Expression() <COLON> ConditionalExpression() ]
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConditionalOrExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
ConditionalAndExpression() ( <PIPE_PIPE> ConditionalAndExpression() )*
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConditionalAndExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
PowerExpression() ( <AMP_AMP> PowerExpression() )*
|
|
|
|
}
|
|
|
|
|
|
|
|
void PowerExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
ConcatExpression() ( <POW> ConcatExpression() )*
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConcatExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
EqualityExpression() ( <CONCAT> EqualityExpression() )*
|
|
|
|
}
|
|
|
|
|
|
|
|
void EqualityExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
RelationalExpression() ( ( <DOUBLE_EQ> | <NOT_EQ> ) RelationalExpression() )*
|
|
|
|
}
|
|
|
|
|
|
|
|
void RelationalExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
AdditiveExpression() ( ( <LT> | <GT> | <LE> | <GE> ) AdditiveExpression() )*
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdditiveExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
MultiplicativeExpression() ( LOOKAHEAD(2) ( <PLUS> | <MINUS> ) MultiplicativeExpression() )*
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplicativeExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
UnaryExpression() ( ( <MUL> | <DIV> | <PERCENT> ) UnaryExpression() )*
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnaryExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
( <PLUS> | <MINUS> ) UnaryExpression()
|
2017-04-26 15:35:53 -07:00
|
|
|
| PrimaryExpression()
|
2017-02-21 12:59:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrimaryExpression() #void :
|
|
|
|
{}
|
|
|
|
{
|
2020-02-17 08:26:28 +01:00
|
|
|
PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
|
2017-04-11 16:34:01 -07:00
|
|
|
}
|
|
|
|
|
2017-04-14 10:39:03 -07:00
|
|
|
void ELSQCommentExpression() #void :
|
|
|
|
{}
|
2017-04-12 09:42:35 -07:00
|
|
|
{
|
2020-02-17 08:26:28 +01:00
|
|
|
<COMMENT_OPEN_SQ> ( <COMMENT_INNER_TEXT_SQ> )* <COMMENT_CLOSE_SQ>
|
2017-04-12 09:42:35 -07:00
|
|
|
}
|
|
|
|
|
2017-04-14 10:39:03 -07:00
|
|
|
void ELDQCommentExpression() #void :
|
|
|
|
{}
|
2017-04-12 09:42:35 -07:00
|
|
|
{
|
2020-02-17 08:26:28 +01:00
|
|
|
<COMMENT_OPEN_DQ> ( <COMMENT_INNER_TEXT_DQ> )* <COMMENT_CLOSE_DQ>
|
2017-04-12 09:42:35 -07:00
|
|
|
}
|
|
|
|
|
2017-04-14 10:39:03 -07:00
|
|
|
void CommentExpression() #void :
|
|
|
|
{}
|
2017-04-11 16:34:01 -07:00
|
|
|
{
|
2020-02-17 08:26:28 +01:00
|
|
|
<COMMENT_OPEN_SCRIPT> ( <COMMENT_INNER_TEXT_SCRIPT> )* <COMMENT_CLOSE_SCRIPT>
|
2017-02-21 12:59:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrimaryPrefix() #void :
|
|
|
|
{}
|
|
|
|
{
|
2017-04-11 16:34:01 -07:00
|
|
|
Literal()
|
2020-02-17 08:26:28 +01:00
|
|
|
| Identifier()
|
2017-02-22 09:47:07 -08:00
|
|
|
| <LPAREN> Expression() <RPAREN>
|
2017-02-22 10:02:10 -08:00
|
|
|
| <LSQUARE> Expression() (<COMMA> Expression())* <RSQUARE>
|
2017-04-26 15:35:53 -07:00
|
|
|
| NegationExpression()
|
2017-02-21 12:59:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrimarySuffix() #void :
|
|
|
|
{}
|
|
|
|
{
|
2017-02-22 10:02:10 -08:00
|
|
|
<LSQUARE> Expression() (<COMMA> Expression())* <RSQUARE>
|
2017-02-21 14:45:10 -08:00
|
|
|
| DotExpression()
|
2017-02-21 12:59:52 -08:00
|
|
|
| Arguments()
|
|
|
|
}
|
|
|
|
|
2017-04-26 15:35:53 -07:00
|
|
|
void NegationExpression() :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
( <EXCL> ) Expression()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-21 14:45:10 -08:00
|
|
|
void DotExpression() :
|
|
|
|
{}
|
|
|
|
{
|
2017-02-22 09:47:07 -08:00
|
|
|
<EXP_DOT> (Identifier() | Literal() )
|
2017-02-21 16:50:34 -08:00
|
|
|
|
2017-02-21 14:45:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Arguments() :
|
2017-02-21 12:59:52 -08:00
|
|
|
{}
|
|
|
|
{
|
|
|
|
<LPAREN> [ ArgumentList() ] <RPAREN>
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArgumentList() #void:
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
Expression() ( <COMMA> Expression() )*
|
|
|
|
}
|
|
|
|
|
|
|
|
void Literal() :
|
2017-02-21 16:33:17 -08:00
|
|
|
{ String s; Token t; }
|
2017-02-21 12:59:52 -08:00
|
|
|
{
|
2017-02-21 16:32:38 -08:00
|
|
|
t = <STRING_LITERAL> { jjtThis.setImage(t.image);}
|
2017-02-21 12:59:52 -08:00
|
|
|
| t = <DIGITS> { jjtThis.setImage(t.image);}
|
|
|
|
| s = BooleanLiteral() { jjtThis.setImage(s);}
|
|
|
|
| s = NullLiteral() { jjtThis.setImage(s);}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String BooleanLiteral() #void :
|
|
|
|
{ Token t; }
|
|
|
|
{
|
|
|
|
( t = <TRUE>
|
|
|
|
| t = <FALSE>
|
|
|
|
) { return t.image; }
|
|
|
|
}
|
|
|
|
|
|
|
|
String NullLiteral() #void :
|
|
|
|
{ Token t; }
|
|
|
|
{
|
|
|
|
t = <NULL> { return t.image;}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Identifier() :
|
|
|
|
{ Token t; }
|
|
|
|
{
|
|
|
|
t = <IDENTIFIER_EL> { jjtThis.setImage(t.image);}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ElExpressionInAttribute() #ElExpression :
|
|
|
|
{}
|
|
|
|
{
|
2017-02-21 16:50:34 -08:00
|
|
|
<EL_EXPRESSION_IN_ATTRIBUTE_SQ> [Expression()] <END_OF_EL_ATTRIB_SQ>
|
|
|
|
| <EL_EXPRESSION_IN_ATTRIBUTE_DQ> [Expression()] <END_OF_EL_ATTRIB_DQ>
|
2017-02-22 09:47:07 -08:00
|
|
|
| <EL_EXPRESSION_IN_ATTRIBUTE_NQ> [Expression()] <END_OF_EL_ATTRIB_NQ>
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
|
|
|
|
2017-03-01 10:54:35 -08:00
|
|
|
void ElExpressionInScript() #ElExpression :
|
|
|
|
{}
|
|
|
|
{
|
|
|
|
<EL_EXPRESSION_IN_SCRIPT> [Expression()] <END_OF_EL_SCRIPT>
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
void CData() :
|
|
|
|
{
|
|
|
|
StringBuffer content = new StringBuffer();
|
|
|
|
Token t;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
<CDATA_START> ( t = <UNPARSED> { content.append(t.image); } )* <CDATA_END>
|
|
|
|
{
|
|
|
|
jjtThis.setImage(content.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A XML element, either with a single empty tag, or with a starting and closing tag
|
|
|
|
* with optional contained content.
|
|
|
|
*/
|
2017-02-14 15:49:54 -08:00
|
|
|
void Element() :
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
|
|
|
Token startTag;
|
|
|
|
Token endTag;
|
|
|
|
String tagName;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
(
|
|
|
|
(
|
2017-02-14 15:49:54 -08:00
|
|
|
<TAG_START>
|
2017-02-14 14:31:07 -08:00
|
|
|
startTag = <TAG_NAME> { tagName = startTag.image;
|
|
|
|
jjtThis.setName(tagName);
|
|
|
|
tagRegister.openTag(jjtThis);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
(Attribute())*
|
2017-02-14 15:49:54 -08:00
|
|
|
(
|
2017-02-14 14:31:07 -08:00
|
|
|
(
|
|
|
|
<TAG_END>{ jjtThis.setEmpty(false);}
|
|
|
|
|
|
|
|
(Content())
|
2017-02-14 15:49:54 -08:00
|
|
|
|
2017-02-21 12:59:52 -08:00
|
|
|
( LOOKAHEAD(2) <ENDTAG_START>
|
2017-02-14 14:31:07 -08:00
|
|
|
endTag = <TAG_NAME> {tagRegister.closeTag(endTag.image);}
|
|
|
|
<TAG_END>)?
|
|
|
|
)
|
2017-02-14 15:49:54 -08:00
|
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
(<TAG_SLASHEND> { jjtThis.setEmpty(true);
|
|
|
|
jjtThis.setUnclosed(false);
|
|
|
|
}
|
2017-02-14 15:49:54 -08:00
|
|
|
)
|
2017-02-14 14:31:07 -08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2017-02-14 15:49:54 -08:00
|
|
|
void Attribute() :
|
2017-02-14 14:31:07 -08:00
|
|
|
{ Token t; }
|
|
|
|
{
|
|
|
|
t = <ATTR_NAME> { jjtThis.setName(t.image); }
|
|
|
|
(
|
2017-02-21 12:59:52 -08:00
|
|
|
<ATTR_EQ> AttributeValue()
|
2017-02-14 14:31:07 -08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The value of an attribute of an element.
|
|
|
|
* EL expressions
|
|
|
|
* are parsed as sub-nodes of the AttributeValue node.
|
|
|
|
*/
|
2017-02-15 11:48:08 -08:00
|
|
|
void AttributeValue() :
|
2017-02-21 12:59:52 -08:00
|
|
|
{}
|
2017-02-15 11:48:08 -08:00
|
|
|
{
|
|
|
|
(
|
|
|
|
( <DOUBLE_QUOTE>
|
2017-02-21 12:59:52 -08:00
|
|
|
( ( UnparsedTextNoDoubleQuotes() | ElExpressionInAttribute() ) )*
|
2017-02-15 11:48:08 -08:00
|
|
|
( <ENDING_DOUBLE_QUOTE> )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
( <SINGLE_QUOTE>
|
2017-02-21 12:59:52 -08:00
|
|
|
( ( UnparsedTextNoSingleQuotes() | ElExpressionInAttribute() ) )*
|
2017-02-15 11:48:08 -08:00
|
|
|
( <ENDING_SINGLE_QUOTE> )
|
|
|
|
)
|
2017-02-22 09:47:07 -08:00
|
|
|
| ( <NO_QUOTE_NO_WHITESPACE>
|
|
|
|
( ( UnparsedTextNoWhitespace() | ElExpressionInAttribute() ) )*
|
|
|
|
( <ENDING_WHITESPACE> )
|
|
|
|
)
|
2017-02-15 11:48:08 -08:00
|
|
|
| <IN_ATTR_WHITESPACE>
|
|
|
|
)
|
|
|
|
}
|
2017-02-14 14:31:07 -08:00
|
|
|
|
2017-04-14 10:39:03 -07:00
|
|
|
void CommentTag() #void :
|
|
|
|
{}
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
2017-04-14 10:39:03 -07:00
|
|
|
<COMMENT_START> ( <COMMENT_TEXT> )* <COMMENT_END>
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
2017-02-14 15:49:54 -08:00
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
void Declaration() :
|
|
|
|
{ Token t; }
|
|
|
|
{
|
2017-02-14 15:49:54 -08:00
|
|
|
<DECL_START>
|
2017-02-14 14:31:07 -08:00
|
|
|
t = <TAG_NAME> { jjtThis.setName(t.image); }
|
2017-02-14 15:49:54 -08:00
|
|
|
(Attribute())*
|
2017-02-14 14:31:07 -08:00
|
|
|
<DECL_END>
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoctypeDeclaration() :
|
|
|
|
{ Token t; }
|
|
|
|
{
|
|
|
|
<DOCTYPE_DECL_START>
|
|
|
|
<WHITESPACES>
|
|
|
|
t = <NAME> { jjtThis.setName(t.image); }
|
|
|
|
(<WHITESPACES>)?
|
2017-02-14 15:49:54 -08:00
|
|
|
(DoctypeExternalId() (<WHITESPACES>)?)?
|
2017-02-14 14:31:07 -08:00
|
|
|
<DOCTYPE_DECL_END>
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoctypeExternalId() :
|
|
|
|
{
|
|
|
|
Token systemLiteral;
|
|
|
|
Token pubIdLiteral;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
( <SYSTEM>
|
2017-02-14 15:49:54 -08:00
|
|
|
<WHITESPACES>
|
|
|
|
systemLiteral = <QUOTED_LITERAL>
|
2017-02-14 14:31:07 -08:00
|
|
|
{ jjtThis.setUri(quoteContent(systemLiteral.image)); }
|
|
|
|
)
|
2017-02-14 15:49:54 -08:00
|
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
( <PUBLIC>
|
2017-02-14 15:49:54 -08:00
|
|
|
<WHITESPACES>
|
|
|
|
pubIdLiteral = <QUOTED_LITERAL>
|
2017-02-14 14:31:07 -08:00
|
|
|
{ jjtThis.setPublicId(quoteContent(pubIdLiteral.image)); }
|
2017-02-14 15:49:54 -08:00
|
|
|
<WHITESPACES>
|
|
|
|
systemLiteral = <QUOTED_LITERAL>
|
2017-02-14 14:31:07 -08:00
|
|
|
{ jjtThis.setUri(quoteContent(systemLiteral.image)); }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
void HtmlScript() :
|
2017-03-01 13:09:35 -08:00
|
|
|
{}
|
2017-02-14 14:31:07 -08:00
|
|
|
{
|
|
|
|
<HTML_SCRIPT_START> {}
|
|
|
|
(Attribute() )* {}
|
|
|
|
(
|
|
|
|
(
|
|
|
|
<TAG_END> {token_source.SwitchTo(HtmlScriptContentState);}
|
2017-03-01 15:44:55 -08:00
|
|
|
( ( HtmlScriptContent() | ElExpressionInScript() ) )*
|
2017-03-01 13:09:35 -08:00
|
|
|
<HTML_SCRIPT_END_TAG>
|
2017-02-14 15:49:54 -08:00
|
|
|
|
2017-02-14 14:31:07 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
(
|
|
|
|
<TAG_SLASHEND>
|
|
|
|
)
|
2017-02-14 15:49:54 -08:00
|
|
|
)
|
2017-02-14 14:31:07 -08:00
|
|
|
}
|
2017-02-16 14:32:36 -08:00
|
|
|
|
2017-03-01 13:09:35 -08:00
|
|
|
void HtmlScriptContent() #Text :
|
|
|
|
{
|
|
|
|
StringBuffer content = new StringBuffer();
|
|
|
|
Token t;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
( t = <HTML_SCRIPT_CONTENT> { content.append(t.image); } )+
|
|
|
|
{ jjtThis.setImage(content.toString()); }
|
|
|
|
}
|
|
|
|
|