Committed by
Gerrit Code Review
[ONOS-3882, 3883, 3892]Implement Yang container, list, leaf, leaf-list parsing
Change-Id: I39039c91385fe0d530d037350ef7833c2459514d
Showing
15 changed files
with
1123 additions
and
0 deletions
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * config-stmt = config-keyword sep | ||
27 | + * config-arg-str stmtend | ||
28 | + * config-arg-str = < a string that matches the rule | ||
29 | + * config-arg > | ||
30 | + * config-arg = true-keyword / false-keyword | ||
31 | + * | ||
32 | + * ANTLR grammar rule | ||
33 | + * configStatement : CONFIG_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND; | ||
34 | + */ | ||
35 | + | ||
36 | +/** | ||
37 | + * Implements listener based call back function corresponding to the "config" | ||
38 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
39 | + */ | ||
40 | +public final class ConfigListener { | ||
41 | + | ||
42 | + /** | ||
43 | + * Creates a new config listener. | ||
44 | + */ | ||
45 | + private ConfigListener() { | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * It is called when parser receives an input matching the grammar | ||
50 | + * rule (config), performs validation and updates the data model | ||
51 | + * tree. | ||
52 | + * | ||
53 | + * @param listener listener's object. | ||
54 | + * @param ctx context object of the grammar rule. | ||
55 | + */ | ||
56 | + public static void processConfigEntry(TreeWalkListener listener, | ||
57 | + GeneratedYangParser.ConfigStatementContext ctx) { | ||
58 | + // TODO method implementation | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * It is called when parser exits from grammar rule (config), it performs | ||
63 | + * validation and updates the data model tree. | ||
64 | + * | ||
65 | + * @param listener listener's object. | ||
66 | + * @param ctx context object of the grammar rule. | ||
67 | + */ | ||
68 | + public static void processConfigExit(TreeWalkListener listener, | ||
69 | + GeneratedYangParser.ConfigStatementContext ctx) { | ||
70 | + // TODO method implementation | ||
71 | + } | ||
72 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * container-stmt = container-keyword sep identifier-arg-str optsep | ||
27 | + * (";" / | ||
28 | + * "{" stmtsep | ||
29 | + * ;; these stmts can appear in any order | ||
30 | + * [when-stmt stmtsep] | ||
31 | + * *(if-feature-stmt stmtsep) | ||
32 | + * *(must-stmt stmtsep) | ||
33 | + * [presence-stmt stmtsep] | ||
34 | + * [config-stmt stmtsep] | ||
35 | + * [status-stmt stmtsep] | ||
36 | + * [description-stmt stmtsep] | ||
37 | + * [reference-stmt stmtsep] | ||
38 | + * *((typedef-stmt / | ||
39 | + * grouping-stmt) stmtsep) | ||
40 | + * *(data-def-stmt stmtsep) | ||
41 | + * "}") | ||
42 | + * | ||
43 | + * ANTLR grammar rule | ||
44 | + * containerStatement : CONTAINER_KEYWORD IDENTIFIER | ||
45 | + * (STMTEND | LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | mustStatement | | ||
46 | + * presenceStatement | configStatement | statusStatement | descriptionStatement | | ||
47 | + * referenceStatement | typedefStatement | groupingStatement | ||
48 | + * | dataDefStatement)* RIGHT_CURLY_BRACE); | ||
49 | + */ | ||
50 | + | ||
51 | +/** | ||
52 | + * Implements listener based call back function corresponding to the "container" | ||
53 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
54 | + */ | ||
55 | +public final class ContainerListener { | ||
56 | + | ||
57 | + /** | ||
58 | + * Creates a new container listener. | ||
59 | + */ | ||
60 | + private ContainerListener() { | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * It is called when parser receives an input matching the grammar | ||
65 | + * rule (container), performs validation and updates the data model | ||
66 | + * tree. | ||
67 | + * | ||
68 | + * @param listener listener's object. | ||
69 | + * @param ctx context object of the grammar rule. | ||
70 | + */ | ||
71 | + public static void processContainerEntry(TreeWalkListener listener, | ||
72 | + GeneratedYangParser.ContainerStatementContext ctx) { | ||
73 | + // TODO method implementation | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * It is called when parser exits from grammar rule (container), it perform | ||
78 | + * validations and updates the data model tree. | ||
79 | + * | ||
80 | + * @param listener listener's object. | ||
81 | + * @param ctx context object of the grammar rule. | ||
82 | + */ | ||
83 | + public static void processContainerExit(TreeWalkListener listener, | ||
84 | + GeneratedYangParser.ContainerStatementContext ctx) { | ||
85 | + //TODO method implementation | ||
86 | + } | ||
87 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * description-stmt = description-keyword sep string optsep stmtend | ||
27 | + * | ||
28 | + * ANTLR grammar rule | ||
29 | + * descriptionStatement : DESCRIPTION_KEYWORD string STMTEND; | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * Implements listener based call back function corresponding to the "description" | ||
34 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
35 | + */ | ||
36 | +public final class DescriptionListener { | ||
37 | + | ||
38 | + /** | ||
39 | + * Creates a new description listener. | ||
40 | + */ | ||
41 | + private DescriptionListener() { | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * It is called when parser receives an input matching the grammar | ||
46 | + * rule (description), perform validations and updates the data model | ||
47 | + * tree. | ||
48 | + * | ||
49 | + * @param listener listener's object. | ||
50 | + * @param ctx context object of the grammar rule. | ||
51 | + */ | ||
52 | + public static void processDescriptionEntry(TreeWalkListener listener, | ||
53 | + GeneratedYangParser.DescriptionStatementContext ctx) { | ||
54 | + // TODO method implementation | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * It is called when parser exits from grammar rule (description), it perform | ||
59 | + * validations and updates the data model tree. | ||
60 | + * | ||
61 | + * @param listener listener's object. | ||
62 | + * @param ctx context object of the grammar rule. | ||
63 | + */ | ||
64 | + public static void processDescriptionExit(TreeWalkListener listener, | ||
65 | + GeneratedYangParser.DescriptionStatementContext ctx) { | ||
66 | + // TODO method implementation | ||
67 | + } | ||
68 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/KeyListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * key-stmt = key-keyword sep key-arg-str stmtend | ||
27 | + * | ||
28 | + * ANTLR grammar rule | ||
29 | + * keyStatement : KEY_KEYWORD string STMTEND; | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * Implements listener based call back function corresponding to the "key" | ||
34 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
35 | + */ | ||
36 | +public final class KeyListener { | ||
37 | + | ||
38 | + /** | ||
39 | + * Creates a new key listener. | ||
40 | + */ | ||
41 | + private KeyListener() { | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * It is called when parser receives an input matching the grammar | ||
46 | + * rule (key), perform validations and updates the data model | ||
47 | + * tree. | ||
48 | + * | ||
49 | + * @param listener listener's object. | ||
50 | + * @param ctx context object of the grammar rule. | ||
51 | + */ | ||
52 | + public static void processKeyEntry(TreeWalkListener listener, | ||
53 | + GeneratedYangParser.KeyStatementContext ctx) { | ||
54 | + // TODO method implementation | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * It is called when parser exits from grammar rule (key), it perform | ||
59 | + * validations and updates the data model tree. | ||
60 | + * | ||
61 | + * @param listener listener's object. | ||
62 | + * @param ctx context object of the grammar rule. | ||
63 | + */ | ||
64 | + public static void processKeyExit(TreeWalkListener listener, | ||
65 | + GeneratedYangParser.KeyStatementContext ctx) { | ||
66 | + // TODO method implementation | ||
67 | + } | ||
68 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * leaf-list-stmt = leaf-list-keyword sep identifier-arg-str optsep | ||
27 | + * "{" stmtsep | ||
28 | + * ;; these stmts can appear in any order | ||
29 | + * [when-stmt stmtsep] | ||
30 | + * *(if-feature-stmt stmtsep) | ||
31 | + * type-stmt stmtsep | ||
32 | + * [units-stmt stmtsep] | ||
33 | + * *(must-stmt stmtsep) | ||
34 | + * [config-stmt stmtsep] | ||
35 | + * [min-elements-stmt stmtsep] | ||
36 | + * [max-elements-stmt stmtsep] | ||
37 | + * [ordered-by-stmt stmtsep] | ||
38 | + * [status-stmt stmtsep] | ||
39 | + * [description-stmt stmtsep] | ||
40 | + * [reference-stmt stmtsep] | ||
41 | + * "}" | ||
42 | + * | ||
43 | + * ANTLR grammar rule | ||
44 | + * leafListStatement : LEAF_LIST_KEYWORD IDENTIFIER LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | | ||
45 | + * typeStatement | unitsStatement | mustStatement | configStatement | minElementsStatement | maxElementsStatement | | ||
46 | + * orderedByStatement | statusStatement | descriptionStatement | referenceStatement)* RIGHT_CURLY_BRACE; | ||
47 | + */ | ||
48 | + | ||
49 | +/** | ||
50 | + * Implements listener based call back function corresponding to the "leaf-list" | ||
51 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
52 | + */ | ||
53 | +public final class LeafListListener { | ||
54 | + | ||
55 | + /** | ||
56 | + * Creates a new leaf list listener. | ||
57 | + */ | ||
58 | + private LeafListListener() { | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * It is called when parser receives an input matching the grammar | ||
63 | + * rule (leaf-list), performs validation and updates the data model | ||
64 | + * tree. | ||
65 | + * | ||
66 | + * @param listener listener's object. | ||
67 | + * @param ctx context object of the grammar rule. | ||
68 | + */ | ||
69 | + public static void processLeafListEntry(TreeWalkListener listener, | ||
70 | + GeneratedYangParser.LeafListStatementContext ctx) { | ||
71 | + // TODO method implementation | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * It is called when parser exits from grammar rule (leaf-list), it performs | ||
76 | + * validation and updates the data model tree. | ||
77 | + * | ||
78 | + * @param listener listener's object. | ||
79 | + * @param ctx context object of the grammar rule. | ||
80 | + */ | ||
81 | + public static void processLeafListExit(TreeWalkListener listener, | ||
82 | + GeneratedYangParser.LeafListStatementContext ctx) { | ||
83 | + // TODO method implementation | ||
84 | + } | ||
85 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * Implements listener based call back function corresponding to the "leaf" | ||
19 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
20 | + */ | ||
21 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
22 | + | ||
23 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
24 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
25 | + | ||
26 | +/* | ||
27 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
28 | + * | ||
29 | + * ABNF grammar as per RFC6020 | ||
30 | + * leaf-stmt = leaf-keyword sep identifier-arg-str optsep | ||
31 | + * "{" stmtsep | ||
32 | + * ;; these stmts can appear in any order | ||
33 | + * [when-stmt stmtsep] | ||
34 | + * *(if-feature-stmt stmtsep) | ||
35 | + * type-stmt stmtsep | ||
36 | + * [units-stmt stmtsep] | ||
37 | + * *(must-stmt stmtsep) | ||
38 | + * [default-stmt stmtsep] | ||
39 | + * [config-stmt stmtsep] | ||
40 | + * [mandatory-stmt stmtsep] | ||
41 | + * [status-stmt stmtsep] | ||
42 | + * [description-stmt stmtsep] | ||
43 | + * [reference-stmt stmtsep] | ||
44 | + * "}" | ||
45 | + * | ||
46 | + * ANTLR grammar rule | ||
47 | + * leafStatement : LEAF_KEYWORD IDENTIFIER LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | typeStatement | | ||
48 | + * unitsStatement | mustStatement | defaultStatement | configStatement | mandatoryStatement | statusStatement | | ||
49 | + * descriptionStatement | referenceStatement)* RIGHT_CURLY_BRACE; | ||
50 | + */ | ||
51 | + | ||
52 | +/** | ||
53 | + * Implements listener based call back function corresponding to the "leaf" | ||
54 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
55 | + */ | ||
56 | +public final class LeafListener { | ||
57 | + | ||
58 | + /** | ||
59 | + * Creates a new leaf listener. | ||
60 | + */ | ||
61 | + private LeafListener() { | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * It is called when parser receives an input matching the grammar | ||
66 | + * rule (leaf), performs validation and updates the data model | ||
67 | + * tree. | ||
68 | + * | ||
69 | + * @param listener listener's object. | ||
70 | + * @param ctx context object of the grammar rule. | ||
71 | + */ | ||
72 | + public static void processLeafEntry(TreeWalkListener listener, | ||
73 | + GeneratedYangParser.LeafStatementContext ctx) { | ||
74 | + // TODO method implementation | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * It is called when parser exits from grammar rule (leaf), performs | ||
79 | + * validation and updates the data model tree. | ||
80 | + * | ||
81 | + * @param listener listener's object. | ||
82 | + * @param ctx context object of the grammar rule. | ||
83 | + */ | ||
84 | + public static void processLeafExit(TreeWalkListener listener, | ||
85 | + GeneratedYangParser.LeafStatementContext ctx) { | ||
86 | + // TODO method implementation | ||
87 | + } | ||
88 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ListListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * list-stmt = list-keyword sep identifier-arg-str optsep | ||
27 | + * "{" stmtsep | ||
28 | + * ;; these stmts can appear in any order | ||
29 | + * [when-stmt stmtsep] | ||
30 | + * *(if-feature-stmt stmtsep) | ||
31 | + * *(must-stmt stmtsep) | ||
32 | + * [key-stmt stmtsep] | ||
33 | + * *(unique-stmt stmtsep) | ||
34 | + * [config-stmt stmtsep] | ||
35 | + * [min-elements-stmt stmtsep] | ||
36 | + * [max-elements-stmt stmtsep] | ||
37 | + * [ordered-by-stmt stmtsep] | ||
38 | + * [status-stmt stmtsep] | ||
39 | + * [description-stmt stmtsep] | ||
40 | + * [reference-stmt stmtsep] | ||
41 | + * *((typedef-stmt / | ||
42 | + * grouping-stmt) stmtsep) | ||
43 | + * 1*(data-def-stmt stmtsep) | ||
44 | + * "}" | ||
45 | + * | ||
46 | + * ANTLR grammar rule | ||
47 | + * listStatement : LIST_KEYWORD IDENTIFIER LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | mustStatement | | ||
48 | + * keyStatement | uniqueStatement | configStatement | minElementsStatement | maxElementsStatement | | ||
49 | + * orderedByStatement | statusStatement | descriptionStatement | referenceStatement | typedefStatement | | ||
50 | + * groupingStatement| dataDefStatement)* RIGHT_CURLY_BRACE; | ||
51 | + */ | ||
52 | + | ||
53 | +/** | ||
54 | + * Implements listener based call back function corresponding to the "list" | ||
55 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
56 | + */ | ||
57 | +public final class ListListener { | ||
58 | + | ||
59 | + /** | ||
60 | + * Creates a new list listener. | ||
61 | + */ | ||
62 | + private ListListener() { | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * It is called when parser receives an input matching the grammar | ||
67 | + * rule (list), performs validation and updates the data model | ||
68 | + * tree. | ||
69 | + * | ||
70 | + * @param listener listener's object. | ||
71 | + * @param ctx context object of the grammar rule. | ||
72 | + */ | ||
73 | + public static void processListEntry(TreeWalkListener listener, | ||
74 | + GeneratedYangParser.ListStatementContext ctx) { | ||
75 | + // TODO | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * It is called when parser exits from grammar rule (list), it performs | ||
80 | + * validation and updates the data model tree. | ||
81 | + * | ||
82 | + * @param listener listener's object. | ||
83 | + * @param ctx context object of the grammar rule. | ||
84 | + */ | ||
85 | + public static void processListExit(TreeWalkListener listener, | ||
86 | + GeneratedYangParser.ListStatementContext ctx) { | ||
87 | + // TODO | ||
88 | + } | ||
89 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * mandatory-stmt = mandatory-keyword sep | ||
27 | + * mandatory-arg-str stmtend | ||
28 | + * | ||
29 | + * mandatory-arg-str = < a string that matches the rule | ||
30 | + * mandatory-arg > | ||
31 | + * | ||
32 | + * mandatory-arg = true-keyword / false-keyword | ||
33 | + * | ||
34 | + * ANTLR grammar rule | ||
35 | + * mandatoryStatement : MANDATORY_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND; | ||
36 | + */ | ||
37 | + | ||
38 | +/** | ||
39 | + * Implements listener based call back function corresponding to the "mandatory" | ||
40 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
41 | + */ | ||
42 | +public final class MandatoryListener { | ||
43 | + | ||
44 | + /** | ||
45 | + * Creates a new mandatory listener. | ||
46 | + */ | ||
47 | + private MandatoryListener() { | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * It is called when parser receives an input matching the grammar | ||
52 | + * rule (mandatory), performs validation and updates the data model | ||
53 | + * tree. | ||
54 | + * | ||
55 | + * @param listener listener's object. | ||
56 | + * @param ctx context object of the grammar rule. | ||
57 | + */ | ||
58 | + public static void processMandatoryEntry(TreeWalkListener listener, | ||
59 | + GeneratedYangParser.MandatoryStatementContext ctx) { | ||
60 | + // TODO method implementation | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * It is called when parser exits from grammar rule (mandatory), it performs | ||
65 | + * validation and updates the data model tree. | ||
66 | + * | ||
67 | + * @param listener listener's object. | ||
68 | + * @param ctx context object of the grammar rule. | ||
69 | + */ | ||
70 | + public static void processMandatoryExit(TreeWalkListener listener, | ||
71 | + GeneratedYangParser.MandatoryStatementContext ctx) { | ||
72 | + // TODO method implementation | ||
73 | + } | ||
74 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * max-elements-stmt = max-elements-keyword sep | ||
27 | + * max-value-arg-str stmtend | ||
28 | + * max-value-arg-str = < a string that matches the rule | ||
29 | + * max-value-arg > | ||
30 | + * | ||
31 | + * ANTLR grammar rule | ||
32 | + * maxElementsStatement : MAX_ELEMENTS_KEYWORD maxValueArgument STMTEND; | ||
33 | + */ | ||
34 | + | ||
35 | +/** | ||
36 | + * Implements listener based call back function corresponding to the "max-elements" | ||
37 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
38 | + */ | ||
39 | +public final class MaxElementsListener { | ||
40 | + | ||
41 | + /** | ||
42 | + * Creates a new max-elements listener. | ||
43 | + */ | ||
44 | + private MaxElementsListener() { | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * It is called when parser receives an input matching the grammar | ||
49 | + * rule (max-elements), performs validation and updates the data model | ||
50 | + * tree. | ||
51 | + * | ||
52 | + * @param listener listener's object. | ||
53 | + * @param ctx context object of the grammar rule. | ||
54 | + */ | ||
55 | + public static void processMaxElementsEntry(TreeWalkListener listener, | ||
56 | + GeneratedYangParser.MaxElementsStatementContext ctx) { | ||
57 | + // TODO method implementation | ||
58 | + } | ||
59 | + | ||
60 | + /** | ||
61 | + * It is called when parser exits from grammar rule (max-elements), it performs | ||
62 | + * validation and updates the data model tree. | ||
63 | + * | ||
64 | + * @param listener listener's object. | ||
65 | + * @param ctx context object of the grammar rule. | ||
66 | + */ | ||
67 | + public static void processMaxElementsExit(TreeWalkListener listener, | ||
68 | + GeneratedYangParser.MaxElementsStatementContext ctx) { | ||
69 | + // TODO method implementation | ||
70 | + } | ||
71 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * min-elements-stmt = min-elements-keyword sep | ||
27 | + * min-value-arg-str stmtend | ||
28 | + * min-value-arg-str = < a string that matches the rule | ||
29 | + * min-value-arg > | ||
30 | + * min-value-arg = non-negative-integer-value | ||
31 | + * | ||
32 | + * ANTLR grammar rule | ||
33 | + * minElementsStatement : MIN_ELEMENTS_KEYWORD INTEGER STMTEND; | ||
34 | + */ | ||
35 | + | ||
36 | +/** | ||
37 | + * Implements listener based call back function corresponding to the "min-elements" | ||
38 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
39 | + */ | ||
40 | +public final class MinElementsListener { | ||
41 | + | ||
42 | + /** | ||
43 | + * Creates a new min-elements listener. | ||
44 | + */ | ||
45 | + private MinElementsListener() { | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * It is called when parser receives an input matching the grammar | ||
50 | + * rule (min-elements), performs validation and updates the data model | ||
51 | + * tree. | ||
52 | + * | ||
53 | + * @param listener listener's object. | ||
54 | + * @param ctx context object of the grammar rule. | ||
55 | + */ | ||
56 | + public static void processMinElementsEntry(TreeWalkListener listener, | ||
57 | + GeneratedYangParser.MinElementsStatementContext ctx) { | ||
58 | + // TODO method implementation | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * It is called when parser exits from grammar rule (min-elements), it performs | ||
63 | + * validation and updates the data model tree. | ||
64 | + * | ||
65 | + * @param listener listener's object. | ||
66 | + * @param ctx context object of the grammar rule. | ||
67 | + */ | ||
68 | + public static void processMinElementsExit(TreeWalkListener listener, | ||
69 | + GeneratedYangParser.MinElementsStatementContext ctx) { | ||
70 | + // TODO method implementation | ||
71 | + } | ||
72 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * presence-stmt = presence-keyword sep string stmtend | ||
27 | + * | ||
28 | + * ANTLR grammar rule | ||
29 | + * presenceStatement : PRESENCE_KEYWORD string STMTEND; | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * Implements listener based call back function corresponding to the "presence" | ||
34 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
35 | + */ | ||
36 | +public final class PresenceListener { | ||
37 | + | ||
38 | + /** | ||
39 | + * Creates a new presence listener. | ||
40 | + */ | ||
41 | + private PresenceListener() { | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * It is called when parser receives an input matching the grammar | ||
46 | + * rule (presence), performs validation and updates the data model | ||
47 | + * tree. | ||
48 | + * | ||
49 | + * @param listener listener's object. | ||
50 | + * @param ctx context object of the grammar rule. | ||
51 | + */ | ||
52 | + public static void processPresenceEntry(TreeWalkListener listener, | ||
53 | + GeneratedYangParser.PresenceStatementContext ctx) { | ||
54 | + // TODO method implementation | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * It is called when parser exits from grammar rule (presence), it performs | ||
59 | + * validation and updates the data model tree. | ||
60 | + * | ||
61 | + * @param listener listener's object. | ||
62 | + * @param ctx context object of the grammar rule. | ||
63 | + */ | ||
64 | + public static void processPresenceExit(TreeWalkListener listener, | ||
65 | + GeneratedYangParser.PresenceStatementContext ctx) { | ||
66 | + // TODO method implementation | ||
67 | + } | ||
68 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * reference-stmt = reference-keyword sep string optsep stmtend | ||
27 | + * | ||
28 | + * ANTLR grammar rule | ||
29 | + * referenceStatement : REFERENCE_KEYWORD string STMTEND; | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * Implements listener based call back function corresponding to the "reference" | ||
34 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
35 | + */ | ||
36 | +public final class ReferenceListener { | ||
37 | + | ||
38 | + /** | ||
39 | + * Creates a new reference listener. | ||
40 | + */ | ||
41 | + private ReferenceListener() { | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * It is called when parser receives an input matching the grammar | ||
46 | + * rule (reference), performs validation and updates the data model | ||
47 | + * tree. | ||
48 | + * | ||
49 | + * @param listener listener's object. | ||
50 | + * @param ctx context object of the grammar rule. | ||
51 | + */ | ||
52 | + public static void processReferenceEntry(TreeWalkListener listener, | ||
53 | + GeneratedYangParser.ReferenceStatementContext ctx) { | ||
54 | + // TODO method implementation | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * It is called when parser exits from grammar rule (reference), it performs | ||
59 | + * validation and updates the data model tree. | ||
60 | + * | ||
61 | + * @param listener listener's object. | ||
62 | + * @param ctx context object of the grammar rule. | ||
63 | + */ | ||
64 | + public static void processReferenceExit(TreeWalkListener listener, | ||
65 | + GeneratedYangParser.ReferenceStatementContext ctx) { | ||
66 | + // TODO method implementation | ||
67 | + } | ||
68 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/StatusListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * status-stmt = status-keyword sep status-arg-str stmtend | ||
27 | + * status-arg-str = < a string that matches the rule | ||
28 | + * status-arg > | ||
29 | + * status-arg = current-keyword / | ||
30 | + * obsolete-keyword / | ||
31 | + * deprecated-keyword | ||
32 | + * | ||
33 | + * ANTLR grammar rule | ||
34 | + * statusStatement : STATUS_KEYWORD (CURRENT_KEYWORD | OBSOLETE_KEYWORD | DEPRECATED_KEYWORD) STMTEND; | ||
35 | + */ | ||
36 | + | ||
37 | +/** | ||
38 | + * Implements listener based call back function corresponding to the "status" | ||
39 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
40 | + */ | ||
41 | +public final class StatusListener { | ||
42 | + | ||
43 | + /** | ||
44 | + * Creates a new status listener. | ||
45 | + */ | ||
46 | + private StatusListener() { | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * It is called when parser receives an input matching the grammar | ||
51 | + * rule (status), performs validation and updates the data model | ||
52 | + * tree. | ||
53 | + * | ||
54 | + * @param listener listener's object. | ||
55 | + * @param ctx context object of the grammar rule. | ||
56 | + */ | ||
57 | + public static void processStatusEntry(TreeWalkListener listener, | ||
58 | + GeneratedYangParser.StatusStatementContext ctx) { | ||
59 | + // TODO method implementation | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * It is called when parser exits from grammar rule (status), it performs | ||
64 | + * validation and updates the data model tree. | ||
65 | + * | ||
66 | + * @param listener listener's object. | ||
67 | + * @param ctx context object of the grammar rule. | ||
68 | + */ | ||
69 | + public static void processStatusExit(TreeWalkListener listener, | ||
70 | + GeneratedYangParser.StatusStatementContext ctx) { | ||
71 | + // TODO method implementation | ||
72 | + } | ||
73 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * type-stmt = type-keyword sep identifier-ref-arg-str optsep | ||
27 | + * (";" / | ||
28 | + * "{" stmtsep | ||
29 | + * type-body-stmts | ||
30 | + * "}") | ||
31 | + * | ||
32 | + * ANTLR grammar rule | ||
33 | + * typeStatement : TYPE_KEYWORD string (STMTEND | LEFT_CURLY_BRACE typeBodyStatements RIGHT_CURLY_BRACE); | ||
34 | + */ | ||
35 | + | ||
36 | +/** | ||
37 | + * Implements listener based call back function corresponding to the "type" | ||
38 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
39 | + */ | ||
40 | +public final class TypeListener { | ||
41 | + | ||
42 | + /** | ||
43 | + * Creates a new type listener. | ||
44 | + */ | ||
45 | + private TypeListener() { | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * It is called when parser receives an input matching the grammar | ||
50 | + * rule (type), performs validation and updates the data model | ||
51 | + * tree. | ||
52 | + * | ||
53 | + * @param listener listener's object. | ||
54 | + * @param ctx context object of the grammar rule. | ||
55 | + */ | ||
56 | + public static void processTypeEntry(TreeWalkListener listener, | ||
57 | + GeneratedYangParser.TypeStatementContext ctx) { | ||
58 | + // TODO method implementation | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * It is called when parser exits from grammar rule (type), it performs | ||
63 | + * validation and updates the data model tree. | ||
64 | + * | ||
65 | + * @param listener listener's object. | ||
66 | + * @param ctx context object of the grammar rule. | ||
67 | + */ | ||
68 | + public static void processTypeExit(TreeWalkListener listener, | ||
69 | + GeneratedYangParser.TypeStatementContext ctx) { | ||
70 | + // TODO method implementation | ||
71 | + } | ||
72 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListener.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
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. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
20 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference: RFC6020 and YANG ANTLR Grammar | ||
24 | + * | ||
25 | + * ABNF grammar as per RFC6020 | ||
26 | + * units-stmt = units-keyword sep string optsep stmtend | ||
27 | + * | ||
28 | + * ANTLR grammar rule | ||
29 | + * unitsStatement : UNITS_KEYWORD string STMTEND; | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * Implements listener based call back function corresponding to the "units" | ||
34 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
35 | + */ | ||
36 | +public final class UnitsListener { | ||
37 | + | ||
38 | + /** | ||
39 | + * Creates a new units listener. | ||
40 | + */ | ||
41 | + private UnitsListener() { | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * It is called when parser receives an input matching the grammar | ||
46 | + * rule (units), performs validation and updates the data model | ||
47 | + * tree. | ||
48 | + * | ||
49 | + * @param listener listener's object. | ||
50 | + * @param ctx context object of the grammar rule. | ||
51 | + */ | ||
52 | + public static void processUnitsEntry(TreeWalkListener listener, | ||
53 | + GeneratedYangParser.UnitsStatementContext ctx) { | ||
54 | + // TODO method implementation | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * It is called when parser exits from grammar rule (units), it performs | ||
59 | + * validation and updates the data model tree. | ||
60 | + * | ||
61 | + * @param listener listener's object. | ||
62 | + * @param ctx context object of the grammar rule. | ||
63 | + */ | ||
64 | + public static void processUnitsExit(TreeWalkListener listener, | ||
65 | + GeneratedYangParser.UnitsStatementContext ctx) { | ||
66 | + // TODO method implementation | ||
67 | + } | ||
68 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment