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
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
22 cpsPath: (cpsPathWithSingleLeafCondition | cpsPathWithDescendant | cpsPathWithDescendantAndLeafConditions) ancestorAxis? ;
24 ancestorAxis: SLASH KW_ANCESTOR COLONCOLON ancestorPath ;
26 ancestorPath: yangElement (SLASH yangElement)* ;
28 cpsPathWithSingleLeafCondition: prefix singleValueCondition ;
31 No need to ditinguish between cpsPathWithDescendant | cpsPathWithDescendantAndLeafConditions really!
32 See https://jira.onap.org/browse/CPS-436
35 cpsPathWithDescendant: descendant ;
37 cpsPathWithDescendantAndLeafConditions: descendant multipleValueConditions ;
39 descendant: SLASH prefix ;
41 prefix: (SLASH yangElement)* SLASH containerName ;
43 yangElement: containerName listElementRef? ;
45 containerName: QName ;
47 listElementRef: multipleValueConditions ;
49 singleValueCondition: '[' leafCondition ']' ;
51 multipleValueConditions: '[' leafCondition (' and ' leafCondition)* ']' ;
53 leafCondition: '@' leafName '=' (IntegerLiteral | StringLiteral ) ;
55 //To Confirm: defintion of Lefname with external xPath grammar
60 * Most of the lexer rules below are 'imporetd' from
61 * https://raw.githubusercontent.com/antlr/grammars-v4/master/xpath/xpath31/XPath31.g4
69 KW_ANCESTOR : 'ancestor' ;
71 IntegerLiteral : FragDigits ;
72 // Add below type definitions for leafvalue comparision in https://jira.onap.org/browse/CPS-440
73 DecimalLiteral : ('.' FragDigits) | (FragDigits '.' [0-9]*) ;
74 DoubleLiteral : (('.' FragDigits) | (FragDigits ('.' [0-9]*)?)) [eE] [+-]? FragDigits ;
75 StringLiteral : ('"' (FragEscapeQuot | ~[^"])*? '"') | ('\'' (FragEscapeApos | ~['])*? '\'') ;
76 fragment FragEscapeQuot : '""' ;
77 fragment FragEscapeApos : '\'';
78 fragment FragDigits : [0-9]+ ;
81 NCName : FragmentNCName ;
82 fragment FragQName : FragPrefixedName | FragUnprefixedName ;
83 fragment FragPrefixedName : FragPrefix ':' FragLocalPart ;
84 fragment FragUnprefixedName : FragLocalPart ;
85 fragment FragPrefix : FragmentNCName ;
86 fragment FragLocalPart : FragmentNCName ;
87 fragment FragNCNameStartChar
102 | '\u{10000}'..'\u{EFFFF}'
104 fragment FragNCNameChar
105 : FragNCNameStartChar | '-' | '.' | '0'..'9'
106 | '\u00B7' | '\u0300'..'\u036F'
109 fragment FragmentNCName : FragNCNameStartChar FragNCNameChar* ;
111 // https://www.w3.org/TR/REC-xml/#NT-Char
113 fragment FragChar : '\u0009' | '\u000a' | '\u000d'
116 | '\u{10000}'..'\u{10ffff}'
119 // Skip all Whitespace
120 Whitespace : ('\u000d' | '\u000a' | '\u0020' | '\u0009')+ -> skip ;
122 // handle characters which failed to match any other token (otherwise Antlr will ignore them)