forked from phoedos/pmd
Use getters for tokens in javacc grammars
This commit is contained in:
@ -101,7 +101,7 @@ public final class CppParser {
|
||||
int i;
|
||||
if (t.kind != SCOPE)
|
||||
{
|
||||
s.append(t.image);
|
||||
s.append(t.getImage());
|
||||
t = getToken(2);
|
||||
i = 3;
|
||||
}
|
||||
@ -110,8 +110,8 @@ public final class CppParser {
|
||||
|
||||
while (t.kind == SCOPE)
|
||||
{
|
||||
s.append(t.image);
|
||||
s.append((t = getToken(i++)).image);
|
||||
s.append(t.getImage());
|
||||
s.append((t = getToken(i++)).getImage());
|
||||
t = getToken(i++);
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ MORE:
|
||||
|
|
||||
"\\\r\n"
|
||||
|
|
||||
"/*": IN_PREPROCESSOR_OUTPUT_COMMENT
|
||||
"/*": IN_PREPROCESSOR_OUTPUT_COMMENT
|
||||
|
|
||||
< ~[] >
|
||||
}
|
||||
@ -606,12 +606,12 @@ String scope_override() :
|
||||
("::") { name += "::"; }
|
||||
(
|
||||
LOOKAHEAD(2) t = <ID> ("<" template_argument_list() ">")? "::"
|
||||
{ name += t.image + "::"; }
|
||||
{ name += t.getImage() + "::"; }
|
||||
)*
|
||||
|
|
||||
(
|
||||
LOOKAHEAD(2) t = <ID> ("<" template_argument_list() ">")? "::"
|
||||
{ name += t.image + "::"; }
|
||||
{ name += t.getImage() + "::"; }
|
||||
)+
|
||||
)
|
||||
{ return name; }
|
||||
@ -627,7 +627,7 @@ String qualified_id() :
|
||||
[ LOOKAHEAD(scope_override_lookahead()) name = scope_override() ]
|
||||
(
|
||||
t = <ID> [ "<" template_argument_list() ">" ]
|
||||
{ return name + t.image; }
|
||||
{ return name + t.getImage(); }
|
||||
|
|
||||
"operator" optor() { return "operator"; }
|
||||
)
|
||||
@ -718,7 +718,7 @@ void class_specifier() :
|
||||
|
|
||||
LOOKAHEAD(2) t = <ID>
|
||||
{
|
||||
sc = (ClassScope)sym.OpenScope(t.image, true);
|
||||
sc = (ClassScope)sym.OpenScope(t.getImage(), true);
|
||||
}
|
||||
(base_clause(sc))?
|
||||
"{"
|
||||
@ -729,7 +729,7 @@ void class_specifier() :
|
||||
}
|
||||
|
|
||||
t=<ID> (LOOKAHEAD(2) "<" template_argument_list() ">")?
|
||||
{ sym.PutTypeName(t.image); }
|
||||
{ sym.PutTypeName(t.getImage()); }
|
||||
)
|
||||
}
|
||||
|
||||
@ -745,7 +745,7 @@ void base_specifier(ClassScope scope) :
|
||||
("virtual" (access_specifier())? | access_specifier() ("virtual")?)?
|
||||
(LOOKAHEAD(scope_override_lookahead()) scope_override())?
|
||||
t = <ID> ("<" template_argument_list() ">")?
|
||||
{ scope.AddSuper(sym.GetScope(t.image));
|
||||
{ scope.AddSuper(sym.GetScope(t.getImage()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -837,7 +837,7 @@ void enum_specifier() :
|
||||
"{" enumerator_list() "}"
|
||||
|
|
||||
t=<ID> (LOOKAHEAD(2) "{" enumerator_list() "}")?
|
||||
{ sym.PutTypeName(t.image); }
|
||||
{ sym.PutTypeName(t.getImage()); }
|
||||
)
|
||||
}
|
||||
|
||||
@ -894,7 +894,7 @@ String direct_declarator() :
|
||||
{
|
||||
LOOKAHEAD(2)
|
||||
"~" t = <ID> (LOOKAHEAD(2) declarator_suffixes())?
|
||||
{ return "~" + t.image; }
|
||||
{ return "~" + t.getImage(); }
|
||||
|
|
||||
"(" name = declarator() ")" (LOOKAHEAD(2) declarator_suffixes())?
|
||||
{ return name; }
|
||||
@ -1149,7 +1149,7 @@ void template_parameter() :
|
||||
{ Token t; }
|
||||
{
|
||||
LOOKAHEAD(3)
|
||||
"class" t=<ID> { sym.PutTypeName(t.image); }
|
||||
"class" t=<ID> { sym.PutTypeName(t.getImage()); }
|
||||
|
|
||||
parameter_declaration()
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,7 @@
|
||||
*/
|
||||
options
|
||||
{
|
||||
/** The default package for this parser kit
|
||||
/** The default package for this parser kit
|
||||
NODE_PACKAGE="org.apache.velocity.runtime.parser";
|
||||
*/
|
||||
NODE_PACKAGE="net.sourceforge.pmd.lang.vm.ast";
|
||||
@ -75,12 +75,12 @@ options
|
||||
*/
|
||||
DEBUG_PARSER=false;
|
||||
DEBUG_TOKEN_MANAGER=false;
|
||||
|
||||
|
||||
/**
|
||||
Copied from JSP parser
|
||||
*/
|
||||
FORCE_LA_CHECK = false;
|
||||
IGNORE_CASE = true;
|
||||
IGNORE_CASE = true;
|
||||
}
|
||||
|
||||
PARSER_BEGIN(VmParser)
|
||||
@ -156,7 +156,7 @@ public class VmParser
|
||||
int iLast = strImage.lastIndexOf("\\");
|
||||
|
||||
String strDirective = strImage.substring(iLast + 1);
|
||||
|
||||
|
||||
// return ( strImage.substring(0,iLast/2) + strDirective);
|
||||
|
||||
boolean bRecognizedDirective = false;
|
||||
@ -998,9 +998,9 @@ TOKEN:
|
||||
/*
|
||||
* Remove the double period if it is there
|
||||
*/
|
||||
if (matchedToken.image.endsWith("..")) {
|
||||
if (matchedToken.getImage().endsWith("..")) {
|
||||
input_stream.backup(2);
|
||||
matchedToken.image = matchedToken.image.substring(0,matchedToken.image.length()-2);
|
||||
matchedToken.image = matchedToken.getImage().substring(0,matchedToken.getImage().length()-2);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1197,7 +1197,7 @@ void EscapedDirective() : {}
|
||||
/*
|
||||
* churn and burn..
|
||||
*/
|
||||
t.image = escapedDirective( t.image );
|
||||
t.image = escapedDirective( t.getImage() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1238,7 +1238,7 @@ void Escape() : {}
|
||||
/*
|
||||
* if that failed, lets lookahead to see if we matched a PD or a VM
|
||||
*/
|
||||
String nTag = t.next.image.substring(1);
|
||||
String nTag = t.next.getImage().substring(1);
|
||||
if (strictEscape
|
||||
|| isDirective(nTag)
|
||||
|| macroNames.containsKey(nTag)
|
||||
@ -1380,11 +1380,11 @@ VmNode Directive() :
|
||||
String directiveName;
|
||||
if (t.kind == VmParserConstants.BRACKETED_WORD)
|
||||
{
|
||||
directiveName = t.image.substring(2, t.image.length() - 1);
|
||||
directiveName = t.getImage().substring(2, t.getImage().length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
directiveName = t.image.substring(1);
|
||||
directiveName = t.getImage().substring(1);
|
||||
}
|
||||
|
||||
d = getDirective(directiveName);
|
||||
@ -1459,13 +1459,13 @@ VmNode Directive() :
|
||||
else if (isVM)
|
||||
{
|
||||
throw new MacroParseException("Invalid arg #"
|
||||
+ argPos + " in VM " + t.image, currentTemplateName, t);
|
||||
+ argPos + " in VM " + t.getImage(), currentTemplateName, t);
|
||||
}
|
||||
/* if #foreach and it's the 2nd arg, ok */
|
||||
else if (d != null && (!directiveName.equals("foreach") || argPos != 1))
|
||||
{
|
||||
throw new MacroParseException("Invalid arg #"
|
||||
+ argPos + " in directive " + t.image, currentTemplateName, t);
|
||||
+ argPos + " in directive " + t.getImage(), currentTemplateName, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1505,7 +1505,7 @@ VmNode Directive() :
|
||||
throw new MacroParseException("A macro declaration requires at least a name argument"
|
||||
, currentTemplateName, t);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Not a directive
|
||||
*/
|
||||
@ -1533,7 +1533,7 @@ VmNode Directive() :
|
||||
{
|
||||
// Add the macro name so that we can peform escape processing
|
||||
// on defined macros
|
||||
String macroName = ((AbstractVmNode)jjtThis.jjtGetChild(0)).getFirstToken().image;
|
||||
String macroName = ((AbstractVmNode)jjtThis.jjtGetChild(0)).getFirstToken().getImage();
|
||||
macroNames.put(macroName, macroName);
|
||||
}
|
||||
/*
|
||||
|
Reference in New Issue
Block a user