Rework incoming candidate check
[yangtools.git] / yang / yang-xpath-impl / src / main / antlr4 / org / opendaylight / yangtools / yang / xpath / impl / instanceIdentifier.g4
1 grammar instanceIdentifier;
2
3 /*
4  * YANG 1.1 instance-identifier grammar, as defined in
5  * https://tools.ietf.org/html/rfc7950#section-9.13
6  *
7  * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
8  *
9  * This program and the accompanying materials are made available under the
10  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
11  * and is available at http://www.eclipse.org/legal/epl-v10.html
12  */
13 instanceIdentifier : ('/' pathArgument)+
14   ;
15
16 pathArgument : nodeIdentifier predicate?
17   ;
18
19 nodeIdentifier : Identifier ':' Identifier
20   ;
21
22 predicate : keyPredicate+
23   | leafListPredicate
24   | pos
25   ;
26
27 keyPredicate : '[' WSP? keyPredicateExpr WSP? ']'
28   ;
29
30 keyPredicateExpr  : nodeIdentifier eqQuotedString
31   ;
32
33 leafListPredicate : '[' WSP? leafListPredicateExpr WSP? ']'
34   ;
35
36 leafListPredicateExpr : '.' eqQuotedString
37   ;
38
39 // Common tail of leafListPredicateExpr and keyPredicateExpr
40 eqQuotedString : WSP? '=' WSP? quotedString
41   ;
42
43 pos : '[' WSP? PositiveIntegerValue WSP? ']'
44   ;
45
46 quotedString : '\'' STRING '\''
47   | '"' STRING '"'
48   ;
49
50 Identifier : [a-zA-Z][a-zA-Z0-9_\-.]*
51   ;
52
53 PositiveIntegerValue : [1-9][0-9]*
54   ;
55
56 STRING : YANGCHAR+
57   ;
58
59 WSP : [ \t]+
60   ;
61
62 fragment
63 YANGCHAR : '\t'..'\n'
64   | '\r'
65   | '\u0020'..'\uD7FF'
66   | '\uE000'..'\uFDCF'
67   | '\uFDF0'..'\uFFFD'
68   | '\u{10000}'..'\u{1FFFD}'
69   | '\u{20000}'..'\u{2FFFD}'
70   | '\u{30000}'..'\u{3FFFD}'
71   | '\u{40000}'..'\u{4FFFD}'
72   | '\u{50000}'..'\u{5FFFD}'
73   | '\u{60000}'..'\u{6FFFD}'
74   | '\u{70000}'..'\u{7FFFD}'
75   | '\u{80000}'..'\u{8FFFD}'
76   | '\u{90000}'..'\u{9FFFD}'
77   | '\u{A0000}'..'\u{AFFFD}'
78   | '\u{B0000}'..'\u{BFFFD}'
79   | '\u{C0000}'..'\u{CFFFD}'
80   | '\u{D0000}'..'\u{DFFFD}'
81   | '\u{E0000}'..'\u{EFFFD}'
82   | '\u{F0000}'..'\u{FFFFD}'
83   | '\u{100000}'..'\u{10FFFD}'
84   ;
85