ws-tsik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject svn commit: r230871 [30/61] - in /incubator/tsik/trunk: ./ data/ data/schema/ resources/ resources/junit/ src/ src/org/ src/org/apache/ src/org/apache/tsik/ src/org/apache/tsik/c14n/ src/org/apache/tsik/c14n/elements/ src/org/apache/tsik/common/ src/or...
Date Mon, 08 Aug 2005 20:03:01 GMT
Added: incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParser.jj
URL: http://svn.apache.org/viewcvs/incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParser.jj?rev=230871&view=auto
==============================================================================
--- incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParser.jj (added)
+++ incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParser.jj Mon Aug  8 12:58:58 2005
@@ -0,0 +1,772 @@
+/*
+	JavaCC Grammar for XSLT/XPath expressions (http://www.w3.org/1999/08/WD-xpath-19990813)
+	Authors: Ingo Macherius, Gerald Huck <{macherius, huck}@gmd.de>
+	Version: 0.01
+	(c) 1999 GMD
+	No warranties, use at your own risk.
+*/
+
+/*
+	Hacked (and hopefully not broken) by Jeffrey Hantin
+	<jhantin@nanobiz.com>.
+*/
+	
+
+/* ----------------------------------------
+	JavaCC 1.1 Options
+-------------------------------------------*/
+
+options {
+	LOOKAHEAD = 1;				// (default 1)
+	CHOICE_AMBIGUITY_CHECK = 2;		// (default 2)
+	OTHER_AMBIGUITY_CHECK = 1;		// (default 1)
+
+	STATIC = false;				// (default true)
+	DEBUG_PARSER = false;			// (default false)
+	DEBUG_LOOKAHEAD = false;		// (default false)
+	DEBUG_TOKEN_MANAGER = false;		// (default false)
+	OPTIMIZE_TOKEN_MANAGER = false;		// (default true)
+	ERROR_REPORTING = true;			// (default true)
+	JAVA_UNICODE_ESCAPE = false;		// (default false)
+// @@@ Note: Unicode seems broken in JavaCC 1.1, else this should be true
+	UNICODE_INPUT = true;			// (default false)
+	IGNORE_CASE = false;			// (default false)
+	COMMON_TOKEN_ACTION = false;		// (default false)
+	USER_TOKEN_MANAGER = false;		// (default false)
+	USER_CHAR_STREAM = false;		// (default false)
+	BUILD_PARSER = true;			// (default true)
+	BUILD_TOKEN_MANAGER = true;		// (default true)
+	SANITY_CHECK = true;			// (default true)
+	FORCE_LA_CHECK = false;			// (default false)
+	CACHE_TOKENS = true;			// (default false)
+}
+
+/*--------------------------------------------
+	Parser Class
+---------------------------------------------*/
+
+PARSER_BEGIN(XPathParser)
+	package org.apache.tsik.xpath.parser;
+
+	import org.apache.tsik.xpath.evaluator.*;
+	import org.apache.tsik.xpath.util.*;
+	import org.w3c.dom.Node;
+
+	public class XPathParser {
+
+		private static AxisEvaluator getAxisByName(String s)
+		{
+			return AxisLibrary.getAxis(s);
+		}
+
+		private static AxisEvaluator childAxis = getAxisByName("child");
+		private static AxisEvaluator attributeAxis = getAxisByName("attribute");
+		private static AxisEvaluator descendantOrSelfAxis = getAxisByName("descendant-or-self");
+		private static AxisEvaluator selfAxis = getAxisByName("self");
+		private static AxisEvaluator parentAxis = getAxisByName("parent");
+
+		private static NodeNodeTestEvaluator nodeNodeTest = new NodeNodeTestEvaluator();
+		private static TextNodeTestEvaluator textNodeTest = new TextNodeTestEvaluator();
+		private static CommentNodeTestEvaluator commentNodeTest = new CommentNodeTestEvaluator();
+		private static ProcessingInstructionNodeTestEvaluator processingInstructionNodeTest = new ProcessingInstructionNodeTestEvaluator(null);
+		private static RootStepEvaluator rootStep = new RootStepEvaluator();
+		private static RelativeStepEvaluator descendantOrSelfNodeStep = new RelativeStepEvaluator(descendantOrSelfAxis, nodeNodeTest);
+		private static RelativeStepEvaluator dotStep = new RelativeStepEvaluator(selfAxis, nodeNodeTest);
+		private static RelativeStepEvaluator dotDotStep = new RelativeStepEvaluator(parentAxis, nodeNodeTest);
+	}
+
+PARSER_END(XPathParser)
+
+/*----------------------------*/
+/* Skip Whitespace everywhere */
+/*----------------------------*/
+
+
+/* [39]    ExprWhitespace    ::=    S  */
+SPECIAL_TOKEN :
+{
+	<S: ( [" ", "\t", "\n", "\r"] )+>
+}
+
+/*-----------------*/
+/* Operator Tokens */
+/*-----------------*/
+
+
+TOKEN:
+{
+		<SLASH:		"/"	>
+	|	<SLASHSLASH:	"//"	>
+	| 	<UNION:		"|"	>
+	| 	<PLUS:		"+"	>
+	| 	<MINUS:		"-"	>
+	| 	<EQ:		"="	>
+	| 	<NEQ:		"!="	>
+	| 	<LT:		"<"	>
+	| 	<LTE:		"<="	>
+	|	<GT:		">"	>
+	| 	<GTE:		">="	>
+	|	<VARIABLE:	"$"	>
+}
+
+
+/*-----------------------------------------------*/
+/* Unambigious Tokens (Number, Literal, Variable */
+/*-----------------------------------------------*/
+
+TOKEN:
+{
+
+/* [29] Literal    ::=    '"' [^"]* '"' | "'" [^']* "'"  */
+	<Literal :
+			"\"" (~["\""])* "\""
+		|	"'"  (~["'"] )* "'"  
+	>
+
+|
+
+/* [31]    Digits    ::=    [0-9]+  */
+	<#Digit :
+		["0"-"9"]
+	>
+
+|
+
+/* [30]    Number    ::=    Digits ('.' Digits?)?  | '.' Digits  */
+	<Number :
+			(<Digit>)+ ("." ( (<Digit>)+ )? )?  
+		|	"." (<Digit>)+
+	>
+}
+
+
+/*-------------------------------*/
+/* XML Names and Qualified Names */
+/*-------------------------------*/
+
+TOKEN:
+{
+	<#Letter :
+		<BaseChar> | <Ideographic>
+	>
+| 
+	<#BaseChar :
+		(
+		["\u0041"-"\u005A"] | ["\u0061"-"\u007A"] | ["\u00C0"-"\u00D6"] | ["\u00D8"-"\u00F6"] |
+		["\u00F8"-"\u00FF"] | ["\u0100"-"\u0131"] | ["\u0134"-"\u013E"] | ["\u0141"-"\u0148"] |
+		["\u014A"-"\u017E"] | ["\u0180"-"\u01C3"] | ["\u01CD"-"\u01F0"] | ["\u01F4"-"\u01F5"] |
+		["\u01FA"-"\u0217"] | ["\u0250"-"\u02A8"] | ["\u02BB"-"\u02C1"] | "\u0386" | ["\u0388"-"\u038A"] |
+		"\u038C" | ["\u038E"-"\u03A1"] | ["\u03A3"-"\u03CE"] | ["\u03D0"-"\u03D6"] | "\u03DA" |
+		"\u03DC" |  "\u03DE" | "\u03E0" | ["\u03E2"-"\u03F3"] | ["\u0401"-"\u040C"] | ["\u040E"-"\u044F"] |
+		["\u0451"-"\u045C"] | ["\u045E"-"\u0481"] | ["\u0490"-"\u04C4"] | ["\u04C7"-"\u04C8"] |
+		["\u04CB"-"\u04CC"] | ["\u04D0"-"\u04EB"] | ["\u04EE"-"\u04F5"] | ["\u04F8"-"\u04F9"] |
+		["\u0531"-"\u0556"] | "\u0559" | ["\u0561"-"\u0586"] | ["\u05D0"-"\u05EA"] | ["\u05F0"-"\u05F2"] |
+		["\u0621"-"\u063A"] | ["\u0641"-"\u064A"] | ["\u0671"-"\u06B7"] | ["\u06BA"-"\u06BE"] |
+		["\u06C0"-"\u06CE"] | ["\u06D0"-"\u06D3"] | "\u06D5" | ["\u06E5"-"\u06E6"] | ["\u0905"-"\u0939"] |
+		"\u093D" | ["\u0958"-"\u0961"] | ["\u0985"-"\u098C"] | ["\u098F"-"\u0990"] | ["\u0993"-"\u09A8"] |
+		["\u09AA"-"\u09B0"] | "\u09B2" | ["\u09B6"-"\u09B9"] | ["\u09DC"-"\u09DD"] | ["\u09DF"-"\u09E1"] |
+		["\u09F0"-"\u09F1"] | ["\u0A05"-"\u0A0A"] | ["\u0A0F"-"\u0A10"] | ["\u0A13"-"\u0A28"] |
+		["\u0A2A"-"\u0A30"] | ["\u0A32"-"\u0A33"] | ["\u0A35"-"\u0A36"] | ["\u0A38"-"\u0A39"] |
+		["\u0A59"-"\u0A5C"] | "\u0A5E" | ["\u0A72"-"\u0A74"] | ["\u0A85"-"\u0A8B"] | "\u0A8D" | 
+		["\u0A8F"-"\u0A91"] | ["\u0A93"-"\u0AA8"] | ["\u0AAA"-"\u0AB0"] | ["\u0AB2"-"\u0AB3"] | 
+		["\u0AB5"-"\u0AB9"] | "\u0ABD" | "\u0AE0" |  ["\u0B05"-"\u0B0C"] | ["\u0B0F"-"\u0B10"] |
+		["\u0B13"-"\u0B28"] | ["\u0B2A"-"\u0B30"] | ["\u0B32"-"\u0B33"] | ["\u0B36"-"\u0B39"] |
+		"\u0B3D" | ["\u0B5C"-"\u0B5D"] | ["\u0B5F"-"\u0B61"] | ["\u0B85"-"\u0B8A"] |  ["\u0B8E"-"\u0B90"] | 
+		["\u0B92"-"\u0B95"] |  ["\u0B99"-"\u0B9A"] | "\u0B9C" | ["\u0B9E"-"\u0B9F"] | ["\u0BA3"-"\u0BA4"] |
+		["\u0BA8"-"\u0BAA"] | ["\u0BAE"-"\u0BB5"] | ["\u0BB7"-"\u0BB9"] | ["\u0C05"-"\u0C0C"] |
+		["\u0C0E"-"\u0C10"] | ["\u0C12"-"\u0C28"] | ["\u0C2A"-"\u0C33"] | ["\u0C35"-"\u0C39"] |
+		["\u0C60"-"\u0C61"] | ["\u0C85"-"\u0C8C"] | ["\u0C8E"-"\u0C90"] | ["\u0C92"-"\u0CA8"] |
+		["\u0CAA"-"\u0CB3"] | ["\u0CB5"-"\u0CB9"] | "\u0CDE" | ["\u0CE0"-"\u0CE1"] | ["\u0D05"-"\u0D0C"] |
+		["\u0D0E"-"\u0D10"] | ["\u0D12"-"\u0D28"] | ["\u0D2A"-"\u0D39"] | ["\u0D60"-"\u0D61"] |
+		["\u0E01"-"\u0E2E"] | "\u0E30" | ["\u0E32"-"\u0E33"] | ["\u0E40"-"\u0E45"] | ["\u0E81"-"\u0E82"] |
+		"\u0E84" | ["\u0E87"-"\u0E88"] | "\u0E8A" | "\u0E8D" | ["\u0E94"-"\u0E97"] | ["\u0E99"-"\u0E9F"] |
+		["\u0EA1"-"\u0EA3"] | "\u0EA5" | "\u0EA7" | ["\u0EAA"-"\u0EAB"] | ["\u0EAD"-"\u0EAE"] | "\u0EB0" |
+		["\u0EB2"-"\u0EB3"] | "\u0EBD" | ["\u0EC0"-"\u0EC4"] | ["\u0F40"-"\u0F47"] | ["\u0F49"-"\u0F69"] |
+		["\u10A0"-"\u10C5"] | ["\u10D0"-"\u10F6"] | "\u1100" | ["\u1102"-"\u1103"] | ["\u1105"-"\u1107"] |
+		"\u1109" | ["\u110B"-"\u110C"] | ["\u110E"-"\u1112"] | "\u113C" | "\u113E" | "\u1140" | "\u114C" |
+		"\u114E" | "\u1150" | ["\u1154"-"\u1155"] | "\u1159" | ["\u115F"-"\u1161"] | "\u1163" | "\u1165" |
+		"\u1167" | "\u1169" | ["\u116D"-"\u116E"] | ["\u1172"-"\u1173"] | "\u1175" | "\u119E" | "\u11A8" |
+		"\u11AB" | ["\u11AE"-"\u11AF"] | ["\u11B7"-"\u11B8"] | "\u11BA" |  ["\u11BC"-"\u11C2"] | "\u11EB" |
+		"\u11F0" | "\u11F9" | ["\u1E00"-"\u1E9B"] | ["\u1EA0"-"\u1EF9"] | ["\u1F00"-"\u1F15"] |
+		["\u1F18"-"\u1F1D"] |
+		["\u1F20"-"\u1F45"] | ["\u1F48"-"\u1F4D"] | ["\u1F50"-"\u1F57"] | "\u1F59" | "\u1F5B" | "\u1F5D" |
+		["\u1F5F"-"\u1F7D"] | ["\u1F80"-"\u1FB4"] | ["\u1FB6"-"\u1FBC"] | "\u1FBE" |  ["\u1FC2"-"\u1FC4"] |
+		["\u1FC6"-"\u1FCC"] | ["\u1FD0"-"\u1FD3"] | ["\u1FD6"-"\u1FDB"] | ["\u1FE0"-"\u1FEC"] |
+		["\u1FF2"-"\u1FF4"] | ["\u1FF6"-"\u1FFC"] | "\u2126" | ["\u212A"-"\u212B"] | "\u212E" |
+		["\u2180"-"\u2182"] | ["\u3041"-"\u3094"] | ["\u30A1"-"\u30FA"] | ["\u3105"-"\u312C"] |
+		["\uAC00"-"\uD7A3"] 
+		)
+	>
+|
+	<#Ideographic :
+		(["\u4E00"-"\u9FA5"] | "\u3007" | ["\u3021"-"\u3029"])
+	>
+|
+	<#CombiningChar :
+		(
+		["\u0300"-"\u0345"]	|	["\u0360"-"\u0361"] 	|	["\u0483"-"\u0486"]	|	["\u0591"-"\u05A1"] |
+		["\u05A3"-"\u05B9"]	|	["\u05BB"-"\u05BD"]		|	"\u05BF" 			|	["\u05C1"-"\u05C2"] |
+		"\u05C4" 			| ["\u064B"-"\u0652"] | "\u0670" 			| ["\u06D6"-"\u06DC"] |
+		["\u06DD"-"\u06DF"] | ["\u06E0"-"\u06E4"] | ["\u06E7"-"\u06E8"] | ["\u06EA"-"\u06ED"] |
+		["\u0901"-"\u0903"] | "\u093C"	|["\u093E"-"\u094C"] | "\u094D" | ["\u0951"-"\u0954"] |
+		["\u0962"-"\u0963"] | ["\u0981"-"\u0983"] | "\u09BC" | "\u09BE" | "\u09BF" | ["\u09C0"-"\u09C4"] |
+		["\u09C7"-"\u09C8"] | ["\u09CB"-"\u09CD"] | "\u09D7" | ["\u09E2"-"\u09E3"] | "\u0A02" | "\u0A3C" |
+		"\u0A3E" | "\u0A3F" | ["\u0A40"-"\u0A42"] |
+		["\u0A47"-"\u0A48"] | ["\u0A4B"-"\u0A4D"] | ["\u0A70"-"\u0A71"] | ["\u0A81"-"\u0A83"] | "\u0ABC" |
+		["\u0ABE"-"\u0AC5"] | ["\u0AC7"-"\u0AC9"] | ["\u0ACB"-"\u0ACD"] | ["\u0B01"-"\u0B03"] | "\u0B3C" |
+		["\u0B3E"-"\u0B43"] | ["\u0B47"-"\u0B48"] | ["\u0B4B"-"\u0B4D"] | ["\u0B56"-"\u0B57"] |
+		["\u0B82"-"\u0B83"] | ["\u0BBE"-"\u0BC2"] | ["\u0BC6"-"\u0BC8"] | ["\u0BCA"-"\u0BCD"] | "\u0BD7" |
+		["\u0C01"-"\u0C03"] | ["\u0C3E"-"\u0C44"] | ["\u0C46"-"\u0C48"] | ["\u0C4A"-"\u0C4D"] |
+		["\u0C55"-"\u0C56"] | ["\u0C82"-"\u0C83"] | ["\u0CBE"-"\u0CC4"] | ["\u0CC6"-"\u0CC8"] |
+		["\u0CCA"-"\u0CCD"] | ["\u0CD5"-"\u0CD6"] | ["\u0D02"-"\u0D03"] | ["\u0D3E"-"\u0D43"] |
+		["\u0D46"-"\u0D48"] | ["\u0D4A"-"\u0D4D"] | "\u0D57" | "\u0E31" | ["\u0E34"-"\u0E3A"] |
+		["\u0E47"-"\u0E4E"] | "\u0EB1" | ["\u0EB4"-"\u0EB9"] | ["\u0EBB"-"\u0EBC"] | ["\u0EC8"-"\u0ECD"] |
+		["\u0F18"-"\u0F19"] | "\u0F35" | "\u0F37" | "\u0F39" | "\u0F3E" | "\u0F3F" | ["\u0F71"-"\u0F84"] |
+		["\u0F86"-"\u0F8B"] | ["\u0F90"-"\u0F95"] | "\u0F97" | ["\u0F99"-"\u0FAD"] | ["\u0FB1"-"\u0FB7"] |
+		"\u0FB9" | ["\u20D0"-"\u20DC"] | "\u20E1" | ["\u302A"-"\u302F"] | "\u3099" | "\u309A"
+		)
+	>
+|
+	<#UnicodeDigit :
+		["\u0030"-"\u0039"] | ["\u0660"-"\u0669"] | ["\u06F0"-"\u06F9"] | ["\u0966"-"\u096F"] |
+		["\u09E6"-"\u09EF"] | ["\u0A66"-"\u0A6F"] | ["\u0AE6"-"\u0AEF"] | ["\u0B66"-"\u0B6F"] |
+		["\u0BE7"-"\u0BEF"] | ["\u0C66"-"\u0C6F"] | ["\u0CE6"-"\u0CEF"] | ["\u0D66"-"\u0D6F"] |
+		["\u0E50"-"\u0E59"] | ["\u0ED0"-"\u0ED9"] | ["\u0F20"-"\u0F29"]  
+	>
+|
+	<#Extender :
+		"\u00B7" | "\u02D0" | "\u02D1" | "\u0387" | "\u0640" | "\u0E46" | "\u0EC6" | 
+		"\u3005" | ["\u3031"-"\u3035"] | ["\u309D"-"\u309E"] | ["\u30FC"-"\u30FE"]  
+	>
+|
+	<OR:	"or">
+|
+ 	<AND:	"and">
+|
+	<MOD:	"mod">
+|
+	<DIV:	"div">
+|
+	<NODE:	"node">
+|
+	<TEXT:	"text">
+|
+	<COMMENT:	"comment">
+|
+	<PI:	"processing-instruction">
+/*
+|
+	<AxisName :
+		(	"self"
+		|	"child"
+		|	"parent"
+		|	"ancestor"
+		|	"attribute"
+		|	"namespace"
+		|	"preceding"
+		|	"following"
+		|	"descendant"
+		|	"ancestor-or-self"
+		|	"following-sibling"
+		|	"preceding-sibling"
+		|	"descendant-or-self"
+		)
+	>
+*/
+|
+	<NCName :
+		(<Letter> | ["_"]) (<Letter> | <UnicodeDigit> | [".","-","_"] | <CombiningChar> | <Extender>)*
+	>
+}
+
+String NCName() :
+{ Token t; }
+{
+	(	t = <NCName>
+	|	t = <OR>
+	| 	t = <AND>
+	|	t = <MOD>
+	|	t = <DIV>
+	|	t = <NODE>
+	|	t = <TEXT>
+	|	t = <COMMENT>
+	|	t = <PI>
+	/* |	t = <AxisName> */
+	) { return t.image; }
+}
+
+String NCName_Without_NodeType() :
+{ Token t; }
+{
+	(	t = <NCName>
+	|	t = <OR>
+	| 	t = <AND>
+	|	t = <MOD>
+	|	t = <DIV>
+	/* |	t = <AxisName> */
+	) { return t.image; }
+}
+
+QualifiedName QName() :
+{ String n1 = null, n2 = null; }
+{
+	n1 = NCName() ( ":" n2 = NCName() )?
+	{
+		if(n2 == null) {
+			return new QualifiedName(null, n1);
+		} else {
+			return new QualifiedName(n1, n2);
+		}
+	}
+}
+
+QualifiedName QName_Without_NodeType() :
+{ String n1 = null, n2 = null; }
+{
+	n1 = NCName_Without_NodeType() ( ":" n2 = NCName_Without_NodeType() )?
+	{
+		if(n2 == null) {
+			return new QualifiedName(null, n1);
+		} else {
+			return new QualifiedName(n1, n2);
+		}
+	}
+}
+
+/* ################################################################################### */
+/* XPath (http://www.w3.org/1999/08/WD-xpath-19990813 )                                */
+/* ################################################################################### */
+
+
+/*------------------*/
+/* 2 Location Paths */
+/*------------------*/
+
+/* [1] LocationPath ::= RelativeLocationPath | AbsoluteLocationPath  */
+
+PathExprEvaluator LocationPath() :
+{ PathExprEvaluator path; }
+{
+	(	{ path = new PathExprEvaluator(); } RelativeLocationPath(path) { return path; }
+	|	path = AbsoluteLocationPath()  
+	) { return path; }
+}
+
+/* [2] AbsoluteLocationPath ::= '/' RelativeLocationPath? | AbbreviatedAbsoluteLocationPath  */
+
+PathExprEvaluator AbsoluteLocationPath() :
+{ PathExprEvaluator path; }
+{
+	path = AbbreviatedAbsoluteLocationPath() { return path; }
+|	<SLASH>
+		{ path = new PathExprEvaluator(); path.addStep(rootStep); }
+	( LOOKAHEAD(RelativeLocationPath()) RelativeLocationPath(path) )?
+		{ return path; }
+}
+
+/* [3] RelativeLocationPath ::= Step | RelativeLocationPath '/' Step | AbbreviatedRelativeLocationPath */
+
+void RelativeLocationPath(PathExprEvaluator path) :
+{ StepEvaluator step; }
+{
+	step = Step() { path.addStep(step); }
+	(
+		LOOKAHEAD((<SLASH> | <SLASHSLASH> ) RelativeLocationPath())
+		(<SLASH> | <SLASHSLASH> { path.addStep(descendantOrSelfNodeStep); } ) RelativeLocationPath(path)
+	)?
+}
+
+
+/*--------------------*/
+/* 2.1 Location Steps */ 
+/*--------------------*/
+
+/* [4] Step ::= AxisSpecifier NodeTest Predicate*   | AbbreviatedStep  */
+
+StepEvaluator Step() :
+{
+	AxisEvaluator axis;
+	NodeTestEvaluator nodetest;
+	ExprEvaluator predicate;
+	RelativeStepEvaluator step;
+}
+{
+	axis = AxisSpecifier() nodetest = NodeTest()
+		{ step = new RelativeStepEvaluator(axis, nodetest); }
+	( predicate = Predicate() 
+		{ step.addPredicate(new PredicateEvaluator(predicate)); }
+	)*
+		{ return step; }
+|	step = AbbreviatedStep()
+		{ return step; }
+}
+
+/* [5] AxisSpecifier ::=    AxisName '::' | AbbreviatedAxisSpecifier  */
+
+AxisEvaluator AxisSpecifier() :
+{ AxisEvaluator axis; }
+{
+		LOOKAHEAD(AxisName() "::") axis = AxisName() "::" { return axis; }
+	|	axis = AbbreviatedAxisSpecifier() { return axis; }
+}
+
+/*----------*/
+/* 2.2 Axes */ 
+/*----------*/
+
+/* [6] AxisName ::= 'ancestor' | 'ancestor-or-self' | 'attribute'  | 'child' | 'descendant'  
+					| 'descendant-or-self' | 'following' | 'following-sibling' | 'namespace'  
+   					| 'parent' | 'preceding' | 'preceding-sibling' | 'self'
+*/
+
+AxisEvaluator AxisName() :
+{ String s; AxisEvaluator axis; }
+{
+	s = NCName() { axis = getAxisByName(s); if(axis == null) throw new ParseException("Unrecognized axis name: " + s); else return axis; }
+}
+
+/*----------------*/
+/* 2.3 Node Tests */ 
+/*----------------*/
+
+/* [7] NodeTest ::= WildcardName | NodeType '(' ')' | 'processing-instruction' '(' Literal ')' */
+
+NodeTestEvaluator NodeTest() :
+{ NodeTestEvaluator nodetest; QualifiedName name; Token target; }
+{
+		LOOKAHEAD(NodeType() "(" ")") nodetest = NodeType() "(" ")" { return nodetest; }
+	|	LOOKAHEAD(<PI> "(" <Literal> ")") <PI> "(" target = <Literal> ")" { return new ProcessingInstructionNodeTestEvaluator(target.image.substring(1, target.image.length() - 1)); }
+	|	name = WildcardName() { return new QualifiedNameNodeTestEvaluator(name); }
+}
+
+/*----------------*/
+/* 2.4 Predicates */
+/*----------------*/
+
+/* [8] Predicate ::= '[' PredicateExpr ']'  */
+ExprEvaluator Predicate() :
+{ ExprEvaluator e; }
+{
+		"[" e = PredicateExpr() "]" { return e; }
+	{ return null; }
+}
+
+/* [9] PredicateExpr ::=  Expr  */
+ExprEvaluator PredicateExpr() :
+{ ExprEvaluator e; }
+{
+		e = Expr() { return e; }
+}
+
+/*------------------------*/
+/* 2.5 Abbreviated Syntax */
+/*------------------------*/
+/* [10]    AbbreviatedAbsoluteLocationPath    ::=    '//' RelativeLocationPath  */
+PathExprEvaluator AbbreviatedAbsoluteLocationPath() :
+{ PathExprEvaluator path; }
+{
+	<SLASHSLASH>
+		{ path = new PathExprEvaluator(); path.addStep(rootStep); path.addStep(descendantOrSelfNodeStep); }
+	RelativeLocationPath(path)
+		{ return path; }
+}
+
+/* [11]    AbbreviatedRelativeLocationPath    ::=    RelativeLocationPath '//' Step  */
+void AbbreviatedRelativeLocationPath(PathExprEvaluator path) :
+{ StepEvaluator step; }
+{
+	RelativeLocationPath(path) <SLASHSLASH>
+		{ path.addStep(descendantOrSelfNodeStep); }
+	step = Step()
+		{ path.addStep(step); }
+}
+
+/* [12]    AbbreviatedStep    ::=    '.'  | '..'  */
+RelativeStepEvaluator AbbreviatedStep() :
+{}
+{
+		"." { return dotStep; }
+	|	".." { return dotDotStep; }
+}
+
+/* [13]    AbbreviatedAxisSpecifier    ::=    '@'? */
+AxisEvaluator AbbreviatedAxisSpecifier() :
+{ AxisEvaluator axis = childAxis; }
+{
+	( "@" { axis = attributeAxis; } )? { return axis; }
+}
+/*---------------*/
+/* 3 Expressions */
+/*---------------*/
+
+/*------------*/
+/* 3.1 Basics */
+/*------------*/
+
+/*
+The effect of the grammar is that the order of precedence is (lowest precedence first): 
+	or 
+	and 
+	=, != 
+	<=, <, >=, > 
+and all operators are left associative.
+For example, 3 > 2 > 1 is equivalent to (3 > 2) > 1, which evaluates to false. 
+*/
+
+/* [14] Expr ::= OrExpr */
+ExprEvaluator Expr() :
+{ ExprEvaluator e; }
+{
+	e = OrExpr() { return e; }
+}
+
+/* [15] PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall */
+
+ExprEvaluator PrimaryExpr() :
+{ Token t; ExprEvaluator e; }
+{
+		e = VariableReference()
+		{
+			return e;
+		}
+	|	"(" e = Expr() ")"  
+		{
+			return e;
+		}
+	|	t = <Literal>
+		{
+			return new ConstantExprEvaluator(t.image.substring(1, t.image.length() - 1));
+		}
+	|	t = <Number>
+		{
+			return new ConstantExprEvaluator(new Double(t.image));
+		}
+	|	e = FunctionCall()
+		{
+			return e;
+		}
+}
+
+/*--------------------*/
+/* 3.2 Function Calls */
+/*--------------------*/
+
+/* [16]    FunctionCall    ::=    FunctionName '(' ( Argument ( ',' Argument)*)? ')'  */
+ExprEvaluator FunctionCall() :
+{ QualifiedName name; FunctionCallExprEvaluator func; ExprEvaluator expr; }
+{
+	name = FunctionName() { func = new FunctionCallExprEvaluator(name); }
+	"(" (
+		expr = Argument() { func.addArgument(expr); }
+		( "," expr = Argument() { func.addArgument(expr); } )*
+	)? ")"
+	{ return func; }
+}
+
+/* [17]    Argument    ::=    Expr */
+ExprEvaluator Argument() :
+{ ExprEvaluator e; }
+{
+	e = Expr() { return e; }
+}
+
+/*---------------*/
+/* 3.3 Node-sets */
+/*---------------*/
+
+/* [18] UnionExpr    ::=    PathExpr | UnionExpr '|' PathExpr */
+ExprEvaluator UnionExpr() :
+{ ExprEvaluator lhs, rhs; } 
+{
+		lhs = PathExpr() ( <UNION> rhs = PathExpr() { lhs = new UnionExprEvaluator(lhs, rhs); } )* { return lhs; }
+}
+
+
+/* [19] PathExpr ::= LocationPath | FilterExpr | FilterExpr '/' RelativeLocationPath | FilterExpr '//' RelativeLocationPath  */
+ExprEvaluator PathExpr() :
+{ ExprEvaluator expr; PathExprEvaluator path; }
+{
+		LOOKAHEAD(FilterExpr() ( ( <SLASH> | <SLASHSLASH> ) RelativeLocationPath() )?)
+		expr = FilterExpr() (
+				{ path = new PathExprEvaluator(); path.addStep(new ExprStepEvaluator(expr)); }
+			( <SLASH> | <SLASHSLASH> { path.addStep(descendantOrSelfNodeStep); } )
+			RelativeLocationPath(path) { expr = path; } )? { return expr; }
+	|	path = LocationPath() { return path; }
+}
+
+/* [20]    FilterExpr    ::=    PrimaryExpr    | FilterExpr Predicate */
+ExprEvaluator FilterExpr() :
+{ ExprEvaluator lhs, rhs; }
+{
+//	This looks bugged to me, but it's what came in the file. -jh
+//		(LOOKAHEAD(PrimaryExpr()) PrimaryExpr())+ ( Predicate() )?
+//	Should be:
+	lhs = PrimaryExpr() ( rhs = Predicate() { lhs = new PredicateExprEvaluator(lhs, rhs); } )* { return lhs; }
+}
+
+
+
+/*--------------*/
+/* 3.4 Booleans */
+/*--------------*/
+
+/* [21] OrExpr    ::=    AndExpr | OrExpr 'or' AndExpr */ 
+ExprEvaluator OrExpr() :
+{ ExprEvaluator lhs, rhs; }
+{
+		lhs = AndExpr() ( <OR> rhs = AndExpr() { lhs = new OrExprEvaluator(lhs, rhs); } )* { return lhs; }
+}
+
+/* [22] AndExpr    ::=    EqualityExpr  | AndExpr 'and' EqualityExpr  */
+ExprEvaluator AndExpr() :
+{ ExprEvaluator lhs, rhs; }
+{
+		lhs = EqualityExpr() ( <AND> rhs = EqualityExpr() { lhs = new AndExprEvaluator(lhs, rhs); } )* { return lhs; }
+}
+
+/* [23] EqualityExpr    ::=    RelationalExpr | EqualityExpr '=' RelationalExpr | EqualityExpr '!=' RelationalExpr */
+ExprEvaluator EqualityExpr() :
+{ ExprEvaluator lhs, rhs; }
+{
+		lhs = RelationalExpr() ( ( <EQ> rhs = RelationalExpr() { lhs = new EqualExprEvaluator(lhs, rhs); } )
+				       | ( <NEQ> rhs = RelationalExpr() { lhs = new NotEqualExprEvaluator(lhs, rhs); } ) )* { return lhs; }
+}
+
+
+/* [24] RelationalExpr    ::=    AdditiveExpr | RelationalExpr '<' AdditiveExpr | RelationalExpr '>' AdditiveExpr  
+					   | RelationalExpr '<=' AdditiveExpr  | RelationalExpr '>=' AdditiveExpr */
+ExprEvaluator RelationalExpr() :
+{ ExprEvaluator lhs, rhs; }
+{
+	lhs = AdditiveExpr()
+	( ( <LT> rhs = AdditiveExpr() { lhs = new LessThanExprEvaluator(lhs, rhs); } )
+	| ( <LTE> rhs = AdditiveExpr() { lhs = new LessThanOrEqualExprEvaluator(lhs, rhs); } )
+	| ( <GT> rhs = AdditiveExpr() { lhs = new GreaterThanExprEvaluator(lhs, rhs); } )
+	| ( <GTE> rhs = AdditiveExpr() { lhs = new GreaterThanOrEqualExprEvaluator(lhs, rhs); } )
+	)* { return lhs; }
+}
+
+/*-------------*/
+/* 3.5 Numbers */
+/*-------------*/
+
+/* [25] AdditiveExpr ::= MultiplicativeExpr  | AdditiveExpr '+' MultiplicativeExpr  | AdditiveExpr '-' MultiplicativeExpr  */
+ExprEvaluator AdditiveExpr() :
+{ ExprEvaluator lhs, rhs; }
+{
+	lhs = MultiplicativeExpr()
+	( ( <PLUS> rhs = MultiplicativeExpr() { lhs = new PlusExprEvaluator(lhs, rhs); } )
+	| ( <MINUS> rhs = MultiplicativeExpr() { lhs = new MinusExprEvaluator(lhs, rhs); } )
+	)* { return lhs; }
+}
+
+/* [26] MultiplicativeExpr ::= UnaryExpr | MultiplicativeExpr MultiplyOperator UnaryExpr
+			| MultiplicativeExpr 'div' UnaryExpr | MultiplicativeExpr 'mod' UnaryExpr  */
+ExprEvaluator MultiplicativeExpr() :
+{ ExprEvaluator lhs, rhs; }
+{
+/*		UnaryExpr() ( ( <MultiplyOperator> | "div" | "mod" ) UnaryExpr() )* */
+	lhs = UnaryExpr()
+	( ( "*" rhs = UnaryExpr() { lhs = new MultiplyExprEvaluator(lhs, rhs); } )
+	| ( <DIV> rhs = UnaryExpr() { lhs = new DivideExprEvaluator(lhs, rhs); } )
+	| ( <MOD> rhs = UnaryExpr() { lhs = new ModuloExprEvaluator(lhs, rhs); } )
+	)* { return lhs; }
+}
+
+/* [27]    UnaryExpr    ::=    UnionExpr  | '-' UnaryExpr  */
+ExprEvaluator UnaryExpr() :
+{ ExprEvaluator e; }
+{
+		e = UnionExpr() { return e; }
+	|	<MINUS> e = UnaryExpr() { return new UnaryMinusExprEvaluator(e); }
+}
+
+/*-------------*/
+/* 3.6 Strings */
+/*-------------*/
+
+/*----------------------------------*/
+/* 3.7 Expression Lexical Structure */
+/*----------------------------------*/
+/*
+The following special tokenization rules must be applied in the order
+specified to disambiguate the grammar:
+
+1. If there is a preceding token and the preceding token is not one of
+   @, ::, (, [, , or an Operator,
+   then a * must be recognized as a MultiplyOperator and an NCName must
+   be recognized as an OperatorName.
+
+2. If the character following an NCName (possibly after intervening ExprWhitespace)
+   is (, then the token must be recognized as a NodeType or a FunctionName.
+
+3. If the two characters following an NCName (possibly after intervening ExprWhitespace)
+   are ::, then the token must be recognized as an AxisName.
+
+4. Otherwise, the token must not be recognized as a MultiplyOperator, an OperatorName,
+   a NodeType, a FunctionName, or an AxisName.
+*/
+
+/*
+[28]    ExprToken    ::=    '(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'  
+   | WildcardName  | NodeType  | Operator  | FunctionName  | AxisName  | Literal  
+   | Number  | VariableReference  
+*/
+/* [34]    MultiplyOperator    ::=    '*'  */
+
+/* [35]    FunctionName    ::=    QName - NodeType   */
+QualifiedName FunctionName() :
+{ QualifiedName name; }
+{
+	name = QName_Without_NodeType() { return name; }
+}
+
+/* [36]    VariableReference    ::=    '$' QName  */
+
+ExprEvaluator VariableReference() :
+{ QualifiedName name; }
+{
+		<VARIABLE> name = QName() { return new VariableReferenceExprEvaluator(name); }
+}
+/* [37]    WildcardName    ::=    '*'     | NCName ':' '*'     | QName  */
+QualifiedName WildcardName() :
+{String prefix, localName;  QualifiedName name; }
+{
+		"*" { return new QualifiedName(null, "*"); }
+	|	LOOKAHEAD(NCName() ":" "*") prefix=NCName() ":" "*" { return new QualifiedName(prefix, "*"); }
+	|	name = QName() { return name; }
+}
+
+/* [38]    NodeType    ::=    'comment' | 'text'  | 'processing-instruction'  | 'node'  */
+
+NodeTestEvaluator NodeType() :
+{ }
+{
+		<TEXT> { return textNodeTest; }
+	|	<NODE> { return nodeNodeTest; }
+	|	<COMMENT> { return commentNodeTest; }
+	|	<PI> { return processingInstructionNodeTest; }
+}
+
+ExprEvaluator ExprInput() :
+{ ExprEvaluator e; }
+{
+	e = Expr() <EOF> { return e; }
+}
+
+ExprEvaluator ExprsInput() :
+{ ExprEvaluator e; }
+{
+	e = Expr() { return e; }
+|	";" { return null; }
+|	<EOF> { throw new ThreadDeath(); /* byebye */ }
+}
+
+
+/* ################################################################################### */
+
+
+
+
+
+

Propchange: incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParser.jj
------------------------------------------------------------------------------
    svn:executable = 

Added: incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserConstants.java
URL: http://svn.apache.org/viewcvs/incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserConstants.java?rev=230871&view=auto
==============================================================================
--- incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserConstants.java (added)
+++ incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserConstants.java Mon Aug  8 12:58:58 2005
@@ -0,0 +1,106 @@
+// $Id$
+
+//
+// (C) Copyright 2005 VeriSign, Inc.  All Rights Reserved.
+//
+// VeriSign, Inc. shall have no responsibility, financial or
+// otherwise, for any consequences arising out of the use of
+// this material. The program material is provided on an "AS IS"
+// BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+// express or implied. The user is responsible for determining
+// any necessary third party rights or authorizations that may
+// be required for the use of the materials. Users are advised 
+// that they may need authorizations under certain patents from 
+// Microsoft and IBM, or others. Please see notice.txt file. 
+// VeriSign disclaims any obligation to notify the user of any 
+// such third party rights.
+//
+
+/* Generated By:JavaCC: Do not edit this line. XPathParserConstants.java */
+package org.apache.tsik.xpath.parser;
+
+public interface XPathParserConstants {
+
+  int EOF = 0;
+  int S = 1;
+  int SLASH = 2;
+  int SLASHSLASH = 3;
+  int UNION = 4;
+  int PLUS = 5;
+  int MINUS = 6;
+  int EQ = 7;
+  int NEQ = 8;
+  int LT = 9;
+  int LTE = 10;
+  int GT = 11;
+  int GTE = 12;
+  int VARIABLE = 13;
+  int Literal = 14;
+  int Digit = 15;
+  int Number = 16;
+  int Letter = 17;
+  int BaseChar = 18;
+  int Ideographic = 19;
+  int CombiningChar = 20;
+  int UnicodeDigit = 21;
+  int Extender = 22;
+  int OR = 23;
+  int AND = 24;
+  int MOD = 25;
+  int DIV = 26;
+  int NODE = 27;
+  int TEXT = 28;
+  int COMMENT = 29;
+  int PI = 30;
+  int NCName = 31;
+
+  int DEFAULT = 0;
+
+  String[] tokenImage = {
+    "<EOF>",
+    "<S>",
+    "\"/\"",
+    "\"//\"",
+    "\"|\"",
+    "\"+\"",
+    "\"-\"",
+    "\"=\"",
+    "\"!=\"",
+    "\"<\"",
+    "\"<=\"",
+    "\">\"",
+    "\">=\"",
+    "\"$\"",
+    "<Literal>",
+    "<Digit>",
+    "<Number>",
+    "<Letter>",
+    "<BaseChar>",
+    "<Ideographic>",
+    "<CombiningChar>",
+    "<UnicodeDigit>",
+    "<Extender>",
+    "\"or\"",
+    "\"and\"",
+    "\"mod\"",
+    "\"div\"",
+    "\"node\"",
+    "\"text\"",
+    "\"comment\"",
+    "\"processing-instruction\"",
+    "<NCName>",
+    "\":\"",
+    "\"::\"",
+    "\"(\"",
+    "\")\"",
+    "\"[\"",
+    "\"]\"",
+    "\".\"",
+    "\"..\"",
+    "\"@\"",
+    "\",\"",
+    "\"*\"",
+    "\";\"",
+  };
+
+}

Propchange: incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserConstants.java
------------------------------------------------------------------------------
    svn:executable = 

Added: incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserTokenManager.java
URL: http://svn.apache.org/viewcvs/incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserTokenManager.java?rev=230871&view=auto
==============================================================================
--- incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserTokenManager.java (added)
+++ incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserTokenManager.java Mon Aug  8 12:58:58 2005
@@ -0,0 +1,1356 @@
+// $Id$
+
+//
+// (C) Copyright 2005 VeriSign, Inc.  All Rights Reserved.
+//
+// VeriSign, Inc. shall have no responsibility, financial or
+// otherwise, for any consequences arising out of the use of
+// this material. The program material is provided on an "AS IS"
+// BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+// express or implied. The user is responsible for determining
+// any necessary third party rights or authorizations that may
+// be required for the use of the materials. Users are advised 
+// that they may need authorizations under certain patents from 
+// Microsoft and IBM, or others. Please see notice.txt file. 
+// VeriSign disclaims any obligation to notify the user of any 
+// such third party rights.
+//
+
+/* Generated By:JavaCC: Do not edit this line. XPathParserTokenManager.java */
+package org.apache.tsik.xpath.parser;
+import org.apache.tsik.xpath.evaluator.*;
+import org.apache.tsik.xpath.util.*;
+import org.w3c.dom.Node;
+
+public class XPathParserTokenManager implements XPathParserConstants
+{
+private final int jjStopStringLiteralDfa_0(int pos, long active0)
+{
+   switch (pos)
+   {
+      case 0:
+         if ((active0 & 0xc000000000L) != 0L)
+            return 11;
+         if ((active0 & 0x7f800000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            return 13;
+         }
+         return -1;
+      case 1:
+         if ((active0 & 0x7f000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 1;
+            return 13;
+         }
+         if ((active0 & 0x800000L) != 0L)
+            return 13;
+         return -1;
+      case 2:
+         if ((active0 & 0x78000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 2;
+            return 13;
+         }
+         if ((active0 & 0x7000000L) != 0L)
+            return 13;
+         return -1;
+      case 3:
+         if ((active0 & 0x18000000L) != 0L)
+            return 13;
+         if ((active0 & 0x60000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 3;
+            return 13;
+         }
+         return -1;
+      case 4:
+         if ((active0 & 0x60000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 4;
+            return 13;
+         }
+         return -1;
+      case 5:
+         if ((active0 & 0x60000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 5;
+            return 13;
+         }
+         return -1;
+      case 6:
+         if ((active0 & 0x20000000L) != 0L)
+            return 13;
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 6;
+            return 13;
+         }
+         return -1;
+      case 7:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 7;
+            return 13;
+         }
+         return -1;
+      case 8:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 8;
+            return 13;
+         }
+         return -1;
+      case 9:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 9;
+            return 13;
+         }
+         return -1;
+      case 10:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 10;
+            return 13;
+         }
+         return -1;
+      case 11:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 11;
+            return 13;
+         }
+         return -1;
+      case 12:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 12;
+            return 13;
+         }
+         return -1;
+      case 13:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 13;
+            return 13;
+         }
+         return -1;
+      case 14:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 14;
+            return 13;
+         }
+         return -1;
+      case 15:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 15;
+            return 13;
+         }
+         return -1;
+      case 16:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 16;
+            return 13;
+         }
+         return -1;
+      case 17:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 17;
+            return 13;
+         }
+         return -1;
+      case 18:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 18;
+            return 13;
+         }
+         return -1;
+      case 19:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 19;
+            return 13;
+         }
+         return -1;
+      case 20:
+         if ((active0 & 0x40000000L) != 0L)
+         {
+            jjmatchedKind = 31;
+            jjmatchedPos = 20;
+            return 13;
+         }
+         return -1;
+      default :
+         return -1;
+   }
+}
+private final int jjStartNfa_0(int pos, long active0)
+{
+   return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
+}
+private final int jjStopAtPos(int pos, int kind)
+{
+   jjmatchedKind = kind;
+   jjmatchedPos = pos;
+   return pos + 1;
+}
+private final int jjStartNfaWithStates_0(int pos, int kind, int state)
+{
+   jjmatchedKind = kind;
+   jjmatchedPos = pos;
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) { return pos + 1; }
+   return jjMoveNfa_0(state, pos + 1);
+}
+private final int jjMoveStringLiteralDfa0_0()
+{
+   switch(curChar)
+   {
+      case 33:
+         return jjMoveStringLiteralDfa1_0(0x100L);
+      case 36:
+         return jjStopAtPos(0, 13);
+      case 40:
+         return jjStopAtPos(0, 34);
+      case 41:
+         return jjStopAtPos(0, 35);
+      case 42:
+         return jjStopAtPos(0, 42);
+      case 43:
+         return jjStopAtPos(0, 5);
+      case 44:
+         return jjStopAtPos(0, 41);
+      case 45:
+         return jjStopAtPos(0, 6);
+      case 46:
+         jjmatchedKind = 38;
+         return jjMoveStringLiteralDfa1_0(0x8000000000L);
+      case 47:
+         jjmatchedKind = 2;
+         return jjMoveStringLiteralDfa1_0(0x8L);
+      case 58:
+         jjmatchedKind = 32;
+         return jjMoveStringLiteralDfa1_0(0x200000000L);
+      case 59:
+         return jjStopAtPos(0, 43);
+      case 60:
+         jjmatchedKind = 9;
+         return jjMoveStringLiteralDfa1_0(0x400L);
+      case 61:
+         return jjStopAtPos(0, 7);
+      case 62:
+         jjmatchedKind = 11;
+         return jjMoveStringLiteralDfa1_0(0x1000L);
+      case 64:
+         return jjStopAtPos(0, 40);
+      case 91:
+         return jjStopAtPos(0, 36);
+      case 93:
+         return jjStopAtPos(0, 37);
+      case 97:
+         return jjMoveStringLiteralDfa1_0(0x1000000L);
+      case 99:
+         return jjMoveStringLiteralDfa1_0(0x20000000L);
+      case 100:
+         return jjMoveStringLiteralDfa1_0(0x4000000L);
+      case 109:
+         return jjMoveStringLiteralDfa1_0(0x2000000L);
+      case 110:
+         return jjMoveStringLiteralDfa1_0(0x8000000L);
+      case 111:
+         return jjMoveStringLiteralDfa1_0(0x800000L);
+      case 112:
+         return jjMoveStringLiteralDfa1_0(0x40000000L);
+      case 116:
+         return jjMoveStringLiteralDfa1_0(0x10000000L);
+      case 124:
+         return jjStopAtPos(0, 4);
+      default :
+         return jjMoveNfa_0(1, 0);
+   }
+}
+private final int jjMoveStringLiteralDfa1_0(long active0)
+{
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(0, active0);
+      return 1;
+   }
+   switch(curChar)
+   {
+      case 46:
+         if ((active0 & 0x8000000000L) != 0L)
+            return jjStopAtPos(1, 39);
+         break;
+      case 47:
+         if ((active0 & 0x8L) != 0L)
+            return jjStopAtPos(1, 3);
+         break;
+      case 58:
+         if ((active0 & 0x200000000L) != 0L)
+            return jjStopAtPos(1, 33);
+         break;
+      case 61:
+         if ((active0 & 0x100L) != 0L)
+            return jjStopAtPos(1, 8);
+         else if ((active0 & 0x400L) != 0L)
+            return jjStopAtPos(1, 10);
+         else if ((active0 & 0x1000L) != 0L)
+            return jjStopAtPos(1, 12);
+         break;
+      case 101:
+         return jjMoveStringLiteralDfa2_0(active0, 0x10000000L);
+      case 105:
+         return jjMoveStringLiteralDfa2_0(active0, 0x4000000L);
+      case 110:
+         return jjMoveStringLiteralDfa2_0(active0, 0x1000000L);
+      case 111:
+         return jjMoveStringLiteralDfa2_0(active0, 0x2a000000L);
+      case 114:
+         if ((active0 & 0x800000L) != 0L)
+            return jjStartNfaWithStates_0(1, 23, 13);
+         return jjMoveStringLiteralDfa2_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(0, active0);
+}
+private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(0, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(1, active0);
+      return 2;
+   }
+   switch(curChar)
+   {
+      case 100:
+         if ((active0 & 0x1000000L) != 0L)
+            return jjStartNfaWithStates_0(2, 24, 13);
+         else if ((active0 & 0x2000000L) != 0L)
+            return jjStartNfaWithStates_0(2, 25, 13);
+         return jjMoveStringLiteralDfa3_0(active0, 0x8000000L);
+      case 109:
+         return jjMoveStringLiteralDfa3_0(active0, 0x20000000L);
+      case 111:
+         return jjMoveStringLiteralDfa3_0(active0, 0x40000000L);
+      case 118:
+         if ((active0 & 0x4000000L) != 0L)
+            return jjStartNfaWithStates_0(2, 26, 13);
+         break;
+      case 120:
+         return jjMoveStringLiteralDfa3_0(active0, 0x10000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(1, active0);
+}
+private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(1, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(2, active0);
+      return 3;
+   }
+   switch(curChar)
+   {
+      case 99:
+         return jjMoveStringLiteralDfa4_0(active0, 0x40000000L);
+      case 101:
+         if ((active0 & 0x8000000L) != 0L)
+            return jjStartNfaWithStates_0(3, 27, 13);
+         break;
+      case 109:
+         return jjMoveStringLiteralDfa4_0(active0, 0x20000000L);
+      case 116:
+         if ((active0 & 0x10000000L) != 0L)
+            return jjStartNfaWithStates_0(3, 28, 13);
+         break;
+      default :
+         break;
+   }
+   return jjStartNfa_0(2, active0);
+}
+private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(2, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(3, active0);
+      return 4;
+   }
+   switch(curChar)
+   {
+      case 101:
+         return jjMoveStringLiteralDfa5_0(active0, 0x60000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(3, active0);
+}
+private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(3, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(4, active0);
+      return 5;
+   }
+   switch(curChar)
+   {
+      case 110:
+         return jjMoveStringLiteralDfa6_0(active0, 0x20000000L);
+      case 115:
+         return jjMoveStringLiteralDfa6_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(4, active0);
+}
+private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(4, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(5, active0);
+      return 6;
+   }
+   switch(curChar)
+   {
+      case 115:
+         return jjMoveStringLiteralDfa7_0(active0, 0x40000000L);
+      case 116:
+         if ((active0 & 0x20000000L) != 0L)
+            return jjStartNfaWithStates_0(6, 29, 13);
+         break;
+      default :
+         break;
+   }
+   return jjStartNfa_0(5, active0);
+}
+private final int jjMoveStringLiteralDfa7_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(5, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(6, active0);
+      return 7;
+   }
+   switch(curChar)
+   {
+      case 105:
+         return jjMoveStringLiteralDfa8_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(6, active0);
+}
+private final int jjMoveStringLiteralDfa8_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(6, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(7, active0);
+      return 8;
+   }
+   switch(curChar)
+   {
+      case 110:
+         return jjMoveStringLiteralDfa9_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(7, active0);
+}
+private final int jjMoveStringLiteralDfa9_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(7, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(8, active0);
+      return 9;
+   }
+   switch(curChar)
+   {
+      case 103:
+         return jjMoveStringLiteralDfa10_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(8, active0);
+}
+private final int jjMoveStringLiteralDfa10_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(8, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(9, active0);
+      return 10;
+   }
+   switch(curChar)
+   {
+      case 45:
+         return jjMoveStringLiteralDfa11_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(9, active0);
+}
+private final int jjMoveStringLiteralDfa11_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(9, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(10, active0);
+      return 11;
+   }
+   switch(curChar)
+   {
+      case 105:
+         return jjMoveStringLiteralDfa12_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(10, active0);
+}
+private final int jjMoveStringLiteralDfa12_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(10, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(11, active0);
+      return 12;
+   }
+   switch(curChar)
+   {
+      case 110:
+         return jjMoveStringLiteralDfa13_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(11, active0);
+}
+private final int jjMoveStringLiteralDfa13_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(11, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(12, active0);
+      return 13;
+   }
+   switch(curChar)
+   {
+      case 115:
+         return jjMoveStringLiteralDfa14_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(12, active0);
+}
+private final int jjMoveStringLiteralDfa14_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(12, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(13, active0);
+      return 14;
+   }
+   switch(curChar)
+   {
+      case 116:
+         return jjMoveStringLiteralDfa15_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(13, active0);
+}
+private final int jjMoveStringLiteralDfa15_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(13, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(14, active0);
+      return 15;
+   }
+   switch(curChar)
+   {
+      case 114:
+         return jjMoveStringLiteralDfa16_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(14, active0);
+}
+private final int jjMoveStringLiteralDfa16_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(14, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(15, active0);
+      return 16;
+   }
+   switch(curChar)
+   {
+      case 117:
+         return jjMoveStringLiteralDfa17_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(15, active0);
+}
+private final int jjMoveStringLiteralDfa17_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(15, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(16, active0);
+      return 17;
+   }
+   switch(curChar)
+   {
+      case 99:
+         return jjMoveStringLiteralDfa18_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(16, active0);
+}
+private final int jjMoveStringLiteralDfa18_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(16, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(17, active0);
+      return 18;
+   }
+   switch(curChar)
+   {
+      case 116:
+         return jjMoveStringLiteralDfa19_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(17, active0);
+}
+private final int jjMoveStringLiteralDfa19_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(17, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(18, active0);
+      return 19;
+   }
+   switch(curChar)
+   {
+      case 105:
+         return jjMoveStringLiteralDfa20_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(18, active0);
+}
+private final int jjMoveStringLiteralDfa20_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(18, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(19, active0);
+      return 20;
+   }
+   switch(curChar)
+   {
+      case 111:
+         return jjMoveStringLiteralDfa21_0(active0, 0x40000000L);
+      default :
+         break;
+   }
+   return jjStartNfa_0(19, active0);
+}
+private final int jjMoveStringLiteralDfa21_0(long old0, long active0)
+{
+   if (((active0 &= old0)) == 0L)
+      return jjStartNfa_0(19, old0); 
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) {
+      jjStopStringLiteralDfa_0(20, active0);
+      return 21;
+   }
+   switch(curChar)
+   {
+      case 110:
+         if ((active0 & 0x40000000L) != 0L)
+            return jjStartNfaWithStates_0(21, 30, 13);
+         break;
+      default :
+         break;
+   }
+   return jjStartNfa_0(20, active0);
+}
+private final void jjCheckNAdd(int state)
+{
+   if (jjrounds[state] != jjround)
+   {
+      jjstateSet[jjnewStateCnt++] = state;
+      jjrounds[state] = jjround;
+   }
+}
+private final void jjAddStates(int start, int end)
+{
+   do {
+      jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+   } while (start++ != end);
+}
+private final void jjCheckNAddTwoStates(int state1, int state2)
+{
+   jjCheckNAdd(state1);
+   jjCheckNAdd(state2);
+}
+private final void jjCheckNAddStates(int start, int end)
+{
+   do {
+      jjCheckNAdd(jjnextStates[start]);
+   } while (start++ != end);
+}
+private final void jjCheckNAddStates(int start)
+{
+   jjCheckNAdd(jjnextStates[start]);
+   jjCheckNAdd(jjnextStates[start + 1]);
+}
+static final long[] jjbitVec0 = {
+   0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec2 = {
+   0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec3 = {
+   0x0L, 0xffffffffffffc000L, 0xfffff0007fffffffL, 0x7fffffL
+};
+static final long[] jjbitVec4 = {
+   0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
+};
+static final long[] jjbitVec5 = {
+   0x7ff3ffffffffffffL, 0x7ffffffffffffdfeL, 0xffffffffffffffffL, 0xfc31ffffffffe00fL
+};
+static final long[] jjbitVec6 = {
+   0xffffffL, 0xffffffffffff0000L, 0xf80001ffffffffffL, 0x3L
+};
+static final long[] jjbitVec7 = {
+   0x0L, 0x0L, 0xfffffffbffffd740L, 0xffffd547f7fffL
+};
+static final long[] jjbitVec8 = {
+   0xffffffffffffdffeL, 0xffffffffdffeffffL, 0xffffffffffff0003L, 0x33fcfffffff199fL
+};
+static final long[] jjbitVec9 = {
+   0xfffe000000000000L, 0xfffffffe027fffffL, 0x7fL, 0x707ffffff0000L
+};
+static final long[] jjbitVec10 = {
+   0x7fffffe00000000L, 0xfffe0000000007feL, 0x7cffffffffffffffL, 0x60002f7fffL
+};
+static final long[] jjbitVec11 = {
+   0x23ffffffffffffe0L, 0x3ff000000L, 0x3c5fdfffff99fe0L, 0x30003b0000000L
+};
+static final long[] jjbitVec12 = {
+   0x36dfdfffff987e0L, 0x1c00005e000000L, 0x23edfdfffffbafe0L, 0x100000000L
+};
+static final long[] jjbitVec13 = {
+   0x23cdfdfffff99fe0L, 0x3b0000000L, 0x3bfc718d63dc7e0L, 0x0L
+};
+static final long[] jjbitVec14 = {
+   0x3effdfffffddfe0L, 0x300000000L, 0x3effdfffffddfe0L, 0x340000000L
+};
+static final long[] jjbitVec15 = {
+   0x3fffdfffffddfe0L, 0x300000000L, 0x0L, 0x0L
+};
+static final long[] jjbitVec16 = {
+   0xd7ffffffffffeL, 0x3fL, 0x200d6caefef02596L, 0x1fL
+};
+static final long[] jjbitVec17 = {
+   0x0L, 0x3fffffffeffL, 0x0L, 0x0L
+};
+static final long[] jjbitVec18 = {
+   0x0L, 0x0L, 0xffffffff00000000L, 0x7fffffffff003fL
+};
+static final long[] jjbitVec19 = {
+   0x500000000007daedL, 0x2c62ab82315001L, 0xf580c90040000000L, 0x201080000000007L
+};
+static final long[] jjbitVec20 = {
+   0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffff0fffffffL, 0x3ffffffffffffffL
+};
+static final long[] jjbitVec21 = {
+   0xffffffff3f3fffffL, 0x3fffffffaaff3f3fL, 0x5fdfffffffffffffL, 0x1fdc1fff0fcf1fdcL
+};
+static final long[] jjbitVec22 = {
+   0x4c4000000000L, 0x0L, 0x7L, 0x0L
+};
+static final long[] jjbitVec23 = {
+   0x3fe00000080L, 0xfffffffffffffffeL, 0xfffffffe001fffffL, 0x7ffffffffffffffL
+};
+static final long[] jjbitVec24 = {
+   0x1fffffffffe0L, 0x0L, 0x0L, 0x0L
+};
+static final long[] jjbitVec25 = {
+   0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffL, 0x0L
+};
+static final long[] jjbitVec26 = {
+   0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffL, 0x0L
+};
+static final long[] jjbitVec27 = {
+   0x0L, 0x0L, 0x80000000000000L, 0xff7fffffff7fffffL
+};
+static final long[] jjbitVec28 = {
+   0xffffffL, 0xffffffffffff0000L, 0xf80001ffffffffffL, 0x30003L
+};
+static final long[] jjbitVec29 = {
+   0xffffffffffffffffL, 0x30000003fL, 0xfffffffbffffd7c0L, 0xffffd547f7fffL
+};
+static final long[] jjbitVec30 = {
+   0xffffffffffffdffeL, 0xffffffffdffeffffL, 0xffffffffffff007bL, 0x33fcfffffff199fL
+};
+static final long[] jjbitVec31 = {
+   0xfffe000000000000L, 0xfffffffe027fffffL, 0xbbfffffbfffe007fL, 0x707ffffff0016L
+};
+static final long[] jjbitVec32 = {
+   0x7fffffe00000000L, 0xffff03ff0007ffffL, 0x7cffffffffffffffL, 0x3ff3dffffef7fffL
+};
+static final long[] jjbitVec33 = {
+   0xf3ffffffffffffeeL, 0xffcfff1e3fffL, 0xd3c5fdfffff99feeL, 0x3ffcfb080399fL
+};
+static final long[] jjbitVec34 = {
+   0xd36dfdfffff987e4L, 0x1fffc05e003987L, 0xf3edfdfffffbafeeL, 0xffc100003bbfL
+};
+static final long[] jjbitVec35 = {
+   0xf3cdfdfffff99feeL, 0xffc3b0c0398fL, 0xc3bfc718d63dc7ecL, 0xff8000803dc7L
+};
+static final long[] jjbitVec36 = {
+   0xc3effdfffffddfeeL, 0xffc300603ddfL, 0xc3effdfffffddfecL, 0xffc340603ddfL
+};
+static final long[] jjbitVec37 = {
+   0xc3fffdfffffddfecL, 0xffc300803dcfL, 0x0L, 0x0L
+};
+static final long[] jjbitVec38 = {
+   0x7ff7ffffffffffeL, 0x3ff7fffL, 0x3bff6caefef02596L, 0x3ff3f5fL
+};
+static final long[] jjbitVec39 = {
+   0xc2a003ff03000000L, 0xfffe03fffffffeffL, 0x2fe3ffffebf0fdfL, 0x0L
+};
+static final long[] jjbitVec40 = {
+   0x0L, 0x0L, 0x0L, 0x21fff0000L
+};
+static final long[] jjbitVec41 = {
+   0x3efffe000000a0L, 0xfffffffffffffffeL, 0xfffffffe661fffffL, 0x77ffffffffffffffL
+};
+private final int jjMoveNfa_0(int startState, int curPos)
+{
+   int[] nextStates;
+   int startsAt = 0;
+   jjnewStateCnt = 14;
+   int i = 1;
+   jjstateSet[0] = startState;
+   int j, kind = 0x7fffffff;
+   for (;;)
+   {
+      if (++jjround == 0x7fffffff)
+         ReInitRounds();
+      if (curChar < 64)
+      {
+         long l = 1L << curChar;
+         MatchLoop: do
+         {
+            switch(jjstateSet[--i])
+            {
+               case 1:
+                  if ((0x3ff000000000000L & l) != 0L)
+                  {
+                     if (kind > 16)
+                        kind = 16;
+                     jjCheckNAddTwoStates(7, 8);
+                  }
+                  else if ((0x100002600L & l) != 0L)
+                  {
+                     if (kind > 1)
+                        kind = 1;
+                     jjCheckNAdd(0);
+                  }
+                  else if (curChar == 46)
+                     jjCheckNAdd(11);
+                  else if (curChar == 39)
+                     jjCheckNAddTwoStates(5, 6);
+                  else if (curChar == 34)
+                     jjCheckNAddTwoStates(2, 3);
+                  break;
+               case 0:
+                  if ((0x100002600L & l) == 0L)
+                     break;
+                  if (kind > 1)
+                     kind = 1;
+                  jjCheckNAdd(0);
+                  break;
+               case 2:
+                  if ((0xfffffffbffffffffL & l) != 0L)
+                     jjCheckNAddTwoStates(2, 3);
+                  break;
+               case 3:
+                  if (curChar == 34 && kind > 14)
+                     kind = 14;
+                  break;
+               case 4:
+                  if (curChar == 39)
+                     jjCheckNAddTwoStates(5, 6);
+                  break;
+               case 5:
+                  if ((0xffffff7fffffffffL & l) != 0L)
+                     jjCheckNAddTwoStates(5, 6);
+                  break;
+               case 6:
+                  if (curChar == 39 && kind > 14)
+                     kind = 14;
+                  break;
+               case 7:
+                  if ((0x3ff000000000000L & l) == 0L)
+                     break;
+                  if (kind > 16)
+                     kind = 16;
+                  jjCheckNAddTwoStates(7, 8);
+                  break;
+               case 8:
+                  if (curChar != 46)
+                     break;
+                  if (kind > 16)
+                     kind = 16;
+                  jjCheckNAdd(9);
+                  break;
+               case 9:
+                  if ((0x3ff000000000000L & l) == 0L)
+                     break;
+                  if (kind > 16)
+                     kind = 16;
+                  jjCheckNAdd(9);
+                  break;
+               case 10:
+                  if (curChar == 46)
+                     jjCheckNAdd(11);
+                  break;
+               case 11:
+                  if ((0x3ff000000000000L & l) == 0L)
+                     break;
+                  if (kind > 16)
+                     kind = 16;
+                  jjCheckNAdd(11);
+                  break;
+               case 13:
+                  if ((0x3ff600000000000L & l) == 0L)
+                     break;
+                  if (kind > 31)
+                     kind = 31;
+                  jjstateSet[jjnewStateCnt++] = 13;
+                  break;
+               default : break;
+            }
+         } while(i != startsAt);
+      }
+      else if (curChar < 128)
+      {
+         long l = 1L << (curChar & 077);
+         MatchLoop: do
+         {
+            switch(jjstateSet[--i])
+            {
+               case 1:
+               case 13:
+                  if ((0x7fffffe87fffffeL & l) == 0L)
+                     break;
+                  if (kind > 31)
+                     kind = 31;
+                  jjCheckNAdd(13);
+                  break;
+               case 2:
+                  jjAddStates(0, 1);
+                  break;
+               case 5:
+                  jjAddStates(2, 3);
+                  break;
+               default : break;
+            }
+         } while(i != startsAt);
+      }
+      else
+      {
+         int hiByte = (int)(curChar >> 8);
+         int i1 = hiByte >> 6;
+         long l1 = 1L << (hiByte & 077);
+         int i2 = (curChar & 0xff) >> 6;
+         long l2 = 1L << (curChar & 077);
+         MatchLoop: do
+         {
+            switch(jjstateSet[--i])
+            {
+               case 1:
+                  if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
+                     break;
+                  if (kind > 31)
+                     kind = 31;
+                  jjCheckNAdd(13);
+                  break;
+               case 2:
+                  if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+                     jjAddStates(0, 1);
+                  break;
+               case 5:
+                  if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+                     jjAddStates(2, 3);
+                  break;
+               case 13:
+                  if (!jjCanMove_2(hiByte, i1, i2, l1, l2))
+                     break;
+                  if (kind > 31)
+                     kind = 31;
+                  jjCheckNAdd(13);
+                  break;
+               default : break;
+            }
+         } while(i != startsAt);
+      }
+      if (kind != 0x7fffffff)
+      {
+         jjmatchedKind = kind;
+         jjmatchedPos = curPos;
+         kind = 0x7fffffff;
+      }
+      ++curPos;
+      if ((i = jjnewStateCnt) == (startsAt = 14 - (jjnewStateCnt = startsAt)))
+         return curPos;
+      try { curChar = input_stream.readChar(); }
+      catch(java.io.IOException e) { return curPos; }
+   }
+}
+static final int[] jjnextStates = {
+   2, 3, 5, 6, 
+};
+private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
+{
+   switch(hiByte)
+   {
+      case 0:
+         return ((jjbitVec2[i2] & l2) != 0L);
+      default : 
+         if ((jjbitVec0[i1] & l1) != 0L)
+            return true;
+         return false;
+   }
+}
+private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
+{
+   switch(hiByte)
+   {
+      case 0:
+         return ((jjbitVec4[i2] & l2) != 0L);
+      case 1:
+         return ((jjbitVec5[i2] & l2) != 0L);
+      case 2:
+         return ((jjbitVec6[i2] & l2) != 0L);
+      case 3:
+         return ((jjbitVec7[i2] & l2) != 0L);
+      case 4:
+         return ((jjbitVec8[i2] & l2) != 0L);
+      case 5:
+         return ((jjbitVec9[i2] & l2) != 0L);
+      case 6:
+         return ((jjbitVec10[i2] & l2) != 0L);
+      case 9:
+         return ((jjbitVec11[i2] & l2) != 0L);
+      case 10:
+         return ((jjbitVec12[i2] & l2) != 0L);
+      case 11:
+         return ((jjbitVec13[i2] & l2) != 0L);
+      case 12:
+         return ((jjbitVec14[i2] & l2) != 0L);
+      case 13:
+         return ((jjbitVec15[i2] & l2) != 0L);
+      case 14:
+         return ((jjbitVec16[i2] & l2) != 0L);
+      case 15:
+         return ((jjbitVec17[i2] & l2) != 0L);
+      case 16:
+         return ((jjbitVec18[i2] & l2) != 0L);
+      case 17:
+         return ((jjbitVec19[i2] & l2) != 0L);
+      case 30:
+         return ((jjbitVec20[i2] & l2) != 0L);
+      case 31:
+         return ((jjbitVec21[i2] & l2) != 0L);
+      case 33:
+         return ((jjbitVec22[i2] & l2) != 0L);
+      case 48:
+         return ((jjbitVec23[i2] & l2) != 0L);
+      case 49:
+         return ((jjbitVec24[i2] & l2) != 0L);
+      case 159:
+         return ((jjbitVec25[i2] & l2) != 0L);
+      case 215:
+         return ((jjbitVec26[i2] & l2) != 0L);
+      default : 
+         if ((jjbitVec3[i1] & l1) != 0L)
+            return true;
+         return false;
+   }
+}
+private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2)
+{
+   switch(hiByte)
+   {
+      case 0:
+         return ((jjbitVec27[i2] & l2) != 0L);
+      case 1:
+         return ((jjbitVec5[i2] & l2) != 0L);
+      case 2:
+         return ((jjbitVec28[i2] & l2) != 0L);
+      case 3:
+         return ((jjbitVec29[i2] & l2) != 0L);
+      case 4:
+         return ((jjbitVec30[i2] & l2) != 0L);
+      case 5:
+         return ((jjbitVec31[i2] & l2) != 0L);
+      case 6:
+         return ((jjbitVec32[i2] & l2) != 0L);
+      case 9:
+         return ((jjbitVec33[i2] & l2) != 0L);
+      case 10:
+         return ((jjbitVec34[i2] & l2) != 0L);
+      case 11:
+         return ((jjbitVec35[i2] & l2) != 0L);
+      case 12:
+         return ((jjbitVec36[i2] & l2) != 0L);
+      case 13:
+         return ((jjbitVec37[i2] & l2) != 0L);
+      case 14:
+         return ((jjbitVec38[i2] & l2) != 0L);
+      case 15:
+         return ((jjbitVec39[i2] & l2) != 0L);
+      case 16:
+         return ((jjbitVec18[i2] & l2) != 0L);
+      case 17:
+         return ((jjbitVec19[i2] & l2) != 0L);
+      case 30:
+         return ((jjbitVec20[i2] & l2) != 0L);
+      case 31:
+         return ((jjbitVec21[i2] & l2) != 0L);
+      case 32:
+         return ((jjbitVec40[i2] & l2) != 0L);
+      case 33:
+         return ((jjbitVec22[i2] & l2) != 0L);
+      case 48:
+         return ((jjbitVec41[i2] & l2) != 0L);
+      case 49:
+         return ((jjbitVec24[i2] & l2) != 0L);
+      case 159:
+         return ((jjbitVec25[i2] & l2) != 0L);
+      case 215:
+         return ((jjbitVec26[i2] & l2) != 0L);
+      default : 
+         if ((jjbitVec3[i1] & l1) != 0L)
+            return true;
+         return false;
+   }
+}
+public static final String[] jjstrLiteralImages = {
+"", null, "\57", "\57\57", "\174", "\53", "\55", "\75", "\41\75", "\74", 
+"\74\75", "\76", "\76\75", "\44", null, null, null, null, null, null, null, null, null, 
+"\157\162", "\141\156\144", "\155\157\144", "\144\151\166", "\156\157\144\145", 
+"\164\145\170\164", "\143\157\155\155\145\156\164", 
+"\160\162\157\143\145\163\163\151\156\147\55\151\156\163\164\162\165\143\164\151\157\156", null, "\72", "\72\72", "\50", "\51", "\133", "\135", "\56", "\56\56", "\100", 
+"\54", "\52", "\73", };
+public static final String[] lexStateNames = {
+   "DEFAULT", 
+};
+static final long[] jjtoToken = {
+   0xfffff817ffdL, 
+};
+static final long[] jjtoSkip = {
+   0x2L, 
+};
+static final long[] jjtoSpecial = {
+   0x2L, 
+};
+private UCode_CharStream input_stream;
+private final int[] jjrounds = new int[14];
+private final int[] jjstateSet = new int[28];
+protected char curChar;
+public XPathParserTokenManager(UCode_CharStream stream)
+{
+   if (UCode_CharStream.staticFlag)
+      throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
+   input_stream = stream;
+}
+public XPathParserTokenManager(UCode_CharStream stream, int lexState)
+{
+   this(stream);
+   SwitchTo(lexState);
+}
+public void ReInit(UCode_CharStream stream)
+{
+   jjmatchedPos = jjnewStateCnt = 0;
+   curLexState = defaultLexState;
+   input_stream = stream;
+   ReInitRounds();
+}
+private final void ReInitRounds()
+{
+   int i;
+   jjround = 0x80000001;
+   for (i = 14; i-- > 0;)
+      jjrounds[i] = 0x80000000;
+}
+public void ReInit(UCode_CharStream stream, int lexState)
+{
+   ReInit(stream);
+   SwitchTo(lexState);
+}
+public void SwitchTo(int lexState)
+{
+   if (lexState >= 1 || lexState < 0)
+      throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+   else
+      curLexState = lexState;
+}
+
+private final Token jjFillToken()
+{
+   Token t = Token.newToken(jjmatchedKind);
+   t.kind = jjmatchedKind;
+   String im = jjstrLiteralImages[jjmatchedKind];
+   t.image = (im == null) ? input_stream.GetImage() : im;
+   t.beginLine = input_stream.getBeginLine();
+   t.beginColumn = input_stream.getBeginColumn();
+   t.endLine = input_stream.getEndLine();
+   t.endColumn = input_stream.getEndColumn();
+   return t;
+}
+
+int curLexState = 0;
+int defaultLexState = 0;
+int jjnewStateCnt;
+int jjround;
+int jjmatchedPos;
+int jjmatchedKind;
+
+public final Token getNextToken() 
+{
+  int kind;
+  Token specialToken = null;
+  Token matchedToken;
+  int curPos = 0;
+
+  EOFLoop :
+  for (;;)
+  {   
+   try   
+   {     
+      curChar = input_stream.BeginToken();
+   }     
+   catch(java.io.IOException e)
+   {        
+      jjmatchedKind = 0;
+      matchedToken = jjFillToken();
+      matchedToken.specialToken = specialToken;
+      return matchedToken;
+   }
+
+   jjmatchedKind = 0x7fffffff;
+   jjmatchedPos = 0;
+   curPos = jjMoveStringLiteralDfa0_0();
+   if (jjmatchedKind != 0x7fffffff)
+   {
+      if (jjmatchedPos + 1 < curPos)
+         input_stream.backup(curPos - jjmatchedPos - 1);
+      if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+      {
+         matchedToken = jjFillToken();
+         matchedToken.specialToken = specialToken;
+         return matchedToken;
+      }
+      else
+      {
+         if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
+         {
+            matchedToken = jjFillToken();
+            if (specialToken == null)
+               specialToken = matchedToken;
+            else
+            {
+               matchedToken.specialToken = specialToken;
+               specialToken = (specialToken.next = matchedToken);
+            }
+         }
+         continue EOFLoop;
+      }
+   }
+   int error_line = input_stream.getEndLine();
+   int error_column = input_stream.getEndColumn();
+   String error_after = null;
+   boolean EOFSeen = false;
+   try { input_stream.readChar(); input_stream.backup(1); }
+   catch (java.io.IOException e1) {
+      EOFSeen = true;
+      error_after = curPos <= 1 ? "" : input_stream.GetImage();
+      if (curChar == '\n' || curChar == '\r') {
+         error_line++;
+         error_column = 0;
+      }
+      else
+         error_column++;
+   }
+   if (!EOFSeen) {
+      input_stream.backup(1);
+      error_after = curPos <= 1 ? "" : input_stream.GetImage();
+   }
+   throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+  }
+}
+
+}

Propchange: incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/XPathParserTokenManager.java
------------------------------------------------------------------------------
    svn:executable = 

Added: incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/package.html
URL: http://svn.apache.org/viewcvs/incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/package.html?rev=230871&view=auto
==============================================================================
--- incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/package.html (added)
+++ incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/package.html Mon Aug  8 12:58:58 2005
@@ -0,0 +1,8 @@
+<html>
+<!-- $Id: package.html,v 1.1 2002/08/30 14:53:20 mark Exp $ -->
+<body>
+
+(INTERNAL) May only be used by <code>org.apache.tsik.xpath</code> packages.
+
+</body>
+</html>

Propchange: incubator/tsik/trunk/src/org/apache/tsik/xpath/parser/package.html
------------------------------------------------------------------------------
    svn:executable = 

Added: incubator/tsik/trunk/src/org/apache/tsik/xpath/util/Coerce.java
URL: http://svn.apache.org/viewcvs/incubator/tsik/trunk/src/org/apache/tsik/xpath/util/Coerce.java?rev=230871&view=auto
==============================================================================
--- incubator/tsik/trunk/src/org/apache/tsik/xpath/util/Coerce.java (added)
+++ incubator/tsik/trunk/src/org/apache/tsik/xpath/util/Coerce.java Mon Aug  8 12:58:58 2005
@@ -0,0 +1,237 @@
+// $Id$
+
+//
+// (C) Copyright 2005 VeriSign, Inc.  All Rights Reserved.
+//
+// VeriSign, Inc. shall have no responsibility, financial or
+// otherwise, for any consequences arising out of the use of
+// this material. The program material is provided on an "AS IS"
+// BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+// express or implied. The user is responsible for determining
+// any necessary third party rights or authorizations that may
+// be required for the use of the materials. Users are advised 
+// that they may need authorizations under certain patents from 
+// Microsoft and IBM, or others. Please see notice.txt file. 
+// VeriSign disclaims any obligation to notify the user of any 
+// such third party rights.
+//
+
+package org.apache.tsik.xpath.util;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.ParseException;
+
+public class Coerce 
+{
+    /* Prevent construction. */
+    private Coerce() {}
+
+    private static DecimalFormat dfInteger;
+    private static DecimalFormat dfReal;
+
+    static {
+	DecimalFormatSymbols dfs = new DecimalFormatSymbols();
+	dfs.setDecimalSeparator('.');
+	dfs.setMinusSign('-');
+	dfs.setZeroDigit('0');
+	dfInteger = new DecimalFormat("0;-0", dfs);
+	dfReal = new DecimalFormat("0.0;-0.0", dfs);
+    }
+
+    public static Boolean toBoolean(Object arg) {
+	if(arg == null) {
+	    return Boolean.FALSE;
+	} else if(arg instanceof Boolean) {
+	    return (Boolean)arg;
+	} else if(arg instanceof Number) {
+	    double x = ((Number)arg).doubleValue();
+	    return new Boolean(!(Double.isNaN(x) || x == 0.0));
+	} else if(arg instanceof NodeSet) {
+	    NodeSet x = (NodeSet)arg;
+	    return new Boolean(x.size() > 0);
+	} else if(arg instanceof String) {
+	    String x = (String)arg;
+	    return new Boolean(x.length() > 0);
+	} else {
+	    /* kinda hard to do something sensible with an arbitrary object */
+	    return Boolean.TRUE;
+	}
+    }
+
+    private static int[] getNodePath(Node node, int depth)
+    {
+	Node parent = node.getParentNode();
+	int[] path;
+
+	if(parent == null)
+	    path = new int[depth];
+	else
+	    path = getNodePath(parent, depth + 1);
+
+	int pos = 0;
+	while(node != null) {
+	    pos++;
+	    node = node.getPreviousSibling();
+	}
+	path[path.length - depth] = pos;
+	return path;
+    }
+
+    public static int[] getNodePath(Node node)
+    {
+	return getNodePath(node, 1);
+    }
+
+    private static int compareNodePaths(int[] a, int[] b)
+    {
+	int i;
+	for(i = 0; i < a.length && i < b.length; i++) {
+	    if(a[i] < b[i])
+		return -1;
+	    else if(a[i] > b[i])
+		return 1;
+	}
+	if(a.length < b.length)
+	    return -1;
+	else if(a.length > b.length)
+	    return 1;
+	return 0;
+    }
+
+    public static Node getFirstNodeDocumentOrder(NodeList nl)
+    {
+	Node curnode, newnode;
+	int i, l;
+	int[] curpath, newpath;
+
+	l = nl.getLength();
+	if(l == 0)
+	    return null;
+	if(l == 1)
+	    return nl.item(0);
+	curnode = nl.item(0);
+	curpath = getNodePath(curnode);
+	for(i = 1; i < l; i++) {
+	    newnode = nl.item(i);
+	    newpath = getNodePath(newnode);
+	    if(compareNodePaths(curpath, newpath) < 0) {
+		curnode = newnode;
+		curpath = newpath;
+	    }
+	}
+	return curnode;
+    }
+
+    private static void collectText(Node node, StringBuffer sb)
+    {
+	switch(node.getNodeType())
+	    {
+	    case Node.TEXT_NODE:
+	    case Node.CDATA_SECTION_NODE:
+		sb.append(node.getNodeValue());
+		break;
+	    default:
+		node = node.getFirstChild();
+		while(node != null) {
+		    collectText(node, sb);
+		    node = node.getNextSibling();
+		}
+	    }
+    }
+
+    public static String stringValueOfNode(Node node)
+    {
+	StringBuffer sb;
+
+	if(node == null)
+	    return "";
+
+	switch(node.getNodeType()) 
+	    {
+	    case Node.DOCUMENT_NODE:
+	    case Node.DOCUMENT_FRAGMENT_NODE:
+	    case Node.ELEMENT_NODE:
+		sb = new StringBuffer();
+		collectText(node, sb);
+		return sb.toString();
+	    default:
+		return node.getNodeValue();
+	    }
+    }
+
+    public static String toString(Object arg)
+    {
+	if(arg == null) {
+	    return "";
+	} else if(arg instanceof String) {
+	    return (String)arg;
+	} else if(arg instanceof Number) {
+	    double x = ((Number)arg).doubleValue();
+	    if(Double.isNaN(x)) {
+		return "NaN";
+	    } else if(x == 0.0) {
+		return "0";
+	    } else if(x == Double.POSITIVE_INFINITY) {
+		return "Infinity";
+	    } else if(x == Double.NEGATIVE_INFINITY) {
+		return "-Infinity";
+	    } else {
+		StringBuffer sb = new StringBuffer();
+		DecimalFormat df;
+		if(x == Math.rint(x)) {
+		    df = dfInteger;
+		} else {
+		    df = dfReal;
+		}
+		return df.format(x);
+	    }
+	} else if(arg instanceof Boolean) {
+	    if(((Boolean)arg).booleanValue()) {
+		return "true";
+	    } else {
+		return "false";
+	    }
+	} else if(arg instanceof NodeSet) {
+	    NodeSet ns = (NodeSet)arg;
+	    if(ns.size() > 0)
+		return stringValueOfNode((Node) ns.iterator().next());
+	    else
+		return "";
+	} else if(arg instanceof NodeList) {
+	    NodeList nl = (NodeList)arg;
+	    if(nl.getLength() > 0)
+		return stringValueOfNode(nl.item(0));
+	    else
+		return "";
+	} else {
+	    return arg.toString();
+	}
+    }
+
+    public static Number toNumber(Object arg)
+    {
+	if(arg instanceof Number) {
+	    return (Number)arg;
+	} else if(arg instanceof Boolean) {
+	    if(((Boolean)arg).booleanValue()) {
+		return new Double(1);
+	    } else {
+		return new Double(0);
+	    }
+	} else if(arg instanceof String) {
+	    // UNDONE: To be strictly correct, we should reject
+	    // anything that doesn't match the XPath "Number"
+	    // production.
+	    try {
+		return dfReal.parse((String)arg);
+	    } catch(ParseException ex) {
+		return new Double(Double.NaN);
+	    }
+	} else {
+	    return toNumber(toString(arg));
+	}
+    }
+}

Propchange: incubator/tsik/trunk/src/org/apache/tsik/xpath/util/Coerce.java
------------------------------------------------------------------------------
    svn:executable = 

Added: incubator/tsik/trunk/src/org/apache/tsik/xpath/util/DocumentOrderComparator.java
URL: http://svn.apache.org/viewcvs/incubator/tsik/trunk/src/org/apache/tsik/xpath/util/DocumentOrderComparator.java?rev=230871&view=auto
==============================================================================
--- incubator/tsik/trunk/src/org/apache/tsik/xpath/util/DocumentOrderComparator.java (added)
+++ incubator/tsik/trunk/src/org/apache/tsik/xpath/util/DocumentOrderComparator.java Mon Aug  8 12:58:58 2005
@@ -0,0 +1,221 @@
+// $Id$
+
+//
+// (C) Copyright 2005 VeriSign, Inc.  All Rights Reserved.
+//
+// VeriSign, Inc. shall have no responsibility, financial or
+// otherwise, for any consequences arising out of the use of
+// this material. The program material is provided on an "AS IS"
+// BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+// express or implied. The user is responsible for determining
+// any necessary third party rights or authorizations that may
+// be required for the use of the materials. Users are advised 
+// that they may need authorizations under certain patents from 
+// Microsoft and IBM, or others. Please see notice.txt file. 
+// VeriSign disclaims any obligation to notify the user of any 
+// such third party rights.
+//
+
+package org.apache.tsik.xpath.util;
+
+import java.io.Serializable;
+import java.util.*;
+import org.w3c.dom.*;
+
+public final class DocumentOrderComparator implements Comparator, Serializable
+{
+    static Object lock = new Object();
+    static WeakHashMap docOrdinals = new WeakHashMap();
+    static int lastDocOrdinal = 0;
+    static final DocumentOrderComparator theInstance = new DocumentOrderComparator();
+
+    /** Gets the true parent of a node.  This is its owner element if
+     *	the node is an attribute, or its parent node otherwise. */
+    static Node parent(Node n)
+    {
+	if(n.getNodeType() == Node.ATTRIBUTE_NODE)
+	    return ((Attr)n).getOwnerElement();
+	else
+	    return n.getParentNode();
+    }
+
+    /** Gets the depth of a node.  This is the number of times one may
+     *  traverse up the tree with parent() without it returning null. */
+    static int depth(Node n)
+    {
+	int depth;
+	for(depth = -1; n != null; n = parent(n), depth++);
+	return depth;
+    }
+
+    /** Gets the Document object associated with a Node. */
+    static Document document(Node n)
+    {
+	if(n.getNodeType() == Node.DOCUMENT_NODE)
+	    return (Document)n;
+	else
+	    return n.getOwnerDocument();
+    }
+
+    /** Gets a Node's ordinal position in its sibling list. */
+    static int siblingOrdinal(Node n)
+    {
+	int i = 0;
+	while((n = n.getPreviousSibling()) != null) i++;
+	return i;
+    }
+
+    /** Compares two nodes for document order, assuming they are siblings. */
+    static int compareDocumentOrderSibling(Node a, Node b)
+    {
+	short atype = a.getNodeType(), btype = b.getNodeType();
+	if(atype == Node.ATTRIBUTE_NODE && btype != Node.ATTRIBUTE_NODE)
+	    return -1;
+	else if(atype != Node.ATTRIBUTE_NODE && btype == Node.ATTRIBUTE_NODE)
+	    return 1;
+	else if(atype == Node.ATTRIBUTE_NODE)
+	    return a.getNodeName().compareTo(b.getNodeName());
+	else {
+	    int aord = siblingOrdinal(a), bord = siblingOrdinal(b);
+	    if(aord < bord)
+		return -1;
+	    else if(aord > bord)
+		return 1;
+	    else
+		return 0;
+	}
+    }
+
+    /** Compares two nodes for document order, assuming they are at the same depth. */
+    static int compareDocumentOrderSameLevel(Node a, Node b)
+    {
+	Node ap = parent(a), bp = parent(b);
+	int r;
+
+	if(ap == bp)
+	    return compareDocumentOrderSibling(a, b);
+
+	r = compareDocumentOrderSameLevel(ap, bp);
+
+	/* If r == 0 here, someone's handing us tear-off proxy
+	   objects, fouling up reference comparisons. */
+	if(r == 0)
+	    return compareDocumentOrderSibling(a, b);
+	else
+	    return r;
+    }
+
+    /** Returns an ordinal number for a document object. */
+    static int documentOrdinal(Document doc)
+    {
+	synchronized(lock) {
+	    Integer ord = (Integer) docOrdinals.get(doc);
+
+	    if(ord == null) {
+
+		/* We haven't found it, allocate it a new number. */
+
+		if(lastDocOrdinal == Integer.MAX_VALUE) {
+
+		    /* Ack! We ran out of numbers.  Renumber. */
+
+		    TreeMap tm = new TreeMap();
+		    Iterator it;
+		    Map.Entry e;
+
+		    it = docOrdinals.entrySet().iterator();
+		    while(it.hasNext()) {
+			e = (Map.Entry) it.next();
+			tm.put(e.getValue(), e.getKey());
+		    }
+
+		    lastDocOrdinal = 0;
+		    docOrdinals.clear();
+
+		    it = tm.entrySet().iterator();
+		    while(it.hasNext()) {
+			e = (Map.Entry) it.next();
+			docOrdinals.put(e.getValue(), new Integer(++lastDocOrdinal));
+		    }
+		}
+
+		docOrdinals.put(doc, new Integer(++lastDocOrdinal));
+		return lastDocOrdinal;
+	    } else {
+		/* Found it. */
+		return ord.intValue();
+	    }
+	}
+    }
+
+    /** Compares two Nodes for document order. */
+    public static int compareDocumentOrder(Node a, Node b)
+    {
+	int adepth, bdepth, depthcomp = 0, r;
+	Node ap, bp, n;
+	Document adoc, bdoc;
+
+	/* Quickie/common cases. */
+	if(a == b)
+	    return 0;
+	if(parent(a) == parent(b))
+	    return compareDocumentOrderSibling(a, b);
+
+	adoc = document(a);
+	bdoc = document(b);
+	if(adoc != bdoc) {
+	    int aord = documentOrdinal(adoc);
+	    int bord = documentOrdinal(bdoc);
+	    if(aord < bord)
+		return -1;
+	    else if(aord > bord)
+		return 1;
+	}
+
+	adepth = depth(a);
+	bdepth = depth(b);
+
+	if(adepth < bdepth) {
+	    depthcomp = -1;
+	    while(adepth < bdepth) {
+		b = parent(b);
+		bdepth--;
+	    }
+	} else if(adepth > bdepth) {
+	    depthcomp = 1;
+	    while(adepth > bdepth) {
+		a = parent(a);
+		adepth--;
+	    }
+	}
+
+	r = compareDocumentOrderSameLevel(a, b);
+	if(r == 0) r = depthcomp;
+	return r;
+    }
+
+    /** Compares two Nodes for document order. */
+    public int compare(Object o1, Object o2)
+    {
+	Node n1 = (Node) o1;
+	Node n2 = (Node) o2;
+
+	return compareDocumentOrder(n1, n2);
+    }
+
+    /** Returns true if the specified Object is a Comparator known to
+        impose the same ordering as this one. */
+    public boolean equals(Object obj)
+    {
+	return (obj instanceof DocumentOrderComparator);
+    }
+
+    /** Default constructor. */
+    DocumentOrderComparator() {}
+
+    /** Factory method. */
+    public static DocumentOrderComparator getInstance()
+    {
+	return theInstance;
+    }
+}

Propchange: incubator/tsik/trunk/src/org/apache/tsik/xpath/util/DocumentOrderComparator.java
------------------------------------------------------------------------------
    svn:executable = 

Added: incubator/tsik/trunk/src/org/apache/tsik/xpath/util/ExpandedName.java
URL: http://svn.apache.org/viewcvs/incubator/tsik/trunk/src/org/apache/tsik/xpath/util/ExpandedName.java?rev=230871&view=auto
==============================================================================
--- incubator/tsik/trunk/src/org/apache/tsik/xpath/util/ExpandedName.java (added)
+++ incubator/tsik/trunk/src/org/apache/tsik/xpath/util/ExpandedName.java Mon Aug  8 12:58:58 2005
@@ -0,0 +1,84 @@
+// $Id$
+
+//
+// (C) Copyright 2005 VeriSign, Inc.  All Rights Reserved.
+//
+// VeriSign, Inc. shall have no responsibility, financial or
+// otherwise, for any consequences arising out of the use of
+// this material. The program material is provided on an "AS IS"
+// BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+// express or implied. The user is responsible for determining
+// any necessary third party rights or authorizations that may
+// be required for the use of the materials. Users are advised 
+// that they may need authorizations under certain patents from 
+// Microsoft and IBM, or others. Please see notice.txt file. 
+// VeriSign disclaims any obligation to notify the user of any 
+// such third party rights.
+//
+
+package org.apache.tsik.xpath.util;
+
+import java.util.Map;
+
+public final class ExpandedName implements java.io.Serializable
+{
+    private String namespaceURI;
+    private String localName;
+
+    public ExpandedName()
+    {
+	this((String)null, (String)null);
+    }
+
+    public ExpandedName(String localName)
+    {
+	this((String)null, localName);
+    }
+
+    public ExpandedName(String namespaceURI, String localName)
+    {
+	this.namespaceURI = namespaceURI;
+	this.localName = localName;
+    }
+
+    public ExpandedName(QualifiedName qname, Map namespaces)
+    {
+	this((String)namespaces.get(qname.getPrefix()), qname.getLocalName());
+    }
+
+    public String getNamespaceURI()
+    {
+	return namespaceURI;
+    }
+
+    public String getLocalName()
+    {
+	return localName;
+    }
+
+    public boolean equals(Object ob)
+    {
+	if(ob instanceof ExpandedName) {
+	    ExpandedName n = (ExpandedName) ob;
+	    return (((localName == null && n.localName == null) ||
+		     (localName != null && localName.equals(n.localName))) &&
+		    ((namespaceURI == null && n.namespaceURI == null) ||
+		     (namespaceURI != null 
+		      && namespaceURI.equals(n.namespaceURI))));
+	} else {
+	    return false;
+	}
+    }
+
+    public int hashCode()
+    {
+	return ((namespaceURI == null ? 0 : namespaceURI.hashCode())
+		+ (localName == null ? 0 : localName.hashCode()));
+    }
+
+    public String toString()
+    {
+	return "\"" + namespaceURI + "\":" + localName;
+    }
+}
+

Propchange: incubator/tsik/trunk/src/org/apache/tsik/xpath/util/ExpandedName.java
------------------------------------------------------------------------------
    svn:executable = 



---------------------------------------------------------------------
To unsubscribe, e-mail: tsik-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tsik-dev-help@ws.apache.org


Mime
View raw message