src/grammar.json -rw-r--r-- 16.5 KiB
1{
2 "name": "diff",
3 "rules": {
4 "source": {
5 "type": "SEQ",
6 "members": [
7 {
8 "type": "REPEAT",
9 "content": {
10 "type": "CHOICE",
11 "members": [
12 {
13 "type": "SYMBOL",
14 "name": "block"
15 },
16 {
17 "type": "SEQ",
18 "members": [
19 {
20 "type": "CHOICE",
21 "members": [
22 {
23 "type": "SYMBOL",
24 "name": "_line"
25 },
26 {
27 "type": "BLANK"
28 }
29 ]
30 },
31 {
32 "type": "PATTERN",
33 "value": "\\r?\\n"
34 }
35 ]
36 }
37 ]
38 }
39 },
40 {
41 "type": "CHOICE",
42 "members": [
43 {
44 "type": "SYMBOL",
45 "name": "_line"
46 },
47 {
48 "type": "BLANK"
49 }
50 ]
51 }
52 ]
53 },
54 "_line": {
55 "type": "CHOICE",
56 "members": [
57 {
58 "type": "SYMBOL",
59 "name": "file_change"
60 },
61 {
62 "type": "SYMBOL",
63 "name": "binary_change"
64 },
65 {
66 "type": "SYMBOL",
67 "name": "index"
68 },
69 {
70 "type": "SYMBOL",
71 "name": "similarity"
72 },
73 {
74 "type": "SYMBOL",
75 "name": "old_file"
76 },
77 {
78 "type": "SYMBOL",
79 "name": "new_file"
80 },
81 {
82 "type": "SYMBOL",
83 "name": "location"
84 },
85 {
86 "type": "SYMBOL",
87 "name": "addition"
88 },
89 {
90 "type": "SYMBOL",
91 "name": "deletion"
92 },
93 {
94 "type": "SYMBOL",
95 "name": "context"
96 },
97 {
98 "type": "SYMBOL",
99 "name": "comment"
100 }
101 ]
102 },
103 "block": {
104 "type": "PREC_RIGHT",
105 "value": 0,
106 "content": {
107 "type": "SEQ",
108 "members": [
109 {
110 "type": "SYMBOL",
111 "name": "command"
112 },
113 {
114 "type": "PATTERN",
115 "value": "\\r?\\n"
116 },
117 {
118 "type": "REPEAT",
119 "content": {
120 "type": "SEQ",
121 "members": [
122 {
123 "type": "CHOICE",
124 "members": [
125 {
126 "type": "SYMBOL",
127 "name": "file_change"
128 },
129 {
130 "type": "SYMBOL",
131 "name": "binary_change"
132 },
133 {
134 "type": "SYMBOL",
135 "name": "index"
136 },
137 {
138 "type": "SYMBOL",
139 "name": "similarity"
140 }
141 ]
142 },
143 {
144 "type": "PATTERN",
145 "value": "\\r?\\n"
146 }
147 ]
148 }
149 },
150 {
151 "type": "CHOICE",
152 "members": [
153 {
154 "type": "SEQ",
155 "members": [
156 {
157 "type": "SYMBOL",
158 "name": "old_file"
159 },
160 {
161 "type": "PATTERN",
162 "value": "\\r?\\n"
163 },
164 {
165 "type": "SYMBOL",
166 "name": "new_file"
167 },
168 {
169 "type": "PATTERN",
170 "value": "\\r?\\n"
171 },
172 {
173 "type": "SYMBOL",
174 "name": "hunks"
175 }
176 ]
177 },
178 {
179 "type": "BLANK"
180 }
181 ]
182 }
183 ]
184 }
185 },
186 "hunks": {
187 "type": "PREC_RIGHT",
188 "value": 0,
189 "content": {
190 "type": "REPEAT1",
191 "content": {
192 "type": "SYMBOL",
193 "name": "hunk"
194 }
195 }
196 },
197 "hunk": {
198 "type": "PREC_RIGHT",
199 "value": 0,
200 "content": {
201 "type": "SEQ",
202 "members": [
203 {
204 "type": "FIELD",
205 "name": "location",
206 "content": {
207 "type": "SYMBOL",
208 "name": "location"
209 }
210 },
211 {
212 "type": "PATTERN",
213 "value": "\\r?\\n"
214 },
215 {
216 "type": "CHOICE",
217 "members": [
218 {
219 "type": "FIELD",
220 "name": "changes",
221 "content": {
222 "type": "SYMBOL",
223 "name": "changes"
224 }
225 },
226 {
227 "type": "BLANK"
228 }
229 ]
230 }
231 ]
232 }
233 },
234 "changes": {
235 "type": "PREC_RIGHT",
236 "value": 0,
237 "content": {
238 "type": "REPEAT1",
239 "content": {
240 "type": "SEQ",
241 "members": [
242 {
243 "type": "CHOICE",
244 "members": [
245 {
246 "type": "SYMBOL",
247 "name": "addition"
248 },
249 {
250 "type": "SYMBOL",
251 "name": "deletion"
252 },
253 {
254 "type": "SYMBOL",
255 "name": "context"
256 }
257 ]
258 },
259 {
260 "type": "PREC_RIGHT",
261 "value": 0,
262 "content": {
263 "type": "REPEAT1",
264 "content": {
265 "type": "PATTERN",
266 "value": "\\r?\\n"
267 }
268 }
269 }
270 ]
271 }
272 }
273 },
274 "command": {
275 "type": "SEQ",
276 "members": [
277 {
278 "type": "IMMEDIATE_TOKEN",
279 "content": {
280 "type": "STRING",
281 "value": "diff"
282 }
283 },
284 {
285 "type": "ALIAS",
286 "content": {
287 "type": "PATTERN",
288 "value": "[-\\w]+"
289 },
290 "named": true,
291 "value": "argument"
292 },
293 {
294 "type": "SYMBOL",
295 "name": "filename"
296 }
297 ]
298 },
299 "file_change": {
300 "type": "CHOICE",
301 "members": [
302 {
303 "type": "SEQ",
304 "members": [
305 {
306 "type": "CHOICE",
307 "members": [
308 {
309 "type": "STRING",
310 "value": "new"
311 },
312 {
313 "type": "STRING",
314 "value": "deleted"
315 }
316 ]
317 },
318 {
319 "type": "STRING",
320 "value": "file"
321 },
322 {
323 "type": "STRING",
324 "value": "mode"
325 },
326 {
327 "type": "SYMBOL",
328 "name": "mode"
329 }
330 ]
331 },
332 {
333 "type": "SEQ",
334 "members": [
335 {
336 "type": "CHOICE",
337 "members": [
338 {
339 "type": "STRING",
340 "value": "new"
341 },
342 {
343 "type": "STRING",
344 "value": "old"
345 }
346 ]
347 },
348 {
349 "type": "STRING",
350 "value": "mode"
351 },
352 {
353 "type": "SYMBOL",
354 "name": "mode"
355 }
356 ]
357 },
358 {
359 "type": "SEQ",
360 "members": [
361 {
362 "type": "STRING",
363 "value": "rename"
364 },
365 {
366 "type": "CHOICE",
367 "members": [
368 {
369 "type": "STRING",
370 "value": "from"
371 },
372 {
373 "type": "STRING",
374 "value": "to"
375 }
376 ]
377 },
378 {
379 "type": "SYMBOL",
380 "name": "filename"
381 }
382 ]
383 }
384 ]
385 },
386 "binary_change": {
387 "type": "SEQ",
388 "members": [
389 {
390 "type": "IMMEDIATE_TOKEN",
391 "content": {
392 "type": "STRING",
393 "value": "Binary"
394 }
395 },
396 {
397 "type": "STRING",
398 "value": "files"
399 },
400 {
401 "type": "SYMBOL",
402 "name": "filename"
403 },
404 {
405 "type": "STRING",
406 "value": "and"
407 },
408 {
409 "type": "SYMBOL",
410 "name": "filename"
411 },
412 {
413 "type": "STRING",
414 "value": "differ"
415 }
416 ]
417 },
418 "index": {
419 "type": "SEQ",
420 "members": [
421 {
422 "type": "IMMEDIATE_TOKEN",
423 "content": {
424 "type": "STRING",
425 "value": "index"
426 }
427 },
428 {
429 "type": "SYMBOL",
430 "name": "commit"
431 },
432 {
433 "type": "STRING",
434 "value": ".."
435 },
436 {
437 "type": "SYMBOL",
438 "name": "commit"
439 },
440 {
441 "type": "CHOICE",
442 "members": [
443 {
444 "type": "SYMBOL",
445 "name": "mode"
446 },
447 {
448 "type": "BLANK"
449 }
450 ]
451 }
452 ]
453 },
454 "similarity": {
455 "type": "SEQ",
456 "members": [
457 {
458 "type": "IMMEDIATE_TOKEN",
459 "content": {
460 "type": "STRING",
461 "value": "similarity"
462 }
463 },
464 {
465 "type": "STRING",
466 "value": "index"
467 },
468 {
469 "type": "ALIAS",
470 "content": {
471 "type": "PATTERN",
472 "value": "\\d+"
473 },
474 "named": true,
475 "value": "score"
476 },
477 {
478 "type": "STRING",
479 "value": "%"
480 }
481 ]
482 },
483 "old_file": {
484 "type": "SEQ",
485 "members": [
486 {
487 "type": "IMMEDIATE_TOKEN",
488 "content": {
489 "type": "STRING",
490 "value": "---"
491 }
492 },
493 {
494 "type": "SYMBOL",
495 "name": "filename"
496 }
497 ]
498 },
499 "new_file": {
500 "type": "SEQ",
501 "members": [
502 {
503 "type": "IMMEDIATE_TOKEN",
504 "content": {
505 "type": "STRING",
506 "value": "+++"
507 }
508 },
509 {
510 "type": "SYMBOL",
511 "name": "filename"
512 }
513 ]
514 },
515 "location": {
516 "type": "SEQ",
517 "members": [
518 {
519 "type": "IMMEDIATE_TOKEN",
520 "content": {
521 "type": "STRING",
522 "value": "@@"
523 }
524 },
525 {
526 "type": "SYMBOL",
527 "name": "linerange"
528 },
529 {
530 "type": "SYMBOL",
531 "name": "linerange"
532 },
533 {
534 "type": "STRING",
535 "value": "@@"
536 },
537 {
538 "type": "CHOICE",
539 "members": [
540 {
541 "type": "PATTERN",
542 "value": "[^\\r\\n]+"
543 },
544 {
545 "type": "BLANK"
546 }
547 ]
548 }
549 ]
550 },
551 "addition": {
552 "type": "CHOICE",
553 "members": [
554 {
555 "type": "SEQ",
556 "members": [
557 {
558 "type": "IMMEDIATE_TOKEN",
559 "content": {
560 "type": "STRING",
561 "value": "+"
562 }
563 },
564 {
565 "type": "CHOICE",
566 "members": [
567 {
568 "type": "PATTERN",
569 "value": "[^\\r\\n]+"
570 },
571 {
572 "type": "BLANK"
573 }
574 ]
575 }
576 ]
577 },
578 {
579 "type": "SEQ",
580 "members": [
581 {
582 "type": "IMMEDIATE_TOKEN",
583 "content": {
584 "type": "STRING",
585 "value": "++"
586 }
587 },
588 {
589 "type": "CHOICE",
590 "members": [
591 {
592 "type": "PATTERN",
593 "value": "[^\\r\\n]+"
594 },
595 {
596 "type": "BLANK"
597 }
598 ]
599 }
600 ]
601 },
602 {
603 "type": "SEQ",
604 "members": [
605 {
606 "type": "IMMEDIATE_TOKEN",
607 "content": {
608 "type": "STRING",
609 "value": "+++"
610 }
611 }
612 ]
613 },
614 {
615 "type": "SEQ",
616 "members": [
617 {
618 "type": "IMMEDIATE_TOKEN",
619 "content": {
620 "type": "STRING",
621 "value": "++++"
622 }
623 },
624 {
625 "type": "CHOICE",
626 "members": [
627 {
628 "type": "PATTERN",
629 "value": "[^\\r\\n]+"
630 },
631 {
632 "type": "BLANK"
633 }
634 ]
635 }
636 ]
637 }
638 ]
639 },
640 "deletion": {
641 "type": "CHOICE",
642 "members": [
643 {
644 "type": "SEQ",
645 "members": [
646 {
647 "type": "IMMEDIATE_TOKEN",
648 "content": {
649 "type": "STRING",
650 "value": "-"
651 }
652 },
653 {
654 "type": "CHOICE",
655 "members": [
656 {
657 "type": "PATTERN",
658 "value": "[^\\r\\n]+"
659 },
660 {
661 "type": "BLANK"
662 }
663 ]
664 }
665 ]
666 },
667 {
668 "type": "SEQ",
669 "members": [
670 {
671 "type": "IMMEDIATE_TOKEN",
672 "content": {
673 "type": "STRING",
674 "value": "--"
675 }
676 },
677 {
678 "type": "CHOICE",
679 "members": [
680 {
681 "type": "PATTERN",
682 "value": "[^\\r\\n]+"
683 },
684 {
685 "type": "BLANK"
686 }
687 ]
688 }
689 ]
690 },
691 {
692 "type": "SEQ",
693 "members": [
694 {
695 "type": "IMMEDIATE_TOKEN",
696 "content": {
697 "type": "STRING",
698 "value": "---"
699 }
700 }
701 ]
702 },
703 {
704 "type": "SEQ",
705 "members": [
706 {
707 "type": "IMMEDIATE_TOKEN",
708 "content": {
709 "type": "STRING",
710 "value": "----"
711 }
712 },
713 {
714 "type": "CHOICE",
715 "members": [
716 {
717 "type": "PATTERN",
718 "value": "[^\\r\\n]+"
719 },
720 {
721 "type": "BLANK"
722 }
723 ]
724 }
725 ]
726 }
727 ]
728 },
729 "context": {
730 "type": "TOKEN",
731 "content": {
732 "type": "PREC",
733 "value": -1,
734 "content": {
735 "type": "PATTERN",
736 "value": "[^\\r\\n]+"
737 }
738 }
739 },
740 "comment": {
741 "type": "SEQ",
742 "members": [
743 {
744 "type": "IMMEDIATE_TOKEN",
745 "content": {
746 "type": "STRING",
747 "value": "#"
748 }
749 },
750 {
751 "type": "CHOICE",
752 "members": [
753 {
754 "type": "PATTERN",
755 "value": "[^\\r\\n]+"
756 },
757 {
758 "type": "BLANK"
759 }
760 ]
761 }
762 ]
763 },
764 "linerange": {
765 "type": "PATTERN",
766 "value": "[-\\+]\\d+(,\\d+)?"
767 },
768 "filename": {
769 "type": "REPEAT1",
770 "content": {
771 "type": "PATTERN",
772 "value": "\\S+"
773 }
774 },
775 "commit": {
776 "type": "PATTERN",
777 "value": "[a-f0-9]{7,40}"
778 },
779 "mode": {
780 "type": "PATTERN",
781 "value": "\\d+"
782 }
783 },
784 "extras": [
785 {
786 "type": "PATTERN",
787 "value": "[\\t\\f\\v ]+"
788 }
789 ],
790 "conflicts": [],
791 "precedences": [],
792 "externals": [],
793 "inline": [],
794 "supertypes": []
795}
796