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 : ( prefix | descendant | incorrectPrefix ) multipleLeafConditions? textFunctionCondition? ancestorAxis? ;
25 ancestorAxis : SLASH KW_ANCESTOR COLONCOLON ancestorPath ;
27 ancestorPath : yangElement ( SLASH yangElement)* ;
29 textFunctionCondition : SLASH leafName OB KW_TEXT_FUNCTION EQ StringLiteral CB ;
31 prefix : ( SLASH yangElement)* SLASH containerName ;
33 descendant : SLASH prefix ;
35 incorrectPrefix : SLASH SLASH SLASH+ ;
37 yangElement : containerName listElementRef? ;
39 containerName : QName ;
41 listElementRef : OB leafCondition ( KW_AND leafCondition)* CB ;
43 multipleLeafConditions : OB leafCondition ( KW_AND leafCondition)* CB ;
45 leafCondition : AT leafName EQ ( IntegerLiteral | StringLiteral) ;
51 * Most of the lexer rules below are inspired by
52 * https://raw.githubusercontent.com/antlr/grammars-v4/master/xpath/xpath31/XPath31.g4
64 KW_ANCESTOR : 'ancestor' ;
66 KW_TEXT_FUNCTION: 'text()' ;
68 IntegerLiteral : FragDigits ;
69 // Add below type definitions for leafvalue comparision in https://jira.onap.org/browse/CPS-440
70 DecimalLiteral : ('.' FragDigits) | (FragDigits '.' [0-9]*) ;
71 DoubleLiteral : (('.' FragDigits) | (FragDigits ('.' [0-9]*)?)) [eE] [+-]? FragDigits ;
72 StringLiteral : ('"' (FragEscapeQuot | ~[^"])*? '"') | ('\'' (FragEscapeApos | ~['])*? '\'') ;
73 fragment FragEscapeQuot : '""' ;
74 fragment FragEscapeApos : '\'' ;
75 fragment FragDigits : [0-9]+ ;
78 NCName : FragmentNCName ;
79 fragment FragQName : FragPrefixedName | FragUnprefixedName ;
80 fragment FragPrefixedName : FragPrefix ':' FragLocalPart ;
81 fragment FragUnprefixedName : FragLocalPart ;
82 fragment FragPrefix : FragmentNCName ;
83 fragment FragLocalPart : FragmentNCName ;
84 fragment FragNCNameStartChar
99 | '\u{10000}'..'\u{EFFFF}'
101 fragment FragNCNameChar
102 : FragNCNameStartChar | '-' | '.' | '0'..'9'
103 | '\u00B7' | '\u0300'..'\u036F'
106 fragment FragmentNCName : FragNCNameStartChar FragNCNameChar* ;
108 // https://www.w3.org/TR/REC-xml/#NT-Char
110 fragment FragChar : '\u0009' | '\u000a' | '\u000d'
113 | '\u{10000}'..'\u{10ffff}'
116 // Skip all Whitespace
117 Whitespace : ('\u000d' | '\u000a' | '\u0020' | '\u0009')+ -> skip ;
119 // handle characters which failed to match any other token (otherwise Antlr will ignore them)