Updates for abbreviation/unabbreviation.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@5422 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Ryan Gustafson
2007-07-18 08:11:32 +00:00
parent 6f493b9751
commit 48547398ca
13 changed files with 864 additions and 664 deletions

View File

@ -13,6 +13,10 @@ options
VISITOR = true;
NODE_USES_PARSER = true;
NODE_PACKAGE="net.sourceforge.pmd.jerry.ast.xpath";
DEBUG_PARSER = false;
DEBUG_LOOKAHEAD = false;
DEBUG_TOKEN_MANAGER = false;
}
PARSER_BEGIN(XPath2Parser)
@ -298,7 +302,7 @@ TOKEN :
|
<#NCNAMECHAR :
// Note: JavaCC cannot do <NAMECHAR> - ":", duplicate <NAMECHAR> here with ":" removed
<LETTER> | <DIGIT> | "." | "-" | "_" | ":" | <COMBININGCHAR> | <EXTENDER>
<LETTER> | <DIGIT> | "." | "-" | "_" | <COMBININGCHAR> | <EXTENDER>
>
|
<#NCNAMESTARTCHAR :
@ -1050,22 +1054,21 @@ void ForwardAxis() :
{
}
{
// TODO Why is this not matching?!?
("child" "::")
("child" { jjtThis.addAxis(AxisEnum.CHILD); } "::")
|
("descendant" "::")
("descendant" { jjtThis.addAxis(AxisEnum.DESCENDANT); } "::")
|
("attribute" "::")
("attribute" { jjtThis.addAxis(AxisEnum.ATTRIBUTE); } "::")
|
("self" "::")
("self" { jjtThis.addAxis(AxisEnum.SELF); } "::")
|
("descendant-or-self" "::")
("descendant-or-self" { jjtThis.addAxis(AxisEnum.DESCENDANT_OR_SELF); } "::")
|
("following-sibling" "::")
("following-sibling" { jjtThis.addAxis(AxisEnum.FOLLOWING_SIBLING); } "::")
|
("following" "::")
("following" { jjtThis.addAxis(AxisEnum.FOLLOWING); } "::")
|
("namespace" "::")
("namespace" { jjtThis.addAxis(AxisEnum.NAMESPACE); } "::")
}
// [31] http://www.w3.org/TR/xpath20/#doc-xpath-AbbrevForwardStep
@ -1091,15 +1094,15 @@ void ReverseAxis() :
{
}
{
("parent" "::")
("parent" { jjtThis.addAxis(AxisEnum.PARENT); } "::")
|
("ancestor" "::")
("ancestor" { jjtThis.addAxis(AxisEnum.ANCESTOR); } "::")
|
("preceding-sibling" "::")
("preceding-sibling" { jjtThis.addAxis(AxisEnum.PRECEDING_SIBLING); } "::")
|
("preceding" "::")
("preceding" { jjtThis.addAxis(AxisEnum.PRECEDING); } "::")
|
("ancestor-or-self" "::")
("ancestor-or-self" { jjtThis.addAxis(AxisEnum.ANCESTOR_OR_SELF); } "::")
}
// [34] http://www.w3.org/TR/xpath20/#doc-xpath-AbbrevReverseStep
@ -1278,11 +1281,12 @@ void OccurrenceIndicator() :
{
}
{
"?"
{ Token token; }
token = "?" { jjtThis.setImage(token.image); }
|
"*"
token = "*" { jjtThis.setImage(token.image); }
|
"+"
token = "+" { jjtThis.setImage(token.image); }
// TODO
/* xgs: occurrence-indicators */
}
@ -1369,7 +1373,8 @@ void PITest() :
{
}
{
"processing-instruction" "(" (<NCNAME> | StringLiteral())? ")"
{ Token token; }
"processing-instruction" "(" (token = <NCNAME> { jjtThis.setImage(token.image); } | StringLiteral())? ")"
}
// [60] http://www.w3.org/TR/xpath20/#doc-xpath-AttributeTest
@ -1411,7 +1416,8 @@ void ElementTest() :
{
}
{
"element" "(" (ElementNameOrWildcard() ("," TypeName() ("?")?)?)? ")"
{ Token token; }
"element" "(" (ElementNameOrWildcard() ("," TypeName() (token = "?" { jjtThis.setImage(token.image); })?)?)? ")"
}
// [65] http://www.w3.org/TR/xpath20/#doc-xpath-ElementNameOrWildcard

View File

@ -2,7 +2,9 @@
package net.sourceforge.pmd.jerry.ast.xpath;
public class ASTElementTest extends SimpleNode {
import net.sourceforge.pmd.jerry.ast.xpath.custom.ImageNode;
public class ASTElementTest extends ImageNode {
public ASTElementTest(int id) {
super(id);
}

View File

@ -2,7 +2,9 @@
package net.sourceforge.pmd.jerry.ast.xpath;
public class ASTForwardAxis extends SimpleNode {
import net.sourceforge.pmd.jerry.ast.xpath.custom.StepNode;
public class ASTForwardAxis extends StepNode {
public ASTForwardAxis(int id) {
super(id);
}

View File

@ -2,7 +2,9 @@
package net.sourceforge.pmd.jerry.ast.xpath;
public class ASTOccurrenceIndicator extends SimpleNode {
import net.sourceforge.pmd.jerry.ast.xpath.custom.ImageNode;
public class ASTOccurrenceIndicator extends ImageNode {
public ASTOccurrenceIndicator(int id) {
super(id);
}

View File

@ -2,7 +2,9 @@
package net.sourceforge.pmd.jerry.ast.xpath;
public class ASTPITest extends SimpleNode {
import net.sourceforge.pmd.jerry.ast.xpath.custom.ImageNode;
public class ASTPITest extends ImageNode {
public ASTPITest(int id) {
super(id);
}

View File

@ -2,7 +2,9 @@
package net.sourceforge.pmd.jerry.ast.xpath;
public class ASTReverseAxis extends SimpleNode {
import net.sourceforge.pmd.jerry.ast.xpath.custom.StepNode;
public class ASTReverseAxis extends StepNode {
public ASTReverseAxis(int id) {
super(id);
}

View File

@ -1611,22 +1611,22 @@ private final int jjMoveNfa_0(int startState, int curPos)
}
break;
case 36:
if ((0x7ff600000000000L & l) != 0L)
if ((0x3ff600000000000L & l) != 0L)
{
if (kind > 94)
kind = 94;
jjCheckNAdd(35);
}
if ((0x7ff600000000000L & l) != 0L)
else if (curChar == 58)
jjstateSet[jjnewStateCnt++] = 32;
if ((0x3ff600000000000L & l) != 0L)
{
if (kind > 93)
kind = 93;
jjCheckNAdd(34);
}
if ((0x7ff600000000000L & l) != 0L)
if ((0x3ff600000000000L & l) != 0L)
jjCheckNAddTwoStates(30, 31);
if (curChar == 58)
jjstateSet[jjnewStateCnt++] = 32;
break;
case 0:
if ((0x3ff000000000000L & l) != 0L)
@ -1768,7 +1768,7 @@ private final int jjMoveNfa_0(int startState, int curPos)
jjCheckNAddTwoStates(28, 23);
break;
case 30:
if ((0x7ff600000000000L & l) != 0L)
if ((0x3ff600000000000L & l) != 0L)
jjCheckNAddTwoStates(30, 31);
break;
case 31:
@ -1776,21 +1776,21 @@ private final int jjMoveNfa_0(int startState, int curPos)
jjstateSet[jjnewStateCnt++] = 32;
break;
case 33:
if ((0x7ff600000000000L & l) == 0L)
if ((0x3ff600000000000L & l) == 0L)
break;
if (kind > 93)
kind = 93;
jjstateSet[jjnewStateCnt++] = 33;
break;
case 34:
if ((0x7ff600000000000L & l) == 0L)
if ((0x3ff600000000000L & l) == 0L)
break;
if (kind > 93)
kind = 93;
jjCheckNAdd(34);
break;
case 35:
if ((0x7ff600000000000L & l) == 0L)
if ((0x3ff600000000000L & l) == 0L)
break;
if (kind > 94)
kind = 94;

View File

@ -17,10 +17,18 @@ public abstract class AbstractPrintVisitor {
return outputBuffer.toString();
}
protected void print(Object o) {
print(String.valueOf(o));
}
protected void print(String s) {
lineBuffer.append(s);
}
protected void println(Object o) {
println(String.valueOf(o));
}
protected void println(String s) {
print(s);
println();
@ -64,7 +72,6 @@ public abstract class AbstractPrintVisitor {
}
protected void TODO(Node node) {
String nodeName = node.getClass().getName();
StringBuffer buf = new StringBuffer(100);
buf.append("Visit for ");
buf.append(node);

View File

@ -45,7 +45,7 @@ public enum AxisEnum {
/**
* TODO Document
*/
PRECEDING_SIBLINGS("preceding-siblings", false),
PRECEDING_SIBLING("preceding-sibling", false),
/**
* TODO Document
*/

View File

@ -66,7 +66,7 @@ public class NodeAccessorAxisNavigator implements AxisNavigator {
case ANCESTOR:
// TODO
break;
case PRECEDING_SIBLINGS:
case PRECEDING_SIBLING:
// TODO
break;
case PRECEDING: