-
Notifications
You must be signed in to change notification settings - Fork 0
/
yang.pegjs
2586 lines (2196 loc) · 49.6 KB
/
yang.pegjs
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
/*
* YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)
*
* http://tools.ietf.org/html/rfc6020
*
* Limitations & cleanup
* - included errata
* - doesn't check for repetition count of statements where "these stmts can appear in any order"
*
* @append ietf/rfc6020-yang-generic.pegjs
* @append ietf/rfc3986-uri.pegjs
* @append ietf/rfc5234-core-abnf.pegjs
*/
{
function extractOptional(optional, index) {
return optional != null ? optional[index] : null;
}
function extractList(list, index) {
return list.map(function (element) { return element[index];});
}
function buildList(head, tail, index) {
return [head].concat(extractList(tail, index));
}
}
start_rule
= module_stmt
/ submodule_stmt
module_stmt
= optsep k:module_keyword sep a:identifier_arg_str optsep "{" stmtsep h:module_header_stmts l:linkage_stmts m:meta_stmts r:revision_stmts b:body_stmts "}" optsep {
return {
type:"module_stmt",
keyword:k,
arg:a,
subs:h.concat(l,m,r,b),
location: location()
};
}
submodule_stmt
= optsep k:submodule_keyword sep a:identifier_arg_str optsep "{" stmtsep h:submodule_header_stmts l:linkage_stmts m:meta_stmts r:revision_stmts b:body_stmts "}" optsep {
return {
type:"submodule_stmt",
keyword:k,
arg:a,
subs:h.concat(l,m,r,b),
location: location()
};
}
// these stmts can appear in any order
// CHANGE don't check repetition count
module_header_stmts
= l:(module_header_stmt_ stmtsep)* {
return extractList(l, 0);
}
module_header_stmt_
= yang_version_stmt
/ namespace_stmt
/ prefix_stmt
/ unknown_stmt
// these stmts can appear in any order
// CHANGE don't check repetition count
submodule_header_stmts
= l:(submodule_header_stmt_ stmtsep)* {
return extractList(l, 0);
}
submodule_header_stmt_
= yang_version_stmt
/ belongs_to_stmt
/ unknown_stmt
// these stmts can appear in any order
// CHANGE don't check repetition count
meta_stmts
= l:(meta_stmt_ stmtsep)* {
return extractList(l, 0);
}
meta_stmt_
= organization_stmt
/ contact_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
// these stmts can appear in any order
// CHANGE don't check repetition count
linkage_stmts
= l:(linkage_stmt_ stmtsep)* {
return extractList(l, 0);
}
linkage_stmt_
= import_stmt
/ include_stmt
/ unknown_stmt
revision_stmts
= l:(revision_stmt stmtsep)* {
return extractList(l, 0);
}
body_stmts
= l:(body_stmt_ stmtsep)* {
return extractList(l, 0);
}
body_stmt_
= extension_stmt
/ feature_stmt
/ identity_stmt
/ typedef_stmt
/ grouping_stmt
/ data_def_stmt
/ augment_stmt
/ rpc_stmt
/ notification_stmt
/ deviation_stmt
/ unknown_stmt
data_def_stmt
= container_stmt
/ leaf_stmt
/ leaf_list_stmt
/ list_stmt
/ choice_stmt
/ anyxml_stmt
/ uses_stmt
/ unknown_stmt
yang_version_stmt
= k:yang_version_keyword sep a:yang_version_arg_str optsep stmtend {
return {
type:"yang_version_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
yang_version_arg_str
= DQUOTE v:yang_version_arg DQUOTE { return v; }
/ SQUOTE v:yang_version_arg SQUOTE { return v; }
/ yang_version_arg
yang_version_arg
= "1"
import_stmt
= k:import_keyword sep a:identifier_arg_str optsep "{" stmtsep p:prefix_stmt stmtsep d:(revision_date_stmt stmtsep)?
"}" {
return {
type:"import_stmt",
keyword:k,
arg:a,
subs: extractOptional(d, 0) ? [p, extractOptional(d, 0)]:[p],
location: location()
};
}
include_stmt
= k:include_keyword sep a:identifier_arg_str optsep s:include_stmt_subs {
return {
type:"include_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
include_stmt_subs
= ";" { return []; }
/ "{" stmtsep d:(revision_date_stmt stmtsep)? "}" {
return [extractOptional(d, 0)];
}
namespace_stmt
= k:namespace_keyword sep a:uri_str optsep stmtend {
return {
type:"namespace_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
uri_str
= DQUOTE u:uri DQUOTE { return u; }
/ SQUOTE u:uri SQUOTE { return u; }
/ uri
prefix_stmt
= k:prefix_keyword sep a:prefix_arg_str optsep stmtend {
return {
type:"prefix_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
belongs_to_stmt
= k:belongs_to_keyword sep a:identifier_arg_str optsep "{" stmtsep p:prefix_stmt stmtsep "}" {
return {
type:"belongs_to_stmt",
keyword:k,
arg:a,
subs:[p],
location: location()
};
}
organization_stmt
= k:organization_keyword sep a:string optsep stmtend {
return {
type:"organization_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
contact_stmt
= k:contact_keyword sep a:string optsep stmtend {
return {
type:"contact_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
description_stmt
= k:description_keyword sep a:string optsep stmtend {
return {
type:"description_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
reference_stmt
= k:reference_keyword sep a:string optsep stmtend {
return {
type:"reference_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
units_stmt
= k:units_keyword sep a:string optsep stmtend {
return {
type:"units_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
revision_stmt
= k:revision_keyword sep a:revision_date optsep s:revision_stmt_subs {
return {
type:"revision_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
revision_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:revision_stmt_subs_ "}" { return s; }
// CHANGE order doesn't matter
// CHANGE don't check repetition count
revision_stmt_subs_
= l:(revision_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
revision_stmt_sub_
= description_stmt
/ reference_stmt
/ unknown_stmt
revision_date
= date_arg_str
revision_date_stmt
= k:revision_date_keyword sep a:revision_date stmtend {
return {
type:"revision_date_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
extension_stmt
= k:extension_keyword sep a:identifier_arg_str optsep s:extension_stmt_subs {
return {
type:"extension_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
extension_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:extension_stmt_subs_ "}" { return s; }
// these stmts can appear in any order
// CHANGE don't check repetition count
extension_stmt_subs_
= l:(extension_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
extension_stmt_sub_
= argument_stmt
/ status_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
argument_stmt
= k:argument_keyword sep a:identifier_arg_str optsep s:argument_stmt_subs {
return {
type:"argument_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
argument_stmt_subs
= ";" { return [];}
/ "{" stmtsep y:(yin_element_stmt stmtsep)? "}" {
return [extractOptional(y, 0)];
}
yin_element_stmt
= k:yin_element_keyword sep a:yin_element_arg_str stmtend {
return {
type:"yin_element_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
yin_element_arg_str
= DQUOTE y:yin_element_arg DQUOTE { return y; }
/ SQUOTE y:yin_element_arg SQUOTE { return y; }
/ yin_element_arg
yin_element_arg
= true_keyword
/ false_keyword
identity_stmt
= k:identity_keyword sep a:identifier_arg_str optsep s:identity_stmt_subs {
return {
type:"identity_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
identity_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:identity_stmt_subs_ "}" { return s; }
// these stmts can appear in any order
// CHANGE don't check repetition count
identity_stmt_subs_
= l:(identity_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
identity_stmt_sub_
= base_stmt
/ status_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
base_stmt
= k:base_keyword sep a:$identifier_ref_arg_str optsep stmtend {
return {
type:"base_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
feature_stmt
= k:feature_keyword sep a:identifier_arg_str optsep s:feature_stmt_subs {
return {
type:"feature_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
feature_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:feature_stmt_subs_ "}" { return s; }
// these stmts can appear in any order
// CHANGE don't check repetition count
feature_stmt_subs_
= l:(feature_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
feature_stmt_sub_
= if_feature_stmt
/ status_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
if_feature_stmt
= k:if_feature_keyword sep a:$identifier_ref_arg_str optsep stmtend {
return {
type:"if_feature_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
typedef_stmt
= k:typedef_keyword sep a:identifier_arg_str optsep "{" stmtsep s:typedef_stmt_subs_ "}" {
return {
type:"typedef_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
// these stmts can appear in any order
// CHANGE don't check repetition count
typedef_stmt_subs_
= l:(typedef_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
typedef_stmt_sub_
= type_stmt
/ units_stmt
/ default_stmt
/ status_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
type_stmt
= k:type_keyword sep a:$identifier_ref_arg_str optsep s:type_body_stmts {
return {
type:"type_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
type_body_stmts
= ";" { return []; }
/ "{" stmtsep s:type_body_stmts_ "}" { return s; }
// CHANGE add empty body alternative
// CHANGE to counteract making all *_restrictions/*_specification rule required
type_body_stmts_
= l:(type_body_stmt_ stmtsep)* {
return extractList(l, 0);
}
type_body_stmt_
= numerical_restrictions
/ decimal64_specification
/ string_restrictions
/ enum_specification
/ leafref_specification
/ identityref_specification
/ instance_identifier_specification
/ bits_specification
/ union_specification
/ binary_specification
/ unknown_stmt
// CHANGE required
binary_specification
= l:length_stmt stmtsep { return l; }
numerical_restrictions
= r:range_stmt stmtsep { return r; }
range_stmt
= k:range_keyword sep a:range_arg_str optsep s:range_stmt_subs {
return {
type:"range_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
range_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:range_stmt_subs_ "}" { return s; }
// these stmts can appear in any order
// CHANGE don't check repetition count
range_stmt_subs_
= l:(range_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
range_stmt_sub_
= error_message_stmt
/ error_app_tag_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
// these stmts can appear in any order
decimal64_specification
= f:fraction_digits_stmt stmtsep { return f; }
fraction_digits_stmt
= k:fraction_digits_keyword sep a:fraction_digits_arg_str stmtend {
return {
type:"fraction_digits_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
fraction_digits_arg_str
= DQUOTE v:fraction_digits_arg DQUOTE { return v; }
/ SQUOTE v:fraction_digits_arg SQUOTE { return v; }
/ fraction_digits_arg
// CHANGE simplify ranges
fraction_digits_arg
= $("1" [0-8]?)
/ [2-9]
// these stmts can appear in any order
// CHANGE required
// CHANGE don't check repetition count
string_restrictions
= l:string_restriction_ stmtsep {
return l;
}
string_restriction_
= length_stmt
/ pattern_stmt
/ unknown_stmt
length_stmt
= k:length_keyword sep a:length_arg_str optsep s:length_stmt_subs {
return {
type:"length_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
length_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:length_stmt_subs_ "}" { return s; }
// these stmts can appear in any order
// CHANGE don't check repetition count
length_stmt_subs_
= l:(length_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
length_stmt_sub_
= error_message_stmt
/ error_app_tag_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
pattern_stmt
= k:pattern_keyword sep a:string optsep s:pattern_stmt_subs {
return {
type:"pattern_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
pattern_arg
= DQUOTE r:RegexpChoiceExpr DQUOTE { return r; }
/ SQUOTE r:RegexpChoiceExpr SQUOTE { return r; }
pattern_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:pattern_stmt_subs_ "}" { return s; }
// these stmts can appear in any order
// CHANGE don't check repetition count
pattern_stmt_subs_
= l:(pattern_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
pattern_stmt_sub_
= error_message_stmt
/ error_app_tag_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
default_stmt
= k:default_keyword sep a:string stmtend {
return {
type:"default_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
enum_specification
= l:enum_stmt stmtsep {
return l;
}
enum_stmt
= k:enum_keyword sep a:string optsep s:enum_stmt_subs {
return {
type:"enum_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
enum_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:enum_stmt_subs_ "}" { return s; }
// these stmts can appear in any order
// CHANGE don't check repetition count
enum_stmt_subs_
= l:(enum_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
enum_stmt_sub_
= value_stmt
/ status_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
leafref_specification
= p:path_stmt stmtsep { return p; }
path_stmt
= k:path_keyword sep a:path_arg_str stmtend {
return {
type:"path_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
require_instance_stmt
= k:require_instance_keyword sep a:require_instance_arg_str stmtend {
return {
type:"require_instance_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
require_instance_arg_str
= DQUOTE v:require_instance_arg DQUOTE { return v; }
/ SQUOTE v:require_instance_arg SQUOTE { return v; }
/ require_instance_arg
require_instance_arg
= true_keyword
/ false_keyword
// CHANGE required
instance_identifier_specification
= r:require_instance_stmt stmtsep { return r; }
identityref_specification
= b:base_stmt stmtsep { return b; }
union_specification
= l:type_stmt stmtsep {
return l;
}
bits_specification
= l:bit_stmt stmtsep {
return l;
}
bit_stmt
= k:bit_keyword sep a:identifier_arg_str optsep s:bit_stmt_subs {
return {
type:"bit_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
bit_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:bit_stmt_subs_ "}" { return s; }
// these stmts can appear in any order
// CHANGE don't check repetition count
bit_stmt_subs_
= l:(bit_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
bit_stmt_sub_
= position_stmt
/ status_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
position_stmt
= k:position_keyword sep a:position_value_arg_str stmtend {
return {
type:"position_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
position_value_arg_str
= DQUOTE v:position_value_arg DQUOTE { return v; }
/ SQUOTE v:position_value_arg SQUOTE { return v; }
/ position_value_arg
position_value_arg
= non_negative_integer_value
status_stmt
= k:status_keyword sep a:status_arg_str stmtend {
return {
type:"status_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
status_arg_str
= DQUOTE v:status_arg DQUOTE { return v; }
/ SQUOTE v:status_arg SQUOTE { return v; }
/ status_arg
status_arg
= current_keyword
/ obsolete_keyword
/ deprecated_keyword
config_stmt
= k:config_keyword sep a:config_arg_str stmtend {
return {
type:"config_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
config_arg_str
= DQUOTE v:config_arg DQUOTE { return v; }
/ SQUOTE v:config_arg SQUOTE { return v; }
/ config_arg
config_arg
= true_keyword
/ false_keyword
mandatory_stmt
= k:mandatory_keyword sep a:mandatory_arg_str stmtend {
return {
type:"mandatory_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
mandatory_arg_str
= DQUOTE v:mandatory_arg DQUOTE { return v; }
/ SQUOTE v:mandatory_arg SQUOTE { return v; }
/ mandatory_arg
mandatory_arg
= true_keyword
/ false_keyword
presence_stmt
= k:presence_keyword sep a:string stmtend {
return {
type:"presence_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
ordered_by_stmt
= k:ordered_by_keyword sep a:ordered_by_arg_str stmtend {
return {
type:"ordered_by_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
ordered_by_arg_str
= DQUOTE v:ordered_by_arg DQUOTE { return v; }
/ SQUOTE v:ordered_by_arg SQUOTE { return v; }
/ ordered_by_arg
ordered_by_arg
= user_keyword
/ system_keyword
must_stmt
= k:must_keyword sep a:string optsep s:must_stmt_subs {
return {
type:"must_stmt",
keyword:k,
arg:a,
subs:s,
location: location()
};
}
must_stmt_subs
= ";" { return []; }
/ "{" stmtsep s:must_stmt_subs_ "}" { return s; }
// these stmts can appear in any order
// CHANGE don't check repetition count
must_stmt_subs_
= l:(must_stmt_sub_ stmtsep)* {
return extractList(l, 0);
}
must_stmt_sub_
= error_message_stmt
/ error_app_tag_stmt
/ description_stmt
/ reference_stmt
/ unknown_stmt
error_message_stmt
= k:error_message_keyword sep a:string stmtend {
return {
type:"error_message_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
error_app_tag_stmt
= k:error_app_tag_keyword sep a:string stmtend {
return {
type:"error_app_tag_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
min_elements_stmt
= k:min_elements_keyword sep a:min_value_arg_str stmtend {
return {
type:"min_elements_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
min_value_arg_str
= DQUOTE v:min_value_arg DQUOTE { return v; }
/ SQUOTE v:min_value_arg SQUOTE { return v; }
/ min_value_arg
min_value_arg
= non_negative_integer_value
max_elements_stmt
= k:max_elements_keyword sep a:max_value_arg_str stmtend {
return {
type:"max_elements_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}
max_value_arg_str
= DQUOTE v:max_value_arg DQUOTE { return v; }
/ SQUOTE v:max_value_arg SQUOTE { return v; }
/ max_value_arg
max_value_arg
= unbounded_keyword
/ positive_integer_value
value_stmt
= k:value_keyword sep a:integer_value_arg_str stmtend {
return {
type:"value_stmt",
keyword:k,
arg:a,
subs:[],
location: location()
};
}