2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
23 cpsPath: (cpsPathWithSingleLeafCondition | cpsPathWithDescendant | cpsPathWithDescendantAndLeafConditions) ancestorAxis? ;
25 ancestorAxis: SLASH KW_ANCESTOR COLONCOLON ancestorPath ;
27 ancestorPath: yangElement (SLASH yangElement)* ;
29 cpsPathWithSingleLeafCondition: prefix singleValueCondition postfix? ;
32 No need to ditinguish between cpsPathWithDescendant | cpsPathWithDescendantAndLeafConditions really!
33 See https://jira.onap.org/browse/CPS-436
36 cpsPathWithDescendant: descendant ;
38 cpsPathWithDescendantAndLeafConditions: descendant multipleValueConditions ;
40 descendant: SLASH prefix ;
42 prefix: (SLASH yangElement)* SLASH containerName ;
44 postfix: (SLASH yangElement)+ ;
46 yangElement: containerName listElementRef? ;
48 containerName: QName ;
50 listElementRef: multipleValueConditions ;
52 singleValueCondition: '[' leafCondition ']' ;
54 multipleValueConditions: '[' leafCondition (' and ' leafCondition)* ']' ;
56 leafCondition: '@' leafName '=' (IntegerLiteral | StringLiteral ) ;
58 //To Confirm: defintion of Lefname with external xPath grammar
63 * Most of the lexer rules below are 'imporetd' from
64 * https://raw.githubusercontent.com/antlr/grammars-v4/master/xpath/xpath31/XPath31.g4
72 KW_ANCESTOR : 'ancestor' ;
74 IntegerLiteral : FragDigits ;
75 // Add below type definitions for leafvalue comparision in https://jira.onap.org/browse/CPS-440
76 DecimalLiteral : ('.' FragDigits) | (FragDigits '.' [0-9]*) ;
77 DoubleLiteral : (('.' FragDigits) | (FragDigits ('.' [0-9]*)?)) [eE] [+-]? FragDigits ;
78 StringLiteral : ('"' (FragEscapeQuot | ~[^"])*? '"') | ('\'' (FragEscapeApos | ~['])*? '\'') ;
79 fragment FragEscapeQuot : '""' ;
80 fragment FragEscapeApos : '\'';
81 fragment FragDigits : [0-9]+ ;
84 NCName : FragmentNCName ;
85 fragment FragQName : FragPrefixedName | FragUnprefixedName ;
86 fragment FragPrefixedName : FragPrefix ':' FragLocalPart ;
87 fragment FragUnprefixedName : FragLocalPart ;
88 fragment FragPrefix : FragmentNCName ;
89 fragment FragLocalPart : FragmentNCName ;
90 fragment FragNCNameStartChar
105 | '\u{10000}'..'\u{EFFFF}'
107 fragment FragNCNameChar
108 : FragNCNameStartChar | '-' | '.' | '0'..'9'
109 | '\u00B7' | '\u0300'..'\u036F'
112 fragment FragmentNCName : FragNCNameStartChar FragNCNameChar* ;
114 // https://www.w3.org/TR/REC-xml/#NT-Char
116 fragment FragChar : '\u0009' | '\u000a' | '\u000d'
119 | '\u{10000}'..'\u{10ffff}'
122 // Skip all Whitespace
123 Whitespace : ('\u000d' | '\u000a' | '\u0020' | '\u0009')+ -> skip ;
125 // handle characters which failed to match any other token (otherwise Antlr will ignore them)