-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
eapi.pl
1997 lines (1440 loc) · 46.6 KB
/
eapi.pl
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
/*
Author: Pieter Van den Abeele
E-mail: pvdabeel@mac.com
Copyright (c) 2005-2024, Pieter Van den Abeele
Distributed under the terms of the LICENSE file in the root directory of this
project.
*/
/** <module> EAPI
This file contains a DCG grammar for Gentoo Portage cache files and manifests.
This grammar is compatible with EAPI version 7 and earlier.
Cache files:
------------
The portage cache is a directory inside the portage repository
that normally has a file for each ebuild in the portage tree.
In this file, metadata regarding the ebuild can be found.
The metadata inside this file is represented as KEY=VALUE pairs.
Each line has one KEY=VALUE pair.
Manifest files:
---------------
The DCG grammar also parses Manifest files.
Manifest files are found in the portage repository in each category/package
directory. For a given category and package combination, the manifest
contains hash information for all files referenced by the ebuilds in this
category/package.
The metadata inside this file is representated as KEY VALUE pairs.
Each line has one KEY VALUE pair.
The specifications of the grammar can be found in the documentation
directory of this project.
*/
:- module(eapi, []).
% ----------
% EAPI parse
% ----------
%! eapi:parse(+Type,+Repository://+Entry,+Codes,-Metadata)
%
% Predicate used to invoke the parser on a list of metadata codes
%
% Type: Manifest or Metadata
%
% Repository: An atom describing the Repository being parsed
% Entry: An atom describing the Entry being parsed
%
% Codes: A list of codes, representing a line in a cache file
% A line contains a key=value pair.
%
% Metadata: A prolog predicate, i.e. key(value)
eapi:parse(Type,Repository://Entry,Codes,Metadata) :-
phrase(eapi:keyvalue(Type,Repository://Entry,Metadata),Codes).
% -----------------------
% EAPI keyvalue structure
% -----------------------
%! DCG eapi:keyvalue/1
%
% Predicate used to turn eapi 'key=value' and 'key value' pairs into prolog
% key(value) pairs
eapi:keyvalue(Type,Repository://Entry,Metadata) -->
eapi:key(Type,Key),!,
eapi:value(Key,Repository://Entry,Metadata).
% ---------------------------
% EAPI metadata key structure
% ---------------------------
%! DCG eapi:metadata_key/1
%
% Predicate used to retrieve the key from an eapi 'key=value' pair or 'key value' manifest.
%
% private predicate
eapi:key(metadata,Key) -->
eapi:chars_to_equal(Cs),
{ atom_codes(Key,Cs),! }.
eapi:key(manifest,Key) -->
eapi:chars_to_space(Cs),
{ atom_codes(Key,Cs),! }.
eapi:key(query,[Key,M]) -->
eapi:chars_to_comparator(Cs,M),
{ atom_codes(Key,Cs),! }.
% --------------------
% EAPI value structure
% --------------------
%! DCG eapi:value/3
%
% Predicate used to retrieve the value corresponding to a given key.
% Also returns corresponding prolog declaration
%
% private predicates
eapi:value('DEFINED_PHASES',_,defined_phases(P)) -->
!,
eapi:functions(P).
eapi:value('DEPEND',R://E,depend(D)) -->
!,
eapi:depend(R://E,D).
eapi:value('DESCRIPTION',_,description(D)) -->
!,
eapi:description(D).
eapi:value('EAPI',_,eapi(E)) -->
!,
eapi:eapi(E).
eapi:value('HOMEPAGE',_,homepage(H)) -->
!,
eapi:homepage(H).
eapi:value('IUSE',R://E,iuse(I)) -->
!,
eapi:iuse(R://E,I).
eapi:value('KEYWORDS',_,keywords(K)) -->
!,
eapi:keywords(K).
eapi:value('LICENSE',R://E,license(L)) -->
!,
eapi:license(R://E,L).
eapi:value('RDEPEND',R://E,rdepend(D)) -->
!,
eapi:rdepend(R://E,D).
eapi:value('SLOT',_,slot(S)) -->
!,
eapi:slot(S).
eapi:value('SRC_URI',R://E,src_uri(S)) -->
!,
eapi:src_uri(R://E,S).
eapi:value('RESTRICT',R://E,restrict(S)) -->
!,
eapi:restrict(R://E,S).
eapi:value('REQUIRED_USE',R://E,required_use(U)) -->
!,
eapi:required_use(R://E,U).
eapi:value('PDEPEND',R://E,pdepend(D)) -->
!,
eapi:cdepend(R://E,D).
eapi:value('IDEPEND',R://E,idepend(D)) -->
!,
eapi:depend(R://E,D).
eapi:value('BDEPEND',R://E,bdepend(D)) -->
!,
eapi:depend(R://E,D).
eapi:value('PROVIDE',R://E,provide(P)) -->
!,
eapi:provide(R://E,P).
eapi:value('PROPERTIES',R://E,properties(P)) -->
!,
eapi:properties(R://E,P).
eapi:value('_eclasses_',_,eclasses(C)) -->
!,
eapi:inherited(C).
eapi:value('_md5_',_,md5([R])) -->
!,
eapi:md5(R).
eapi:value('EBUILD',_,manifest(ebuild,F,S,H)) -->
!,
eapi:manifest(F,S,H).
eapi:value('MISC',_,manifest(misc,F,S,H)) -->
!,
eapi:manifest(F,S,H).
eapi:value('AUX',_,manifest(aux,F,S,H)) -->
!,
eapi:manifest(F,S,H).
eapi:value('DIST',_,manifest(dist,F,S,H)) -->
!,
eapi:manifest(F,S,H).
eapi:value(_,_,unused(U)) -->
!,
eapi:unused(U).
% --------------------
% EAPI DCG value types
% --------------------
%
% Grammars invoked for parsing the different value types
%
% private predicates
%! DCG depend
%
% EAPI 4 - 9.2 defines a dependency as a dependency sequence.
% Elements of the dependency sequence are packages.
eapi:depend(R://E,D) -->
eapi:dependencies(package_d,R://E,D).
%! DCG rdepend
%
% EAPI 4 - 9.2 defines a runtime dependency as a dependency sequence.
% Elements of the dependency sequence are packages.
eapi:rdepend(R://E,D) -->
eapi:dependencies(package_r,R://E,D).
%! DCG src_uri
%
% EAPI 4 - 9.2.6 defines a src_uri as a dependency sequence.
% Elements of the dependency sequence are uri's.
eapi:src_uri(R://E,S) -->
eapi:dependencies(uri,R://E,S).
%! DCG restrict
%
% EAPI 4 - 9.2.5 defines a restrict as a dependency sequence.
% Elements of the dependency sequence are restrict strings.
eapi:restrict(R://E,S) -->
eapi:dependencies(restrict,R://E,S).
%! DCG homepage
%
% EAPI 4 - 9.2 defines a homepage as a dependency sequence.
% Elements of the dependency sequence are uri's.
%
% Homepage uri's tend to include a wide range of non-standard
% characters, as opposed to src_uri. For this reason parsing
% homepage is an expensive operation. In the current revision
% of this eapi parser, homepages are not parsed, unless needed.
eapi:homepage([H]) -->
eapi:chars_to_end(Hs),
{ atom_codes(H,Hs),! }.
%! DCG license
%
% EAPI 4 - 9.2 defines a license as a dependency sequence.
% Elements of the dependency sequence are license strings.
eapi:license(R://E,L) -->
eapi:dependencies(license,R://E,L).
%! DCG description
%
% EAPI 2.0 defines a description as an unparsed element. This
% is basically pure text information.
eapi:description([D]) -->
eapi:chars_to_end(Ds),
{ string_codes(D,Ds),! }.
%! DCG properties
%
% EAPI defines properties as a dependency sequence
% Elements of the dependency sequence are property strings.
eapi:properties(R://E,P) -->
eapi:dependencies(property,R://E,P).
%! DCG manifest
%
% A Manifest contains a filename, file size, and hashes
eapi:manifest(F,S,H) -->
eapi:chars_to_space(Fs),
eapi:chars_to_space(Ss),
eapi:chars_to_end(Hs),
{ atom_codes(F,Fs),
number_codes(S,Ss),
string_codes(H,Hs),! }.
%! DCG unused
%
% Some of the fields in a cache struct are currently unused.
% This grammar is used to parse those entries. Basically they
% are treated as a char sequence.
eapi:unused([]) -->
eapi:skip_to_end.
%! DCG cdepend
%
% EAPI 4 - 9.2 defines cdepend as a dependency sequence. Elements
% of the sequence are typically packages.
eapi:cdepend(R://E,D) -->
eapi:dependencies(package_c,R://E,D).
%! DCG provide
%
% EAPI 4 - 9.2 defines provide as a dependency sequence. Elements
% of the sequence must be virtuals.
eapi:provide(_,P) -->
eapi:chars_to_end(Ps),
{ atom_codes(P,Ps),! }.
%eapi:dependencies(virtual,P).
%! DCG dependencies
%
% EAPI 4 - 9.1 Grammar for parsing DEPEND, RDEPEND and PDEPEND
%
% Parses zero or more dependencies, separated by whites
eapi:dependencies(T,R://E,[D|Rs]) -->
eapi:whites,
eapi:dependency(T,R://E,D), !,
eapi:dependencies(T,R://E,Rs).
eapi:dependencies(_,_,[]) -->
[],!.
%! DCG dependency
%
% EAPI 4 - 9.2 defines 4 types of dependencies
eapi:dependency(T,R://E,D) -->
eapi:use_conditional_group(T,R://E,D),!.
eapi:dependency(T,R://E,D) -->
eapi:any_of_group(T,R://E,D),!.
eapi:dependency(T,R://E,D) -->
eapi:all_of_group(T,R://E,D),!.
eapi:dependency(T,R://E,D) -->
eapi:exactly_one_of_group(T,R://E,D),!.
eapi:dependency(T,R://E,D) -->
eapi:at_most_one_of_group(T,R://E,D),!.
eapi:dependency(package_d,R://E,D) -->
eapi:package_dependency(install,R://E,D). %!
eapi:dependency(package_r,R://E,D) -->
eapi:package_dependency(run,R://E,D). %!
eapi:dependency(package_c,R://E,D) -->
eapi:package_dependency(compile,R://E,D). %!
eapi:dependency(license,_,D) -->
eapi:string(Ds),
{ atom_codes(D,Ds),! }.
eapi:dependency(property,_,D) -->
eapi:string(Ds),
{ atom_codes(D,Ds),! }.
eapi:dependency(restrict,_,D) -->
eapi:string(D),!.
eapi:dependency(uri,_,D) -->
eapi:uri(D),!.
eapi:dependency(use,_,D) -->
eapi:required_use_flag(D),!.
%! DCG qualified_package
%
% EAPI 4 - 9.2 defines a qualified package
eapi:qualified_package(C,P,V) -->
eapi:category(C),eapi:separator,eapi:package(P),eapi:version(V),!.
%! DCG package_dependency
%
% EAPI 4 - 9.2.4 defines package dependency
eapi:package_dependency(T,R://E,package_dependency(R://E,T,B,C,P,O,V,S,U)) -->
eapi:blocking(B), % optional
eapi:operator(O), % optional
eapi:category(C),eapi:separator,!,eapi:package(P), % required
eapi:version0(V), % optional
eapi:slot_restriction(S), % optional
eapi:use_dependencies(U). % optional
%! DCG use_conditional_group
%
% EAPI 4 - 9.2.2 defines a use conditional dependency
eapi:use_conditional_group(T,R://E,use_conditional_group(P,U,R://E,D)) -->
eapi:use_exclamation(P), % optional
eapi:use_flag(U), % required
[63],!, % required char: ?
eapi:whites, % optional
[40], % required char: (
eapi:dependencies(T,R://E,D), % optional
eapi:whites, % optional
[41]. % required char: )
%! DCG any_of_group
%
% EAPI 4 - 9.2.3 defines an any-of-group dependency
eapi:any_of_group(T,R://E,any_of_group(D)) -->
eapi:choice,!, % required
eapi:whites, % optional
[40], % required char: (
eapi:dependencies(T,R://E,D), % optional
eapi:whites, % optional
[41]. % required char: )
%! DCG all_of_group
%
% EAPI 9.2.1 defines an all-of-group dependency
eapi:all_of_group(T,R://E,all_of_group(D)) -->
[40],!, % required char: (
eapi:dependencies(T,R://E,D), % optional
eapi:whites, % optional
[41]. % required char: )
%! DCG exactly_one_of_group
%
% EAPI 5 - 8.2.0 defines an exactly_one_of dependency
eapi:exactly_one_of_group(T,R://E,exactly_one_of_group(D)) -->
eapi:one_of,!,
eapi:whites,
[40],!, % required char: (
eapi:dependencies(T,R://E,D), % optional
eapi:whites, % optional
[41]. % required char: )
%! DCG at_most_one_of_group
%
% EAPI 5 - 8.2.0 defines an at_most_one_of dependency
eapi:at_most_one_of_group(T,R://E,exactly_one_of_group(D)) -->
eapi:at_most_one,!,
eapi:whites,
[40],!, % required char: (
eapi:dependencies(T,R://E,D), % optional
eapi:whites, % optional
[41]. % required char: )
%! DCG blocking
%
% EAPI 4 - 9.2.4 defines the block operator for package dependencies
eapi:blocking(strong) -->
[33,33],!. % char: !!
eapi:blocking(weak) -->
[33],!. % char: !
eapi:blocking(no) -->
[],!.
%! DCG operator
%
% EAPI 4 - 9.2.4 defines the operators for package dependencies
eapi:operator(greaterequal) -->
[62,61], !. % char: >=
eapi:operator(greaterequal) -->
[61,62], !. % char: =>
eapi:operator(smallerequal) -->
[60,61], !. % char: <=
eapi:operator(smallerequal) -->
[61,60], !. % char: =<
eapi:operator(greater) -->
[62], !. % char: >
eapi:operator(smaller) -->
[60], !. % char: <
eapi:operator(tilde) -->
[126], !. % char: ~
eapi:operator(tilde) -->
[58,61], !. % char: :=
eapi:operator(equal) -->
[61], !. % char: =
eapi:operator(none) -->
[], !.
%! DCG: repository
%
% Repository Names
eapi:repository(Ra) -->
eapi:chars1(c,R),
{ atom_codes(Ra,R),! }.
%! DCG: set
%
% Set Names
eapi:set([64|Sa]) -->
[64],!,
eapi:chars1(c,S),
{ atom_codes(Sa,S),! }.
%! DCG: category
%
% EAPI 4 - 2.1.1 Category Names
eapi:category(Ca) -->
eapi:chars1(c,C),
{ atom_codes(Ca,C),! }.
% DCG: separator
%
% EAPI 4 - 9.2.4 Package dependency specification
eapi:separator -->
[47]. % char: /
% DCG: repositoryseparator
%
% Repository separator
eapi:repositoryseparator -->
[58,47,47]. % char: ://
%! DCG: package
%
% EAPI 4 - 2.1.1 Package Names
eapi:package(P) -->
eapi:pchars(L),
{ eapi:check_package(L),
eapi:convert_package(L,P),! }.
% Case: don't do any checks if package is just one chunck
eapi:check_package(L) :-
length(L,1),!.
% Case: check if package is valid, if there are more than one chunck
eapi:check_package(L) :-
lists:reverse(L,[E,B|_]),
not(eapi:invalid_package_ending(E,B)).
% Converts a list of chuncks to atom
eapi:convert_package(L,P) :-
maplist(atom_codes,R,L),
atomic_list_concat(R,'-',P).
% Case: last chunk is a version
eapi:invalid_package_ending(E,_) :-
phrase(eapi:version2(_),E,[]),!.
% Case: last chunk is a revision AND the chunk before is a version
eapi:invalid_package_ending(E,B) :-
phrase(eapi:versionrevision(_),E,[]),
phrase(eapi:version2(_),B,[]),!.
%! DCG: version
%
% EAPI 5 - 3.2 defines version specification
% eapi:version starts with '-', and cannot be empty
eapi:version(V) -->
eapi:version2([N,W,A,S]),
{ eapi:version2atom(N,W,A,S,V) }.
% eapi:version0 starts with '-', and can be empty
eapi:version0(V) -->
eapi:version2([N,W,A,S]),
{ eapi:version2atom(N,W,A,S,V) }.
eapi:version0([[],'','','','']) -->
[].
% eapi:version2 reads a version following EAPI 5 spec
eapi:version2([N,W,A,S]) -->
eapi:versionnumberpart(N,W),
eapi:versionalphapart(A),
eapi:versionsuffixpart(S).
eapi:version2([[],'','','']) -->
[],!.
% eapi: versionsuffixpart following eapi 5 specs
eapi:versionsuffixpart([S|R]) -->
eapi:versionsuffix(S),
eapi:versionsuffixpart(R).
eapi:versionsuffixpart([]) -->
[].
% eapi: versionnumberpart following eapi 5 specs
eapi:versionnumberpart([C|V],W) -->
eapi:versioninteger(C,_),
[46],!,
eapi:versionnumberpart0(V,W).
eapi:versionnumberpart([C],W) -->
eapi:versioninteger(C,W),!.
eapi:versionnumberpart0([C|V],W) -->
eapi:versioninteger(C,_),
[46],!,
eapi:versionnumberpart0(V,W).
eapi:versionnumberpart0([C],W) -->
eapi:versioninteger(C,W),!.
eapi:versionnumberpart0([],_) -->
[],!.
% eapi: versionalphapart following eapi 5 specs
eapi:versionalphapart([C]) -->
eapi:versionalpha(C),!.
eapi:versionalphapart([]) -->
[],!.
% eapi: versionsuffix following eapi 5 specs
eapi:versionsuffix([95,97,108,112,104,97|V]) -->
[95,97,108,112,104,97], % _alpha
!,
eapi:versioninteger2(V,_).
eapi:versionsuffix([95,98,101,116,97|V]) -->
[95,98,101,116,97], % _beta
!,
eapi:versioninteger2(V,_).
eapi:versionsuffix([95,112,114,101|V]) -->
[95,112,114,101], % _pre
!,
eapi:versioninteger2(V,_).
eapi:versionsuffix([95,114,99|V]) -->
[95,114,99], % _rc
!,
eapi:versioninteger2(V,_).
eapi:versionsuffix([95,112|V]) -->
[95,112], % _p
!,
eapi:versioninteger2(V,_).
eapi:versionsuffix([45,114|V]) --> % -r
[45,114],
!,
eapi:versioninteger(V,_).
eapi:versionrevision([114|V]) --> % (-)r
[114],
!,
eapi:versioninteger(V,_).
% eapi:versioninteger - reads integers (and detect integer wildcard)
eapi:versioninteger([],'*') -->
[42],!.
%eapi:versioninteger2(V,_).
eapi:versioninteger([C|V],W) -->
[C],
{ code_type(C,digit),! },
eapi:versioninteger2(V,W).
eapi:versioninteger2([],'*') -->
[42],!.
%eapi:versioninteger(V,_).
eapi:versioninteger2([C|V],W) -->
[C],
{ code_type(C,digit),! },
eapi:versioninteger2(V,W).
eapi:versioninteger2([],'') -->
[].
% eapi:versionalpha reads alpha
eapi:versionalpha([C]) -->
[C],
{ code_type(C,alpha), !}.
% eapi:version2atom converts version format to atom
eapi:version2atom(N,W,A,S,[Nn,Alphapart,Suffixpart,Fullversion]) :-
maplist(atom_codes,Na,N),
maplist(atom_codes,Aa,A),
maplist(atom_codes,Sa,S),
maplist(atom_number,Na,Nn),
atomic_list_concat(Na,'.',Numberpart),
atomic_list_concat(Aa,Alphapart),
atomic_list_concat(Sa,Suffixpart),
atomic_list_concat([Numberpart,W,Alphapart,Suffixpart],Fullversion).
eapi:version2numberlist('',[]) :- !.
eapi:version2numberlist(NumberAtom,NumberList) :-
atomic_list_concat(SplitAtoms,'.',NumberAtom),
maplist(atom_number,SplitAtoms,NumberList).
%! DCG: md5
%
% EAPI 5 - defines _md5_ metadata
eapi:md5(M) -->
eapi:chars1(m,Ms),
{ atom_codes(M,Ms) }.
%! DCG: slot_restriction
%
% EAPI 4 - 9.2.4 defines slot restriction
eapi:slot_restriction(any_different_slot) -->
[58,42],!. % char: :*
eapi:slot_restriction(any_same_slot) -->
[58,61],!. % char: :=
eapi:slot_restriction(S) -->
[58],!, % char: :
eapi:slot(S).
eapi:slot_restriction([]) -->
[],!.
%! DCG: use_dependencies
%
% EAPI 4 - 9.2.4 defines 2-style use dependencies
eapi:use_dependencies(U) -->
[91],!, % char: [
eapi:whites,
eapi:use_dependency_list(U),
eapi:whites,
[93]. % char: ]
eapi:use_dependencies([]) -->
[],!.
%! DCG: use_dependency_list
%
% EAPI 4 - 9.2.4 defines use dependency list as comma separated
% list of use flags
eapi:use_dependency_list([use(U,D)|R]) -->
eapi:use_dependency(U,D),
eapi:whites,
eapi:comma,!,
eapi:whites,
eapi:use_dependency_list(R).
eapi:use_dependency_list([use(U,D)]) -->
eapi:use_dependency(U,D),!,
eapi:whites.
eapi:use_dependency_list([]) -->
[],!.
%! DCG: use_dependency
%
% EAPI 4 - 9.2.4 defines 2-style use dependency syntax
eapi:use_dependency(inverse(U),D) -->
[33], % char: !
eapi:use_flag(U),
eapi:use_default(D),
[61]. % char: =
eapi:use_dependency(equal(U),D) -->
eapi:use_flag(U),
eapi:use_default(D),
[61]. % char: =
eapi:use_dependency(optdisable(U),D) -->
[33],!, % char: !
eapi:use_flag(U),
eapi:use_default(D),
[63]. % char: ?
eapi:use_dependency(optenable(U),D) -->
eapi:use_flag(U),
eapi:use_default(D),
[63],!. % char: ?
eapi:use_dependency(disable(U),D) -->
[45],!, % char: -
eapi:use_flag(U),
eapi:use_default(D).
eapi:use_dependency(enable(U),D) -->
eapi:use_flag(U),
eapi:use_default(D).
%! DCG use_default
%
% EAPI 4 - 9.2.5.4 defines 4-style use default syntax
eapi:use_default(positive) -->
[40,43,41],!. % chars: (+)
eapi:use_default(negative) -->
[40,45,41],!. % chars: (-)
eapi:use_default(none) -->
[],!.
%! DCG use_exclamation
%
% EAPI 4 - 9.2.2 defines use_exclamation
eapi:use_exclamation(negative) -->
[33],!. % char: !
eapi:use_exclamation(positive) -->
[],!.
%! DCG required_use
%
% EAPI 4 defines required use as a list of use flags, with
% conditional, xor and or relationship.
eapi:required_use(Hash,U) -->
eapi:dependencies(use,Hash,U).
%eapi:chars_to_end(U),
%{ atom_codes(Ua,U),! }.
%! DCG required use flag
%
% Required use flag syntax
eapi:required_use_flag(blocking(U)) -->
[33],!,
eapi:use_flag(U).
eapi:required_use_flag(required(U)) -->
eapi:use_flag(U).
%! DCG iuse
%
% EAPI 4 - 2.1.4 defines iuse as a list of use flags, each possibly
% prefixed with a '+' or a '-' to indicate status.
eapi:iuse(R://E,[plus(U)|Rs]) -->
[43],!, % char: +
eapi:use_flag(U),
eapi:whites,
eapi:iuse(R://E,Rs).
eapi:iuse(R://E,[minus(U)|Rs]) -->
[45],!, % char: -
eapi:use_flag(U),
eapi:whites,
eapi:iuse(R://E,Rs).
eapi:iuse(R://E,[U|Rs]) -->
eapi:use_flag(U),!,
eapi:whites,
eapi:iuse(R://E,Rs).
eapi:iuse(_,[]) -->
[],!.
%! DCG keywords
%
% EAPI 4 - 2.1.6 defines keywords as a list of individual keywords,
% each possibly prefixed with a '~' or a '-' char to indicate status.
eapi:keywords([K|R]) -->
eapi:keyword(K),!,
eapi:whites,
eapi:keywords(R).
eapi:keywords([]) -->
[],!.
%! DCG keyword
%
% EAPI 4 - 2.1.6 defines a keyword as a sequence of chars, each
% possibly prefixed with a '~' or a '-' char to indicate status.
eapi:keyword(unstable(Ka)) -->
[126],!, % char: ~
eapi:kchars(K),
{ atom_codes(Ka,K) }.
eapi:keyword(broken(Ka)) -->
[45],!, % char: -
eapi:kchars(K),
{ atom_codes(Ka,K) }.
eapi:keyword(stable(Ka)) -->
eapi:kchars(K),!,
{ atom_codes(Ka,K) }.
%! DCG inherited
%
% Identical to functions
eapi:inherited([[eclass(F),md5(M)]|R]) -->
eapi:function(F),!,