GeneratedYang.g4 62.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223
/*
 * Copyright 2016 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * This is a YANG grammar for parser based on which ANTLR will generate YANG parser.
 */

grammar GeneratedYang;
import YangLexer;

@header {
package org.onosproject.yangutils.parser.antlrgencode;
}

    yangfile : moduleStatement
             | subModuleStatement;

    /**
     * module-stmt         = optsep module-keyword sep identifier-arg-str
     *                       optsep
     *                       "{" stmtsep
     *                           module-header-stmts
     *                           linkage-stmts
     *                           meta-stmts
     *                           revision-stmts
     *                           body-stmts
     *                       "}" optsep
     */

    moduleStatement : MODULE_KEYWORD IDENTIFIER LEFT_CURLY_BRACE moduleBody* RIGHT_CURLY_BRACE;

    moduleBody : moduleHeaderStatement linkageStatements metaStatements revisionStatements bodyStatements;

    /**
     * module-header-stmts = ;; these stmts can appear in any order
     *                       [yang-version-stmt stmtsep]
     *                        namespace-stmt stmtsep
     *                        prefix-stmt stmtsep
     */

    moduleHeaderStatement : yangVersionStatement? namespaceStatement prefixStatement
                            | yangVersionStatement? prefixStatement namespaceStatement
                            | namespaceStatement yangVersionStatement? prefixStatement
                            | namespaceStatement prefixStatement yangVersionStatement?
                            | prefixStatement namespaceStatement yangVersionStatement?
                            | prefixStatement yangVersionStatement? namespaceStatement
                            ;

    /**
     * linkage-stmts       = ;; these stmts can appear in any order
     *                       *(import-stmt stmtsep)
     *                       *(include-stmt stmtsep)
     */

    linkageStatements : (importStatement
                  | includeStatement)*;

    /**
     * meta-stmts          = ;; these stmts can appear in any order
     *                       [organization-stmt stmtsep]
     *                       [contact-stmt stmtsep]
     *                       [description-stmt stmtsep]
     *                       [reference-stmt stmtsep]
     */

    metaStatements : organizationStatement? contactStatement? descriptionStatement? referenceStatement?
               | organizationStatement? contactStatement? referenceStatement? descriptionStatement?
               | organizationStatement? descriptionStatement? contactStatement? referenceStatement?
               | organizationStatement? descriptionStatement? referenceStatement? contactStatement?
               | organizationStatement? referenceStatement? contactStatement? descriptionStatement?
               | organizationStatement? referenceStatement? descriptionStatement? contactStatement?
               | contactStatement? organizationStatement? descriptionStatement? referenceStatement?
               | contactStatement? organizationStatement? referenceStatement? descriptionStatement?
               | contactStatement? referenceStatement? organizationStatement? descriptionStatement?
               | contactStatement? referenceStatement? descriptionStatement? organizationStatement?
               | contactStatement? descriptionStatement? referenceStatement? organizationStatement?
               | contactStatement? descriptionStatement? organizationStatement? referenceStatement?
               | referenceStatement? contactStatement? organizationStatement? descriptionStatement?
               | referenceStatement? contactStatement? descriptionStatement? organizationStatement?
               | referenceStatement? organizationStatement? contactStatement? descriptionStatement?
               | referenceStatement? organizationStatement? descriptionStatement? contactStatement?
               | referenceStatement? descriptionStatement? organizationStatement? contactStatement?
               | referenceStatement? descriptionStatement? contactStatement? organizationStatement?
               | descriptionStatement? referenceStatement? contactStatement? organizationStatement?
               | descriptionStatement? referenceStatement? organizationStatement? contactStatement?
               | descriptionStatement? contactStatement? referenceStatement? organizationStatement?
               | descriptionStatement? contactStatement? organizationStatement? referenceStatement?
               | descriptionStatement? organizationStatement? contactStatement? referenceStatement?
               | descriptionStatement? organizationStatement? referenceStatement? contactStatement?
               ;

    // revision-stmts      = *(revision-stmt stmtsep)
    revisionStatements : revisionStatement*;

    /**
     * body-stmts          = *((extension-stmt /
     *                          feature-stmt /
     *                          identity-stmt /
     *                          typedef-stmt /
     *                          grouping-stmt /
     *                          data-def-stmt /
     *                          augment-stmt /
     *                          rpc-stmt /
     *                          notification-stmt /
     *                          deviation-stmt) stmtsep)
     */

    bodyStatements : (extensionStatement
               | featureStatement
               | identityStatement
               | typedefStatement
               | groupingStatement
               | dataDefStatement
               | augmentStatement
               | rpcStatement
               | notificationStatement
               | deviationStatement)*
               ;

    /**
     * yang-version-stmt   = yang-version-keyword sep yang-version-arg-str
     *                       optsep stmtend
     */

    yangVersionStatement :   YANG_VERSION_KEYWORD INTEGER STMTEND;


    /**
     * namespace-stmt      = namespace-keyword sep uri-str optsep stmtend
     * For namespace validation TODO in Listener
     */
    namespaceStatement : NAMESPACE_KEYWORD string STMTEND;

    /**
     * prefix-stmt         = prefix-keyword sep prefix-arg-str
     *                       optsep stmtend
     */
    prefixStatement : PREFIX_KEYWORD IDENTIFIER STMTEND;

    /**
     * import-stmt         = import-keyword sep identifier-arg-str optsep
     *                       "{" stmtsep
     *                           prefix-stmt stmtsep
     *                           [revision-date-stmt stmtsep]
     *                        "}"
     */
    importStatement : IMPORT_KEYWORD IDENTIFIER LEFT_CURLY_BRACE importStatementBody RIGHT_CURLY_BRACE;

    importStatementBody : prefixStatement revisionDateStatement?;

    // revision-date-stmt = revision-date-keyword sep revision-date stmtend
    revisionDateStatement : REVISION_DATE_KEYWORD DATE_ARG STMTEND;

    /**
     * include-stmt        = include-keyword sep identifier-arg-str optsep
     *                             (";" /
     *                              "{" stmtsep
     *                                  [revision-date-stmt stmtsep]
     *                            "}")
     */
    includeStatement : INCLUDE_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE revisionDateStatement? RIGHT_CURLY_BRACE);

    /**
     * organization-stmt   = organization-keyword sep string
     *                            optsep stmtend
     */
    organizationStatement : ORGANIZATION_KEYWORD string STMTEND;

    // contact-stmt        = contact-keyword sep string optsep stmtend
    contactStatement : CONTACT_KEYWORD string STMTEND;

    // description-stmt    = description-keyword sep string optsep stmtend
    descriptionStatement : DESCRIPTION_KEYWORD string STMTEND;

    // reference-stmt      = reference-keyword sep string optsep stmtend
    referenceStatement : REFERENCE_KEYWORD string STMTEND;

    /**
     * revision-stmt       = revision-keyword sep revision-date optsep
     *                             (";" /
     *                              "{" stmtsep
     *                                  [description-stmt stmtsep]
     *                                  [reference-stmt stmtsep]
     *                              "}")
     */
    revisionStatement : REVISION_KEYWORD DATE_ARG (STMTEND | LEFT_CURLY_BRACE revisionStatementBody RIGHT_CURLY_BRACE);
    revisionStatementBody : descriptionStatement? referenceStatement?;

    /**
     * submodule-stmt      = optsep submodule-keyword sep identifier-arg-str
     *                             optsep
     *                             "{" stmtsep
     *                                 submodule-header-stmts
     *                                 linkage-stmts
     *                                 meta-stmts
     *                                 revision-stmts
     *                                 body-stmts
     *                             "}" optsep
     */
    subModuleStatement : SUBMODULE_KEYWORD IDENTIFIER LEFT_CURLY_BRACE submoduleBody* RIGHT_CURLY_BRACE;
    submoduleBody : submoduleHeaderStatement linkageStatements metaStatements revisionStatements bodyStatements;

    /** submodule-header-stmts =
     *                            ;; these stmts can appear in any order
     *                            [yang-version-stmt stmtsep]
     *                             belongs-to-stmt stmtsep
     */
    submoduleHeaderStatement : yangVersionStatement? belongstoStatement
                               | belongstoStatement yangVersionStatement?
                              ;

    /**
     * belongs-to-stmt     = belongs-to-keyword sep identifier-arg-str
     *                       optsep
     *                       "{" stmtsep
     *                           prefix-stmt stmtsep
     *                       "}"
     */
    belongstoStatement : BELONGS_TO_KEYWORD IDENTIFIER LEFT_CURLY_BRACE belongstoStatementBody RIGHT_CURLY_BRACE;
    belongstoStatementBody : prefixStatement;

    /**
     * extension-stmt      = extension-keyword sep identifier-arg-str optsep
     *                       (";" /
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [argument-stmt stmtsep]
     *                            [status-stmt stmtsep]
     *                            [description-stmt stmtsep]
     *                            [reference-stmt stmtsep]
     *                        "}")
     */
    extensionStatement : EXTENSION_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE extensionBody RIGHT_CURLY_BRACE);
    extensionBody : argumentStatement? statusStatement? descriptionStatement? referenceStatement?
                   | argumentStatement? statusStatement? referenceStatement? descriptionStatement?
                   | argumentStatement? descriptionStatement? statusStatement? referenceStatement?
                   | argumentStatement? descriptionStatement? referenceStatement? statusStatement?
                   | argumentStatement? referenceStatement? descriptionStatement? statusStatement?
                   | argumentStatement? referenceStatement? statusStatement? descriptionStatement?
                   | statusStatement? referenceStatement? argumentStatement? descriptionStatement?
                   | statusStatement? referenceStatement? descriptionStatement? argumentStatement?
                   | statusStatement? descriptionStatement? referenceStatement? argumentStatement?
                   | statusStatement? descriptionStatement? argumentStatement? referenceStatement?
                   | statusStatement? argumentStatement? referenceStatement? descriptionStatement?
                   | statusStatement? argumentStatement? descriptionStatement? referenceStatement?
                   | descriptionStatement? argumentStatement? statusStatement? referenceStatement?
                   | descriptionStatement? argumentStatement? referenceStatement? statusStatement?
                   | descriptionStatement? statusStatement? argumentStatement? referenceStatement?
                   | descriptionStatement? statusStatement? referenceStatement? argumentStatement?
                   | descriptionStatement? referenceStatement? statusStatement? argumentStatement?
                   | descriptionStatement? referenceStatement? argumentStatement? statusStatement?
                   | referenceStatement? descriptionStatement? argumentStatement? statusStatement?
                   | referenceStatement? descriptionStatement? statusStatement? argumentStatement?
                   | referenceStatement? statusStatement? argumentStatement? descriptionStatement?
                   | referenceStatement? statusStatement? descriptionStatement? argumentStatement?
                   | referenceStatement? argumentStatement? descriptionStatement? statusStatement?
                   | referenceStatement? argumentStatement? statusStatement? descriptionStatement?
                   ;

    /**
     * argument-stmt       = argument-keyword sep identifier-arg-str optsep
     *                       (";" /
     *                        "{" stmtsep
     *                            [yin-element-stmt stmtsep]
     *                        "}")
     */
    argumentStatement : ARGUMENT_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE argumentBody RIGHT_CURLY_BRACE);
    argumentBody : yinElementStatement?;

    /**
     * yin-element-stmt    = yin-element-keyword sep yin-element-arg-str
     *                       stmtend
     */
    yinElementStatement : YIN_ELEMENT_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND;

    /**
     * identity-stmt       = identity-keyword sep identifier-arg-str optsep
     *                       (";" /
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [base-stmt stmtsep]
     *                            [status-stmt stmtsep]
     *                            [description-stmt stmtsep]
     *                            [reference-stmt stmtsep]
     *                        "}")
     */
    identityStatement : IDENTITY_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE identityBody RIGHT_CURLY_BRACE);
    identityBody : baseStatement? statusStatement? descriptionStatement? referenceStatement?
                  | baseStatement? statusStatement? referenceStatement? descriptionStatement?
                  | baseStatement? descriptionStatement? statusStatement? referenceStatement?
                  | baseStatement? descriptionStatement? referenceStatement? statusStatement?
                  | baseStatement? referenceStatement? descriptionStatement? statusStatement?
                  | baseStatement? referenceStatement? statusStatement? descriptionStatement?
                  | referenceStatement? baseStatement? statusStatement? descriptionStatement?
                  | referenceStatement? baseStatement? descriptionStatement? statusStatement?
                  | referenceStatement? statusStatement? baseStatement? descriptionStatement?
                  | referenceStatement? statusStatement? descriptionStatement? baseStatement?
                  | referenceStatement? descriptionStatement? statusStatement? baseStatement?
                  | referenceStatement? descriptionStatement? baseStatement? statusStatement?
                  | descriptionStatement? referenceStatement? statusStatement? baseStatement?
                  | descriptionStatement? referenceStatement? statusStatement? baseStatement?
                  | descriptionStatement? referenceStatement? baseStatement? statusStatement?
                  | descriptionStatement? statusStatement? baseStatement? referenceStatement?
                  | descriptionStatement? statusStatement? referenceStatement? baseStatement?
                  | descriptionStatement? baseStatement? referenceStatement? statusStatement?
                  | descriptionStatement? baseStatement? statusStatement? referenceStatement?
                  | statusStatement? baseStatement? descriptionStatement? referenceStatement?
                  | statusStatement? baseStatement? referenceStatement? descriptionStatement?
                  | statusStatement? descriptionStatement? baseStatement? referenceStatement?
                  | statusStatement? descriptionStatement? referenceStatement? baseStatement?
                  | statusStatement? referenceStatement? descriptionStatement? baseStatement?
                  | statusStatement? referenceStatement? baseStatement? descriptionStatement?
                  ;

    /**
     * base-stmt           = base-keyword sep identifier-ref-arg-str
     *                          optsep stmtend*
     * identifier-ref-arg  = [prefix ":"] identifier
     */
    baseStatement : BASE_KEYWORD string STMTEND;

    /**
     *  feature-stmt        = feature-keyword sep identifier-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             *(if-feature-stmt stmtsep)
     *                             [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                         "}")
     */
    featureStatement : FEATURE_KEYWORD string (STMTEND | LEFT_CURLY_BRACE featureBody RIGHT_CURLY_BRACE);
    featureBody : ifFeatureStatement* statusStatement? descriptionStatement? referenceStatement?
                 | ifFeatureStatement* statusStatement? referenceStatement? descriptionStatement?
                 | ifFeatureStatement* descriptionStatement? statusStatement? referenceStatement?
                 | ifFeatureStatement* descriptionStatement? referenceStatement? statusStatement?
                 | ifFeatureStatement* referenceStatement? statusStatement? descriptionStatement?
                 | ifFeatureStatement* referenceStatement? descriptionStatement? statusStatement?
                 | statusStatement? ifFeatureStatement* descriptionStatement? referenceStatement?
                 | statusStatement? ifFeatureStatement* referenceStatement? descriptionStatement?
                 | statusStatement? descriptionStatement? ifFeatureStatement* referenceStatement?
                 | statusStatement? descriptionStatement? referenceStatement? ifFeatureStatement*
                 | statusStatement? referenceStatement? ifFeatureStatement* descriptionStatement?
                 | statusStatement? referenceStatement? descriptionStatement? ifFeatureStatement*
                 | descriptionStatement? ifFeatureStatement* statusStatement? referenceStatement?
                 | descriptionStatement? ifFeatureStatement* referenceStatement? statusStatement?
                 | descriptionStatement? statusStatement? ifFeatureStatement* referenceStatement?
                 | descriptionStatement? statusStatement? referenceStatement? ifFeatureStatement*
                 | descriptionStatement? referenceStatement* statusStatement? ifFeatureStatement*
                 | descriptionStatement? referenceStatement* ifFeatureStatement? statusStatement?
                 | referenceStatement? ifFeatureStatement* statusStatement? descriptionStatement?
                 | referenceStatement? ifFeatureStatement* descriptionStatement? statusStatement?
                 | referenceStatement? descriptionStatement? statusStatement? ifFeatureStatement*
                 | referenceStatement? descriptionStatement? ifFeatureStatement* statusStatement?
                 | referenceStatement? statusStatement? descriptionStatement? ifFeatureStatement*
                 | referenceStatement? statusStatement? ifFeatureStatement* descriptionStatement?
                 ;

    /**
     *  data-def-stmt       = container-stmt /
     *                       leaf-stmt /
     *                       leaf-list-stmt /
     *                       list-stmt /
     *                       choice-stmt /
     *                       anyxml-stmt /
     *                       uses-stmt
     */
    dataDefStatement : containerStatement
                    | leafStatement
                    | leafListStatement
                    | listStatement
                    | choiceStatement
                    | usesStatement;

    /**
     *  if-feature-stmt     = if-feature-keyword sep identifier-ref-arg-str
     *                        optsep stmtend
     */
    ifFeatureStatement : IF_FEATURE_KEYWORD string STMTEND;

    /**
    *    units-stmt          = units-keyword sep string optsep stmtend
    */
    unitsStatement : UNITS_KEYWORD string STMTEND;

    /**
     *   typedef-stmt        = typedef-keyword sep identifier-arg-str optsep
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             type-stmt stmtsep
     *                            [units-stmt stmtsep]
     *                             [default-stmt stmtsep]
     *                             [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                           "}"
     * TODO : 0..1 occurance to be validated in listener
     */
    typedefStatement : TYPEDEF_KEYWORD IDENTIFIER LEFT_CURLY_BRACE
                   (typeStatement | unitsStatement | defaultStatement | statusStatement | descriptionStatement | referenceStatement)*
                   RIGHT_CURLY_BRACE;

    /**
     *  type-stmt           = type-keyword sep identifier-ref-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                            type-body-stmts
     *                         "}")
     */
    typeStatement : TYPE_KEYWORD string (STMTEND | LEFT_CURLY_BRACE typeBodyStatements RIGHT_CURLY_BRACE);

    /**
     *  type-body-stmts     = numerical-restrictions /
     *                        decimal64-specification /
     *                       string-restrictions /
     *                        enum-specification /
     *                        leafref-specification /
     *                        identityref-specification /
     *                        instance-identifier-specification /
     *                        bits-specification /
     *                        union-specification
     * TODO : decimal64-specification to be added
     */
    typeBodyStatements : numericalRestrictions | stringRestrictions | enumSpecification
                    | leafrefSpecification | identityrefSpecification | instanceIdentifierSpecification
                    | bitsSpecification | unionSpecification;

    /**
     *  numerical-restrictions = range-stmt stmtsep
     */
    numericalRestrictions : rangeStatement;

    /**
     *  range-stmt          = range-keyword sep range-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [error-message-stmt stmtsep]
     *                             [error-app-tag-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                          "}")
     */
    rangeStatement : RANGE_KEYWORD string (STMTEND | LEFT_CURLY_BRACE commonStatements RIGHT_CURLY_BRACE);

    commonStatements : errorMessageStatement? errorAppTagStatement? descriptionStatement? referenceStatement?
                 | errorMessageStatement? errorAppTagStatement? referenceStatement? descriptionStatement?
                 | errorMessageStatement? descriptionStatement? errorAppTagStatement? referenceStatement?
                 | errorMessageStatement? descriptionStatement? referenceStatement? errorAppTagStatement?
                 | errorMessageStatement? referenceStatement? errorAppTagStatement? descriptionStatement?
                 | errorMessageStatement? referenceStatement? descriptionStatement? errorAppTagStatement?
                 | errorAppTagStatement? errorMessageStatement? descriptionStatement? referenceStatement?
                 | errorAppTagStatement? errorMessageStatement? referenceStatement? descriptionStatement?
                 | errorAppTagStatement? descriptionStatement? descriptionStatement? errorMessageStatement?
                 | errorAppTagStatement? descriptionStatement? errorMessageStatement? descriptionStatement?
                 | errorAppTagStatement? referenceStatement? errorMessageStatement? descriptionStatement?
                 | errorAppTagStatement? referenceStatement? descriptionStatement? errorMessageStatement?
                 | descriptionStatement? errorMessageStatement? errorAppTagStatement? referenceStatement?
                 | descriptionStatement? errorMessageStatement? referenceStatement? errorAppTagStatement?
                 | descriptionStatement? errorAppTagStatement? errorMessageStatement? referenceStatement?
                 | descriptionStatement? errorAppTagStatement? referenceStatement? errorMessageStatement?
                 | descriptionStatement? referenceStatement? errorMessageStatement? errorAppTagStatement?
                 | descriptionStatement? referenceStatement? errorAppTagStatement? errorMessageStatement?
                 | referenceStatement? errorMessageStatement? descriptionStatement? errorAppTagStatement?
                 | referenceStatement? errorMessageStatement? errorAppTagStatement? descriptionStatement?
                 | referenceStatement? errorAppTagStatement? descriptionStatement? errorMessageStatement?
                 | referenceStatement? errorAppTagStatement? errorMessageStatement? descriptionStatement?
                 | referenceStatement? descriptionStatement? errorMessageStatement? errorAppTagStatement?
                 | referenceStatement? descriptionStatement? errorAppTagStatement? errorMessageStatement?
                 ;

    /**
     *  string-restrictions = ;; these stmts can appear in any order
     *                        [length-stmt stmtsep]
     *                        *(pattern-stmt stmtsep)
     */
    stringRestrictions : ((lengthStatement)? (patternStatement)*) | ((patternStatement)* (lengthStatement)?);

    /**
     *  length-stmt         = length-keyword sep length-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [error-message-stmt stmtsep]
     *                             [error-app-tag-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                          "}")
     */
    lengthStatement : LENGTH_KEYWORD string
                  (STMTEND | LEFT_CURLY_BRACE commonStatements RIGHT_CURLY_BRACE);

    /**
     *  pattern-stmt        = pattern-keyword sep string optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [error-message-stmt stmtsep]
     *                             [error-app-tag-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                          "}")
     */
    patternStatement : PATTERN_KEYWORD string (STMTEND | LEFT_CURLY_BRACE commonStatements RIGHT_CURLY_BRACE);

    /**
     *  default-stmt        = default-keyword sep string stmtend
     */
    defaultStatement : DEFAULT_KEYWORD string STMTEND;

    /**
     *  enum-specification  = 1*(enum-stmt stmtsep)
     */
    enumSpecification : enumStatement+;

    /**
     *  enum-stmt           = enum-keyword sep string optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [value-stmt stmtsep]
     *                             [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                          "}")
     */
    enumStatement : ENUM_KEYWORD string (STMTEND | LEFT_CURLY_BRACE enumStatementBody RIGHT_CURLY_BRACE);

    enumStatementBody : valueStatement? statusStatement? descriptionStatement? referenceStatement?
                   | valueStatement? statusStatement? referenceStatement? descriptionStatement?
                   | valueStatement? descriptionStatement? statusStatement? referenceStatement?
                   | valueStatement? descriptionStatement? referenceStatement? statusStatement?
                   | valueStatement? referenceStatement? statusStatement? descriptionStatement?
                   | valueStatement? referenceStatement? descriptionStatement? statusStatement?
                   | statusStatement? valueStatement? descriptionStatement? referenceStatement?
                   | statusStatement? valueStatement? referenceStatement? descriptionStatement?
                   | statusStatement? descriptionStatement? descriptionStatement? valueStatement?
                   | statusStatement? descriptionStatement? valueStatement? descriptionStatement?
                   | statusStatement? referenceStatement? valueStatement? descriptionStatement?
                   | statusStatement? referenceStatement? descriptionStatement? valueStatement?
                   | descriptionStatement? valueStatement? statusStatement? referenceStatement?
                   | descriptionStatement? valueStatement? referenceStatement? statusStatement?
                   | descriptionStatement? statusStatement? valueStatement? referenceStatement?
                   | descriptionStatement? statusStatement? referenceStatement? valueStatement?
                   | descriptionStatement? referenceStatement? valueStatement? statusStatement?
                   | descriptionStatement? referenceStatement? statusStatement? valueStatement?
                   | referenceStatement? valueStatement? descriptionStatement? statusStatement?
                   | referenceStatement? valueStatement? statusStatement? descriptionStatement?
                   | referenceStatement? statusStatement? descriptionStatement? valueStatement?
                   | referenceStatement? statusStatement? valueStatement? descriptionStatement?
                   | referenceStatement? descriptionStatement? valueStatement? statusStatement?
                   | referenceStatement? descriptionStatement? statusStatement? valueStatement?
                   ;

    /**
     *  leafref-specification =
     *                        ;; these stmts can appear in any order
     *                        path-stmt stmtsep
     *                        [require-instance-stmt stmtsep]
     */
    leafrefSpecification : (pathStatement (requireInstanceStatement)?) | ((requireInstanceStatement)? pathStatement);

    /**
     *  path-stmt           = path-keyword sep path-arg-str stmtend
     */
    pathStatement : PATH_KEYWORD string STMTEND;

    /**
     *  require-instance-stmt = require-instance-keyword sep
     *                           require-instance-arg-str stmtend
     *  require-instance-arg-str = < a string that matches the rule
     *                             require-instance-arg >
     *  require-instance-arg = true-keyword / false-keyword
     */
    requireInstanceStatement : REQUIRE_INSTANCE_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND;

    /**
     *  instance-identifier-specification =
     *                        [require-instance-stmt stmtsep]
     */
    instanceIdentifierSpecification : requireInstanceStatement?;

    /**
     * identityref-specification =
     *                        base-stmt stmtsep
     */
    identityrefSpecification : baseStatement;

    /**
     *  union-specification = 1*(type-stmt stmtsep)
     */
    unionSpecification : typeStatement+;

    /**
     *  bits-specification  = 1*(bit-stmt stmtsep)
     */
    bitsSpecification : bitStatement+;

    /**
     * bit-stmt            = bit-keyword sep identifier-arg-str optsep
     *                       (";" /
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [position-stmt stmtsep]
     *                            [status-stmt stmtsep]
     *                            [description-stmt stmtsep]
     *                            [reference-stmt stmtsep]
     *                          "}"
     *                        "}")
     */
    bitStatement : BIT_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE bitBodyStatement RIGHT_CURLY_BRACE);

    bitBodyStatement : positionStatement? statusStatement? descriptionStatement? referenceStatement?
                  | positionStatement? statusStatement? referenceStatement? descriptionStatement?
                  | positionStatement? descriptionStatement? statusStatement? referenceStatement?
                  | positionStatement? descriptionStatement? referenceStatement? statusStatement?
                  | positionStatement? referenceStatement? statusStatement? descriptionStatement?
                  | positionStatement? referenceStatement? descriptionStatement? statusStatement?
                  | statusStatement? positionStatement? descriptionStatement? referenceStatement?
                  | statusStatement? positionStatement? referenceStatement? descriptionStatement?
                  | statusStatement? descriptionStatement? descriptionStatement? positionStatement?
                  | statusStatement? descriptionStatement? positionStatement? descriptionStatement?
                  | statusStatement? referenceStatement? positionStatement? descriptionStatement?
                  | statusStatement? referenceStatement? descriptionStatement? positionStatement?
                  | descriptionStatement? positionStatement? statusStatement? referenceStatement?
                  | descriptionStatement? positionStatement? referenceStatement? statusStatement?
                  | descriptionStatement? statusStatement? positionStatement? referenceStatement?
                  | descriptionStatement? statusStatement? referenceStatement? positionStatement?
                  | descriptionStatement? referenceStatement? positionStatement? statusStatement?
                  | descriptionStatement? referenceStatement? statusStatement? positionStatement?
                  | referenceStatement? positionStatement? descriptionStatement? statusStatement?
                  | referenceStatement? positionStatement? statusStatement? descriptionStatement?
                  | referenceStatement? statusStatement? descriptionStatement? positionStatement?
                  | referenceStatement? statusStatement? positionStatement? descriptionStatement?
                  | referenceStatement? descriptionStatement? positionStatement? statusStatement?
                  | referenceStatement? descriptionStatement? statusStatement? positionStatement?
                  ;

    /**
     *  position-stmt       = position-keyword sep
     *                        position-value-arg-str stmtend
     *  position-value-arg-str = < a string that matches the rule
     *                              position-value-arg >
     *  position-value-arg  = non-negative-integer-value
     */
    positionStatement : POSITION_KEYWORD INTEGER STMTEND;

    /**
     *  status-stmt         = status-keyword sep status-arg-str stmtend
     *  status-arg-str      = < a string that matches the rule
     *                         status-arg >
     *  status-arg          = current-keyword /
     *                        obsolete-keyword /
     *                        deprecated-keyword
     */
    statusStatement : STATUS_KEYWORD (CURRENT_KEYWORD | OBSOLETE_KEYWORD | DEPRECATED_KEYWORD) STMTEND;

    /**
     *  config-stmt         = config-keyword sep
     *                        config-arg-str stmtend
     *  config-arg-str      = < a string that matches the rule
     *                          config-arg >
     *  config-arg          = true-keyword / false-keyword
     */
    configStatement : CONFIG_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND;

    /**
     *  mandatory-stmt      = mandatory-keyword sep
     *                        mandatory-arg-str stmtend
     *
     *  mandatory-arg-str   = < a string that matches the rule
     *                          mandatory-arg >
     *
     *  mandatory-arg       = true-keyword / false-keyword
     */
    mandatoryStatement : MANDATORY_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND;

    /**
     *  presence-stmt       = presence-keyword sep string stmtend
     */
    presenceStatement : PRESENCE_KEYWORD string STMTEND;

    /**
     *  ordered-by-stmt     = ordered-by-keyword sep
     *                        ordered-by-arg-str stmtend
     *
     *  ordered-by-arg-str  = < a string that matches the rule
     *                          ordered-by-arg >
     *
     *  ordered-by-arg      = user-keyword / system-keyword
     */
    orderedByStatement : ORDERED_BY_KEYWORD (USER_KEYWORD | SYSTEM_KEYWORD) STMTEND;

    /**
     *  must-stmt           = must-keyword sep string optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [error-message-stmt stmtsep]
     *                             [error-app-tag-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                          "}")
     */
    mustStatement : MUST_KEYWORD string (STMTEND | LEFT_CURLY_BRACE commonStatements RIGHT_CURLY_BRACE);

    /**
     *   error-message-stmt  = error-message-keyword sep string stmtend
     */
    errorMessageStatement : ERROR_MESSAGE_KEYWORD string STMTEND;

    /**
     *  error-app-tag-stmt  = error-app-tag-keyword sep string stmtend
     */
    errorAppTagStatement : ERROR_APP_TAG_KEYWORD string STMTEND;

    /**
     *  min-elements-stmt   = min-elements-keyword sep
     *                        min-value-arg-str stmtend
     *  min-value-arg-str   = < a string that matches the rule
     *                          min-value-arg >
     *  min-value-arg       = non-negative-integer-value
     */
    minElementsStatement : MIN_ELEMENTS_KEYWORD INTEGER STMTEND;

    /**
     *  max-elements-stmt   = max-elements-keyword sep
     *                        max-value-arg-str stmtend
     *  max-value-arg-str   = < a string that matches the rule
     *                          max-value-arg >

     */
    maxElementsStatement :  MAX_ELEMENTS_KEYWORD maxValueArgument STMTEND;

    /**
     *  max-value-arg       = unbounded-keyword /
     *                        positive-integer-value
     */
    maxValueArgument : UNBOUNDED_KEYWORD | INTEGER;

    /**
     *  value-stmt          = value-keyword sep integer-value stmtend
     */
    valueStatement : VALUE_KEYWORD ((MINUS INTEGER) | INTEGER) STMTEND;

    /**
     *   grouping-stmt       = grouping-keyword sep identifier-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                             *((typedef-stmt /
     *                                grouping-stmt) stmtsep)
     *                             *(data-def-stmt stmtsep)
     *                         "}")
     * TODO : 0..1 occurance to be checked in listener
     */
    groupingStatement : GROUPING_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE
                      (statusStatement | descriptionStatement | referenceStatement | typedefStatement | groupingStatement
                       | dataDefStatement)* RIGHT_CURLY_BRACE);

    /**
     *  container-stmt      = container-keyword sep identifier-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [when-stmt stmtsep]
     *                             *(if-feature-stmt stmtsep)
     *                             *(must-stmt stmtsep)
     *                             [presence-stmt stmtsep]
     *                             [config-stmt stmtsep]
     *                             [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                             *((typedef-stmt /
     *                                grouping-stmt) stmtsep)
     *                             *(data-def-stmt stmtsep)
     *                         "}")
     * TODO : 0..1 occurance to be checked in listener
     */
    containerStatement : CONTAINER_KEYWORD IDENTIFIER
                     (STMTEND | LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | mustStatement | presenceStatement | configStatement
                     | statusStatement | descriptionStatement | referenceStatement | typedefStatement | groupingStatement
                     | dataDefStatement)* RIGHT_CURLY_BRACE);

    /**
     *  leaf-stmt           = leaf-keyword sep identifier-arg-str optsep
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [when-stmt stmtsep]
     *                            *(if-feature-stmt stmtsep)
     *                            type-stmt stmtsep
     *                            [units-stmt stmtsep]
     *                            *(must-stmt stmtsep)
     *                            [default-stmt stmtsep]
     *                            [config-stmt stmtsep]
     *                            [mandatory-stmt stmtsep]
     *                            [status-stmt stmtsep]
     *                            [description-stmt stmtsep]
     *                            [reference-stmt stmtsep]
     *                         "}"
     * TODO : 0..1 occurance to be checked in listener
     */
    leafStatement : LEAF_KEYWORD IDENTIFIER LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | typeStatement | unitsStatement
              | mustStatement | defaultStatement | configStatement | mandatoryStatement | statusStatement  | descriptionStatement
              | referenceStatement)* RIGHT_CURLY_BRACE;

    /**
     *  leaf-list-stmt      = leaf-list-keyword sep identifier-arg-str optsep
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [when-stmt stmtsep]
     *                            *(if-feature-stmt stmtsep)
     *                            type-stmt stmtsep
     *                            [units-stmt stmtsep]
     *                            *(must-stmt stmtsep)
     *                            [config-stmt stmtsep]
     *                            [min-elements-stmt stmtsep]
     *                            [max-elements-stmt stmtsep]
     *                            [ordered-by-stmt stmtsep]
     *                            [status-stmt stmtsep]
     *                            [description-stmt stmtsep]
     *                            [reference-stmt stmtsep]
     *                         "}"
     * TODO : 0..1 occurance to be checked in listener
     */
    leafListStatement : LEAF_LIST_KEYWORD IDENTIFIER LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | typeStatement
                     | unitsStatement | mustStatement | configStatement | minElementsStatement | maxElementsStatement | orderedByStatement
                     | statusStatement | descriptionStatement | referenceStatement)* RIGHT_CURLY_BRACE;

    /**
     *  list-stmt           = list-keyword sep identifier-arg-str optsep
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [when-stmt stmtsep]
     *                            *(if-feature-stmt stmtsep)
     *                            *(must-stmt stmtsep)
     *                            [key-stmt stmtsep]
     *                            *(unique-stmt stmtsep)
     *                            [config-stmt stmtsep]
     *                            [min-elements-stmt stmtsep]
     *                            [max-elements-stmt stmtsep]
     *                            [ordered-by-stmt stmtsep]
     *                            [status-stmt stmtsep]
     *                            [description-stmt stmtsep]
     *                            [reference-stmt stmtsep]
     *                            *((typedef-stmt /
     *                               grouping-stmt) stmtsep)
     *                            1*(data-def-stmt stmtsep)
     *                         "}"
     * TODO : 0..1 occurance to be checked in listener
     */
    listStatement : LIST_KEYWORD IDENTIFIER LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | mustStatement | keyStatement
              | uniqueStatement | configStatement | minElementsStatement | maxElementsStatement | orderedByStatement | statusStatement
              | descriptionStatement | referenceStatement | typedefStatement | groupingStatement| dataDefStatement)* RIGHT_CURLY_BRACE;

    /**
     *  key-stmt            = key-keyword sep key-arg-str stmtend
     */
    keyStatement : KEY_KEYWORD string STMTEND;

    /**
     *  unique-stmt         = unique-keyword sep unique-arg-str stmtend
     */
    uniqueStatement: UNIQUE_KEYWORD string STMTEND;

    /**
     *  choice-stmt         = choice-keyword sep identifier-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [when-stmt stmtsep]
     *                             *(if-feature-stmt stmtsep)
     *                             [default-stmt stmtsep]
     *                             [config-stmt stmtsep]
     *                             [mandatory-stmt stmtsep]
     *                             [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                             *((short-case-stmt / case-stmt) stmtsep)
     *                         "}")
     * TODO : 0..1 occurance to be checked in listener
     */
    choiceStatement : CHOICE_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | defaultStatement
                  | configStatement | mandatoryStatement | statusStatement | descriptionStatement | referenceStatement | shortCaseStatement
                  | caseStatement)* RIGHT_CURLY_BRACE);

    /**
     *  short-case-stmt     = container-stmt /
     *                        leaf-stmt /
     *                        leaf-list-stmt /
     *                        list-stmt /
     *                        anyxml-stmt
     */
    shortCaseStatement : containerStatement | leafStatement | leafListStatement | listStatement;

    /**
     *  case-stmt           = case-keyword sep identifier-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [when-stmt stmtsep]
     *                             *(if-feature-stmt stmtsep)
     *                             [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                             *(data-def-stmt stmtsep)
     *                         "}")
     * TODO : 0..1 occurance to be checked in listener
     */
    caseStatement : CASE_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | statusStatement
              | descriptionStatement | referenceStatement | dataDefStatement)* RIGHT_CURLY_BRACE);

    /**
     *  uses-stmt           = uses-keyword sep identifier-ref-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [when-stmt stmtsep]
     *                             *(if-feature-stmt stmtsep)
     *                             [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                             *(refine-stmt stmtsep)
     *                             *(uses-augment-stmt stmtsep)
     *                         "}")
     * TODO : 0..1 occurance to be checked in listener
     */
    usesStatement : USES_KEYWORD string (STMTEND | LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | statusStatement
                | descriptionStatement | referenceStatement | refineStatement | usesAugmentStatement)* RIGHT_CURLY_BRACE);

    /**
     *  refine-stmt         = refine-keyword sep refine-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             (refine-container-stmts /
     *                              refine-leaf-stmts /
     *                              refine-leaf-list-stmts /
     *                              refine-list-stmts /
     *                              refine-choice-stmts /
     *                              refine-case-stmts /
     *                              refine-anyxml-stmts)
     *                         "}")
     */
    refineStatement : REFINE_KEYWORD string (STMTEND  | LEFT_CURLY_BRACE (refineContainerStatements | refineLeafStatements
                  | refineLeafListStatements | refineListStatements | refineChoiceStatements | refineCaseStatements)
                  RIGHT_CURLY_BRACE);

    /**
     *  refine-container-stmts =
     *                        ;; these stmts can appear in any order
     *                        *(must-stmt stmtsep)
     *                        [presence-stmt stmtsep]
     *                        [config-stmt stmtsep]
     *                        [description-stmt stmtsep]
     *                         [reference-stmt stmtsep]
     * TODO : 0..1 occurance to be checked in listener
     */
    refineContainerStatements : (mustStatement | presenceStatement | configStatement | descriptionStatement | referenceStatement)* ;

    /**
     *   refine-leaf-stmts   = ;; these stmts can appear in any order
     *                         *(must-stmt stmtsep)
     *                         [default-stmt stmtsep]
     *                         [config-stmt stmtsep]
     *                        [mandatory-stmt stmtsep]
     *                        [description-stmt stmtsep]
     *                        [reference-stmt stmtsep]
     * TODO : 0..1 occurance to be checked in listener
     */
    refineLeafStatements : (mustStatement | defaultStatement | configStatement | mandatoryStatement | descriptionStatement | referenceStatement)*;

    /**
     *  refine-leaf-list-stmts =
     *                        ;; these stmts can appear in any order
     *                        *(must-stmt stmtsep)
     *                        [config-stmt stmtsep]
     *                        [min-elements-stmt stmtsep]
     *                        [max-elements-stmt stmtsep]
     *                        [description-stmt stmtsep]
     *                        [reference-stmt stmtsep]
     * TODO : 0..1 occurance to be checked in listener
     */
    refineLeafListStatements : (mustStatement | configStatement | minElementsStatement | maxElementsStatement | descriptionStatement
                             | referenceStatement)*;

    /**
     *  refine-list-stmts   = ;; these stmts can appear in any order
     *                        *(must-stmt stmtsep)
     *                        [config-stmt stmtsep]
     *                        [min-elements-stmt stmtsep]
     *                        [max-elements-stmt stmtsep]
     *                        [description-stmt stmtsep]
     *                        [reference-stmt stmtsep]
     * TODO : 0..1 occurance to be checked in listener
     */
    refineListStatements : (mustStatement | configStatement | minElementsStatement | maxElementsStatement | descriptionStatement
                        | referenceStatement)*;

    /**
     *  refine-choice-stmts = ;; these stmts can appear in any order
     *                        [default-stmt stmtsep]
     *                        [config-stmt stmtsep]
     *                        [mandatory-stmt stmtsep]
     *                        [description-stmt stmtsep]
     *                        [reference-stmt stmtsep]
     * TODO : 0..1 occurance to be checked in listener
     */
    refineChoiceStatements : (defaultStatement | configStatement | mandatoryStatement | descriptionStatement | referenceStatement)*;

    /**
     *  refine-case-stmts   = ;; these stmts can appear in any order
     *                        [description-stmt stmtsep]
     *                        [reference-stmt stmtsep]
     *
     */
    refineCaseStatements : (descriptionStatement | referenceStatement)? | (referenceStatement | descriptionStatement)?;

    /**
     *  uses-augment-stmt   = augment-keyword sep uses-augment-arg-str optsep
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [when-stmt stmtsep]
     *                            *(if-feature-stmt stmtsep)
     *                            [status-stmt stmtsep]
     *                            [description-stmt stmtsep]
     *                            [reference-stmt stmtsep]
     *                            1*((data-def-stmt stmtsep) /
     *                               (case-stmt stmtsep))
     *                         "}"
     * TODO : 0..1 occurance to be checked in listener
     */
    usesAugmentStatement : AUGMENT_KEYWORD string LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | statusStatement
                        | descriptionStatement | referenceStatement | dataDefStatement | caseStatement)* RIGHT_CURLY_BRACE;

    /**
     *  augment-stmt        = augment-keyword sep augment-arg-str optsep
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [when-stmt stmtsep]
     *                            *(if-feature-stmt stmtsep)
     *                            [status-stmt stmtsep]
     *                            [description-stmt stmtsep]
     *                            [reference-stmt stmtsep]
     *                            1*((data-def-stmt stmtsep) /
     *                               (case-stmt stmtsep))
     *                         "}"
     * TODO : 0..1 occurance to be checked in listener
     */
    augmentStatement : AUGMENT_KEYWORD string LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | statusStatement
                   | descriptionStatement | referenceStatement | dataDefStatement  | caseStatement)* RIGHT_CURLY_BRACE;

    /**
     *  when-stmt           = when-keyword sep string optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                          "}")
     *
     */
    whenStatement : WHEN_KEYWORD string (STMTEND | LEFT_CURLY_BRACE ((descriptionStatement? referenceStatement?)
                       | (referenceStatement? descriptionStatement?)) RIGHT_CURLY_BRACE);

    /**
     *  rpc-stmt            = rpc-keyword sep identifier-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             *(if-feature-stmt stmtsep)
     *                             [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                             *((typedef-stmt /
     *                                grouping-stmt) stmtsep)
     *                             [input-stmt stmtsep]
     *                             [output-stmt stmtsep]
     *                         "}")
     * TODO : 0..1 occurance to be checked in listener
     */
    rpcStatement : RPC_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE (ifFeatureStatement | statusStatement | descriptionStatement
                | referenceStatement | typedefStatement | groupingStatement | inputStatement | outputStatement)* RIGHT_CURLY_BRACE);

    /**
     * input-stmt          = input-keyword optsep
     *                       "{" stmtsep
     *                           ;; these stmts can appear in any order
     *                           *((typedef-stmt /
     *                              grouping-stmt) stmtsep)
     *                           1*(data-def-stmt stmtsep)
     *                         "}"
     */
    inputStatement : INPUT_KEYWORD LEFT_CURLY_BRACE
                 ((typedefStatement | groupingStatement)* | dataDefStatement+)
                 | (dataDefStatement+ | (typedefStatement | groupingStatement)*)RIGHT_CURLY_BRACE;

    /**
     *  output-stmt         = output-keyword optsep
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            *((typedef-stmt /
     *                               grouping-stmt) stmtsep)
     *                            1*(data-def-stmt stmtsep)
     *                        "}"
     */
    outputStatement : OUTPUT_KEYWORD LEFT_CURLY_BRACE
                 ((typedefStatement | groupingStatement)* | dataDefStatement+)
                 | (dataDefStatement+ | (typedefStatement | groupingStatement)*)RIGHT_CURLY_BRACE;

    /**
     *  notification-stmt   = notification-keyword sep
     *                        identifier-arg-str optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             ;; these stmts can appear in any order
     *                             *(if-feature-stmt stmtsep)
     *                             [status-stmt stmtsep]
     *                             [description-stmt stmtsep]
     *                             [reference-stmt stmtsep]
     *                             *((typedef-stmt /
     *                                grouping-stmt) stmtsep)
     *                             *(data-def-stmt stmtsep)
     *                         "}")
     * TODO : 0..1 occurance to be checked in listener
     */
     notificationStatement : NOTIFICATION_KEYWORD IDENTIFIER (STMTEND | LEFT_CURLY_BRACE (ifFeatureStatement | statusStatement
                        | descriptionStatement | referenceStatement | typedefStatement | groupingStatement | dataDefStatement)*
                        RIGHT_CURLY_BRACE);

    /**
     *  deviation-stmt      = deviation-keyword sep
     *                        deviation-arg-str optsep
     *                        "{" stmtsep
     *                            ;; these stmts can appear in any order
     *                            [description-stmt stmtsep]
     *                            [reference-stmt stmtsep]
     *                            (deviate-not-supported-stmt /
     *                              1*(deviate-add-stmt /
     *                                 deviate-replace-stmt /
     *                                 deviate-delete-stmt))
     *                        "}"
     * TODO : 0..1 occurance to be checked in listener
     */
    deviationStatement: DEVIATION_KEYWORD string LEFT_CURLY_BRACE (descriptionStatement | referenceStatement
                    | deviateNotSupportedStatement | deviateAddStatement | deviateReplaceStatement | deviateDeleteStatement)*
                    RIGHT_CURLY_BRACE;

    /**
     * deviate-not-supported-stmt =
     *                       deviate-keyword sep
     *                       not-supported-keyword optsep
     *                       (";" /
     *                        "{" stmtsep
     *                        "}")
     */
    deviateNotSupportedStatement: DEVIATE_KEYWORD NOT_SUPPORTED_KEYWORD (STMTEND | LEFT_CURLY_BRACE RIGHT_CURLY_BRACE);

    /**
     *  deviate-add-stmt    = deviate-keyword sep add-keyword optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             [units-stmt stmtsep]
     *                             *(must-stmt stmtsep)
     *                             *(unique-stmt stmtsep)
     *                             [default-stmt stmtsep]
     *                             [config-stmt stmtsep]
     *                             [mandatory-stmt stmtsep]
     *                             [min-elements-stmt stmtsep]
     *                             [max-elements-stmt stmtsep]
     *                         "}")
     */
    deviateAddStatement: DEVIATE_KEYWORD ADD_KEYWORD (STMTEND | (LEFT_CURLY_BRACE unitsStatement? mustStatement* uniqueStatement*
                      defaultStatement? configStatement? mandatoryStatement? minElementsStatement? maxElementsStatement?
                      RIGHT_CURLY_BRACE));

    /**
     *  deviate-delete-stmt = deviate-keyword sep delete-keyword optsep
     *                        (";" /
     *                         "{" stmtsep
     *                             [units-stmt stmtsep]
     *                             *(must-stmt stmtsep)
     *                             *(unique-stmt stmtsep)
     *                               [default-stmt stmtsep]
     *                           "}")
     */
    deviateDeleteStatement: DEVIATE_KEYWORD DELETE_KEYWORD (STMTEND
                       | (LEFT_CURLY_BRACE  unitsStatement? mustStatement* uniqueStatement* defaultStatement? RIGHT_CURLY_BRACE));

    /**
     *   deviate-replace-stmt = deviate-keyword sep replace-keyword optsep
     *                         (";" /
     *                          "{" stmtsep
     *                              [type-stmt stmtsep]
     *                              [units-stmt stmtsep]
     *                              [default-stmt stmtsep]
     *                              [config-stmt stmtsep]
     *                              [mandatory-stmt stmtsep]
     *                              [min-elements-stmt stmtsep]
     *                              [max-elements-stmt stmtsep]
     *                          "}")
     */
    deviateReplaceStatement: DEVIATE_KEYWORD REPLACE_KEYWORD (STMTEND | (LEFT_CURLY_BRACE typeStatement? unitsStatement?
                           defaultStatement? configStatement? mandatoryStatement? minElementsStatement?
                           maxElementsStatement? RIGHT_CURLY_BRACE));

    string : STRING (PLUS STRING)*;