xpath/trunk/resources/parser.txt
changeset 0 5057afe1ec87
equal deleted inserted replaced
-1:000000000000 0:5057afe1ec87
       
     1 LocationPath:
       
     2 		  RelativeLocationPath
       
     3 			{ '1' }
       
     4 		| AbsoluteLocationPath
       
     5 			{ '1' }
       
     6 		;
       
     7 	
       
     8 AbsoluteLocationPath :
       
     9 		  "/" RelativeLocationPath
       
    10 			{ '2' absolute: true; yourself }
       
    11 		| "/"
       
    12 			{ XMLv2::XPathExpression new absolute: true }
       
    13 		| AbbreviatedAbsoluteLocationPath
       
    14 			{ '1' }
       
    15 		;
       
    16 
       
    17 AbbreviatedAbsoluteLocationPath:
       
    18 		"//" RelativeLocationPath
       
    19 			{ '2'
       
    20 				addFirst:
       
    21 			    	(XMLv2::XPathLocationStep new
       
    22 			        	axis: XMLv2::XPathAxisDescendantOrSelf new;
       
    23 						nodeTest: XMLv2::XPathAnyKindTest new);
       
    24 				yourself }
       
    25 		;
       
    26 			
       
    27 RelativeLocationPath:
       
    28 		  Step
       
    29 			{ XMLv2::XPathExpression with: '1' }
       
    30 		| RelativeLocationPath "/" Step
       
    31 			{ '1' add:'3'; yourself }
       
    32 		| AbbreviatedRelativeLocationPath
       
    33 			{ '1' }
       
    34 		;
       
    35 		
       
    36 AbbreviatedRelativeLocationPath:
       
    37 		RelativeLocationPath "//" Step
       
    38 			{ '1'
       
    39 				add:
       
    40 					(XMLv2::XPathLocationStep new
       
    41 						axis: XMLv2::XPathAxisDescendantOrSelf new;
       
    42 			            nodeTest: XMLv2::XPathAnyKindTest new);
       
    43 				add: '3';
       
    44 				yourself }
       
    45 		;
       
    46 
       
    47 	
       
    48 Step:
       
    49 		  AxisSpecifier NodeTest Predicate*
       
    50 			{ XMLv2::XPathLocationStep new
       
    51 			            axis: '1';
       
    52 			            nodeTest: '2';
       
    53 			            predicates: '3';
       
    54 			            yourself }
       
    55 		| "."
       
    56 			{ XMLv2::XPathLocationStep new
       
    57 			            axis: XMLv2::XPathAxisSelf new;
       
    58 			            nodeTest: XMLv2::XPathAnyKindTest new;
       
    59 			            yourself }
       
    60 
       
    61 		| ".."
       
    62 			{ XMLv2::XPathLocationStep new
       
    63 			            axis: XMLv2::XPathAxisParent new;
       
    64 			            nodeTest: XMLv2::XPathAnyKindTest new;
       
    65 			            yourself }
       
    66 
       
    67 		| <NCName>
       
    68 			{ XMLv2::XPathLocationStep new
       
    69 			            axis: XMLv2::XPathAxisChild new;
       
    70 			            nodeTest: (XMLv2::XPathNameTest new
       
    71 			                                    localName:'1' value);
       
    72 			            yourself }
       
    73 		;
       
    74 			
       
    75 	
       
    76 AxisSpecifier:
       
    77 	  ExplicitAxisSpecifier "::"
       
    78 		{ '1' }
       
    79 		| "@"
       
    80 			{ XMLv2::XPathAxisAttribute new }
       
    81 		;
       
    82 
       
    83 ExplicitAxisSpecifier:
       
    84 		  "ancestor"
       
    85 			{ XMLv2::XPathAxisAncestor new }
       
    86 		| "ancestor-or-self"
       
    87 			{ XMLv2::XPathAxisAncestorOrSelf new }
       
    88 		| "attribute"
       
    89 			{ XMLv2::XPathAxisAttribute new }
       
    90 		| "child"
       
    91 			{ XMLv2::XPathAxisChild new }
       
    92 		| "descendant"
       
    93 			{ XMLv2::XPathAxisDescendant new }
       
    94 		| "descendant-or-self"
       
    95 			{ XMLv2::XPathAxisDescendantOrSelf new }
       
    96 		| "following"
       
    97 			{ XMLv2::XPathAxisFollowing new }
       
    98 		| "following-sibling"
       
    99 			{ XMLv2::XPathAxisFollowingSibling new }
       
   100 		| "namespace"
       
   101 			{ XMLv2::XPathAxisNamespace new }
       
   102 		| "parent"
       
   103 			{ XMLv2::XPathAxisParent new }
       
   104 		| "preceding"
       
   105 			{ XMLv2::XPathAxisPreceding new }
       
   106 		| "preceding-sibling"
       
   107 			{ XMLv2::XPathAxisPrecedingSibling new }
       
   108 		| "self"
       
   109 			{ XMLv2::XPathAxisSelf new }
       
   110 		;
       
   111 
       
   112 NodeTest:
       
   113 		  NameTest
       
   114 			{ '1' }
       
   115 		| KindTest
       
   116 			{ '1' }
       
   117 		;
       
   118 		
       
   119 NameTest:
       
   120 		  <NCName>
       
   121 			{ XMLv2::XPathNameTest new
       
   122 			            localName:'1' value }
       
   123 		| "*"
       
   124 			{ XMLv2::XPathNameTest new
       
   125 			            localName:'*'; prefix:'*' }
       
   126 		| "*" ":" <NCName>
       
   127 			{ XMLv2::XPathNameTest new
       
   128 			            localName:'*'; prefix:'1' value }
       
   129 		| <NCName> ":" "*"
       
   130 			{ XMLv2::XPathNameTest new
       
   131 			            localName:'1' value; prefix:'*' }
       
   132 		;
       
   133 		
       
   134 KindTest:
       
   135 		| "node" "(" ")"
       
   136 			{ XMLv2::XPathAnyKindTest new }
       
   137 		| "document-element" "(" ")"
       
   138 			{ XMLv2::XPathDocumentTest new }
       
   139 		| "element" "(" ")"
       
   140 			{ XMLv2::XPathElementTest new }
       
   141 		| "attribute" "(" ")"
       
   142 			{ XMLv2::XPathAttributeTest new }
       
   143 		| "text" "(" ")"
       
   144 			{ XMLv2::XPathTextTest new }
       
   145 		| "comment" "(" ")"
       
   146 			{ XMLv2::XPathCommentTest new }
       
   147 		| "processing-instruction" "(" ")"
       
   148 			{ XMLv2::XPathProcessingInstructionTest new }
       
   149 		;
       
   150 		
       
   151 
       
   152 Predicate:
       
   153 	"[" "]"
       
   154 		{ XMLv2::XPathPredicate new }
       
   155 		;