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