]> matita.cs.unibo.it Git - helm.git/blob - helm/papers/matita/klunum.bst
ocaml 3.09 transition
[helm.git] / helm / papers / matita / klunum.bst
1 % This style produces citations in the `author-year' format.
2 % It supports two forms of citation: the \cite command produces:  (Author, year)
3 % in the text; the \cite* command only:  (year) .
4
5  
6 ENTRY
7   { address
8     author
9     booktitle
10     chapter
11     edition
12     editor
13     howpublished
14     institution
15     journal
16     key
17     note
18     number
19     organization
20     pages
21     publisher
22     school
23     series
24     title
25     type
26     volume
27     year
28   }
29   {}
30   { label extra.label sort.label }
31  
32 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
33  
34 FUNCTION {init.state.consts}
35 { #0 'before.all :=
36   #1 'mid.sentence :=
37   #2 'after.sentence :=
38   #3 'after.block :=
39 }
40  
41 STRINGS { s t }
42  
43 FUNCTION {output.nonnull}
44 { 's :=
45   output.state mid.sentence =
46     { ", " * write$ }
47     { output.state after.block =
48         { add.period$ write$
49           newline$
50           "\newblock " write$
51         }
52         { output.state before.all =
53             'write$
54             { add.period$ " " * write$ }
55           if$
56         }
57       if$
58       mid.sentence 'output.state :=
59     }
60   if$
61   s
62 }
63  
64 FUNCTION {output.nonnull.extra}
65 { 's :=
66   output.state mid.sentence =
67     { " " * write$ }
68     { output.state after.block =
69         { add.period$  write$
70           newline$
71           "\newblock " write$
72         }
73         { output.state before.all =
74             'write$
75             { add.period$ " " * write$ }
76           if$
77         }
78       if$
79       mid.sentence 'output.state :=
80     }
81   if$
82   s
83 }
84  
85 FUNCTION {output}
86 { duplicate$ empty$
87     'pop$
88     'output.nonnull
89   if$
90 }
91  
92 FUNCTION {output.extra}
93 { duplicate$ empty$
94     'pop$
95     'output.nonnull.extra
96   if$
97 }
98  
99 FUNCTION {output.check}
100 { 't :=
101   duplicate$ empty$
102     { pop$ "empty " t * " in " * cite$ * warning$ }
103     'output.nonnull
104   if$
105 }
106  
107 FUNCTION {output.check.extra}
108 { 't :=
109   duplicate$ empty$
110     { pop$ "empty " t * " in " * cite$ * warning$ }
111     'output.nonnull.extra
112   if$
113 }
114  
115 FUNCTION {output.year.check}
116 { year empty$
117     { "empty year in " cite$ * warning$ }
118     { write$
119       ": " year * extra.label * 
120       mid.sentence 'output.state :=
121     }
122   if$
123 }
124  
125 FUNCTION {output.bibitem}
126 { newline$
127   "\bibitem{" write$
128   cite$ write$
129   "}" write$
130   newline$
131   ""
132   before.all 'output.state :=
133 }
134  
135 FUNCTION {fin.entry}
136 { add.period$
137   write$
138   newline$
139 }
140  
141 FUNCTION {new.block}
142 { output.state before.all =
143     'skip$
144     { after.block 'output.state := }
145   if$
146 }
147  
148 FUNCTION {new.sentence}
149 { output.state after.block =
150     'skip$
151     { output.state before.all =
152         'skip$
153         { after.sentence 'output.state := }
154       if$
155     }
156   if$
157 }
158  
159 FUNCTION {not}
160 {   { #0 }
161     { #1 }
162   if$
163 }
164  
165 FUNCTION {and}
166 {   'skip$
167     { pop$ #0 }
168   if$
169 }
170  
171 FUNCTION {or}
172 {   { pop$ #1 }
173     'skip$
174   if$
175 }
176  
177 FUNCTION {new.block.checkb}
178 { empty$
179   swap$ empty$
180   and
181     'skip$
182     'new.block
183   if$
184 }
185  
186 FUNCTION {field.or.null}
187 { duplicate$ empty$
188     { pop$ "" }
189     'skip$
190   if$
191 }
192  
193 FUNCTION {boldface}
194 { duplicate$ empty$
195     { pop$ "" }
196     { "{\bf " swap$ * "}" * }
197   if$
198 }
199  
200 FUNCTION {emphasize}
201 { duplicate$ empty$
202     { pop$ "" }
203     { "{\em " swap$ * "}" * }
204   if$
205 }
206  
207 INTEGERS { nameptr namesleft numnames }
208  
209 FUNCTION {format.names}
210 { 's :=
211   #1 'nameptr :=
212   s num.names$ 'numnames :=
213   numnames 'namesleft :=
214     { namesleft #0 > }
215     { nameptr #1 >
216         { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't := }
217         { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't := }
218       if$
219       nameptr #1 >
220         { namesleft #1 >
221             { ", " * t * }
222             { numnames #2 >
223                 { "," * }
224                 'skip$
225               if$
226               t "others" =
227                 { " et~al." * }
228                 { " and " * t * }
229               if$
230             }
231           if$
232         }
233         't
234       if$
235       nameptr #1 + 'nameptr :=
236       namesleft #1 - 'namesleft :=
237     }
238   while$
239 }
240  
241 FUNCTION {format.ed.names}
242 { 's :=
243   #1 'nameptr :=
244   s num.names$ 'numnames :=
245   numnames 'namesleft :=
246     { namesleft #0 > }
247     { nameptr #1 >
248         { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't := }
249         { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't := }
250       if$
251       nameptr #1 >
252         { namesleft #1 >
253             { ", " * t * }
254             { numnames #2 >
255                 { "," * }
256                 'skip$
257               if$
258               t "others" =
259                 { " et~al." * }
260                 { " and " * t * }
261               if$
262             }
263           if$
264         }
265         't
266       if$
267       nameptr #1 + 'nameptr :=
268       namesleft #1 - 'namesleft :=
269     }
270   while$
271 }
272
273 FUNCTION {format.authors}
274 { author empty$
275     { "" }
276     { author format.names }
277   if$
278 }
279  
280 FUNCTION {format.key}
281 { empty$
282     { key field.or.null }
283     { "" }
284   if$
285 }
286
287 FUNCTION {format.editors}
288 { editor empty$
289     { "" }
290     { editor format.names
291       editor num.names$ #1 >
292         { " (eds.)" * }
293         { " (ed.)" * }
294       if$
295     }
296   if$
297 }
298  
299 FUNCTION {format.editors.extra}
300 { editor empty$
301     { "" }
302     { editor format.ed.names
303       editor num.names$ #1 >
304         { " (eds.)" * }
305         { " (ed.)" * }
306       if$
307     }
308   if$
309 }
310  
311 FUNCTION {format.title}
312 { title empty$
313     { "" }
314     { "`" title "'" * * }
315   if$
316 }
317  
318 FUNCTION {n.dashify}
319 { 't :=
320   ""
321     { t empty$ not }
322     { t #1 #1 substring$ "-" =
323         { t #1 #2 substring$ "--" = not
324             { "--" *
325               t #2 global.max$ substring$ 't :=
326             }
327             {   { t #1 #1 substring$ "-" = }
328                 { "-" *
329                   t #2 global.max$ substring$ 't :=
330                 }
331               while$
332             }
333           if$
334         }
335         { t #1 #1 substring$ *
336           t #2 global.max$ substring$ 't :=
337         }
338       if$
339     }
340   while$
341 }
342  
343 FUNCTION {first.page.number}
344 { 't :=
345   ""
346     { t "" =
347         { #0 }
348         { t #1 #1 substring$ "-" = not }
349       if$
350     }
351     { t #1 #1 substring$ *
352       t #2 global.max$ substring$ 't :=
353     }
354   while$
355 }
356
357 FUNCTION {format.btitle}
358 { title emphasize
359 }
360  
361 FUNCTION {tie.or.space.connect}
362 { duplicate$ text.length$ #3 <
363     { "~" }
364     { " " }
365   if$
366   swap$ * *
367 }
368  
369 FUNCTION {either.or.check}
370 { empty$
371     'pop$
372     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
373   if$
374 }
375  
376 FUNCTION {format.bvolume}
377 { volume empty$
378     { "" }
379     { "Vol." volume tie.or.space.connect
380       series empty$
381         'skip$
382         { " of " * series emphasize * }
383       if$
384       "volume and number" number either.or.check
385     }
386   if$
387 }
388  
389 FUNCTION {format.number.series}
390 { volume empty$
391     { number empty$
392         { series field.or.null }
393         { output.state mid.sentence =
394             { "No." }
395             { "No." }
396           if$
397           number tie.or.space.connect
398           series empty$
399             { "there's a number but no series in " cite$ * warning$ }
400             { " in " * series * }
401           if$
402         }
403       if$
404     }
405     { "" }
406   if$
407 }
408  
409 FUNCTION {format.edition}
410 { edition empty$
411     { "" }
412     { output.state mid.sentence =
413         { edition "l" change.case$ " edition" * }
414         { edition "t" change.case$ " edition" * }
415       if$
416     }
417   if$
418 }
419  
420 INTEGERS { multiresult }
421  
422 FUNCTION {multi.page.check}
423 { 't :=
424   #0 'multiresult :=
425     { multiresult not
426       t empty$ not
427       and
428     }
429     { t #1 #1 substring$
430       duplicate$ "-" =
431       swap$ duplicate$ "," =
432       swap$ "+" =
433       or or
434         { #1 'multiresult := }
435         { t #2 global.max$ substring$ 't := }
436       if$
437     }
438   while$
439   multiresult
440 }
441  
442 FUNCTION {format.pages}
443 { pages empty$
444     { "" }
445     { pages multi.page.check
446         { "pp." pages n.dashify tie.or.space.connect }
447         { "p." pages tie.or.space.connect }
448       if$
449     }
450   if$
451 }
452
453 FUNCTION {format.page}
454 { pages empty$
455     { "" }
456     { "p.~" pages first.page.number * }
457   if$
458 }
459
460 FUNCTION {format.vol.num.pages}
461 { volume field.or.null
462   volume empty$
463     'skip$
464     { boldface }
465   if$
466   number empty$
467     'skip$
468     { "(" number * ")" * *
469       volume empty$
470         { "there's a number but no volume in " cite$ * warning$ }
471         'skip$
472       if$
473     }
474   if$
475   pages empty$
476     'skip$
477     { duplicate$ empty$
478         { pop$ format.pages }
479         { ", " * pages n.dashify * }
480       if$
481     }
482   if$
483 }
484
485 FUNCTION {format.vol.num.page}
486 { volume field.or.null
487   volume empty$
488     'skip$
489     { boldface }
490   if$
491   number empty$
492     'skip$
493     { "(" number * ")" * *
494       volume empty$
495         { "there's a number but no volume in " cite$ * warning$ }
496         'skip$
497       if$
498     }
499   if$
500   pages empty$
501     'skip$
502     { duplicate$ empty$
503         { pop$ format.pages }
504         { ", " * pages first.page.number * }
505       if$
506     }
507   if$
508 }
509
510 FUNCTION {format.chapter.pages}
511 { chapter empty$
512     'format.pages
513     { type empty$
514         { "Chapt." }
515         { type "l" change.case$ }
516       if$
517       chapter tie.or.space.connect
518       pages empty$
519         'skip$
520         { ", " * format.pages * }
521       if$
522     }
523   if$
524 }
525  
526 FUNCTION {format.in.ed.booktitle}
527 { booktitle empty$
528     { "" }
529     { editor empty$
530         { "In: " booktitle emphasize * }
531         { "In: " format.editors.extra * ": " * booktitle emphasize * }
532       if$
533     }
534   if$
535 }
536  
537 FUNCTION {format.in.booktitle.or.series}
538 { booktitle empty$
539     { series empty$
540         { "" }
541         { "In: " series emphasize * }
542       if$
543     }
544     { editor empty$
545         { "In: " booktitle emphasize * }
546         { "In: " format.editors.extra * ": " * booktitle emphasize * }
547       if$ 
548     }
549   if$
550 }
551  
552 FUNCTION {format.thesis.type}
553 { type empty$
554     'skip$
555     { pop$
556       type "t" change.case$
557     }
558   if$
559 }
560  
561 FUNCTION {format.tr.number}
562 { type empty$
563     { "Technical Report" }
564     'type
565   if$
566   number empty$
567     { "t" change.case$ }
568     { number tie.or.space.connect }
569   if$
570 }
571  
572 FUNCTION {format.article.crossref}
573 { "in"
574   " \cite{" * crossref * "}" *
575 }
576  
577 FUNCTION {format.book.crossref}
578 { volume empty$
579     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
580       "in "
581     }
582     { "Vol." volume tie.or.space.connect
583       " of " *
584     }
585   if$
586   "\cite{" * crossref * "}" *
587 }
588  
589 FUNCTION {format.incoll.inproc.crossref}
590 { "in"
591   " \cite{" * crossref * "}" *
592 }
593  
594 FUNCTION {article}
595 { output.bibitem
596   format.authors "author" output.check
597   author format.key output
598   output.year.check
599   format.title "title" output.check
600   new.block
601   crossref missing$
602     { journal emphasize "journal" output.check.extra
603       format.vol.num.pages output.extra
604     }
605     { format.article.crossref output.nonnull
606       format.pages output
607     }
608   if$
609   new.block
610   note output
611   fin.entry
612 }
613  
614 FUNCTION {book}
615 { output.bibitem
616   author empty$
617     { format.editors "author and editor" output.check
618       editor format.key output
619     }
620     { format.authors output.nonnull
621       crossref missing$
622         { "author and editor" editor either.or.check }
623         'skip$
624       if$
625     }
626   if$
627   output.year.check
628   format.btitle "title" output.check
629   crossref missing$
630     { format.bvolume output
631       format.number.series output
632       new.block
633       address empty$
634         'skip$
635         { address ":" * output }
636       if$
637       publisher "publisher" output.check.extra
638     }
639     { new.block
640       format.book.crossref output.nonnull
641     }
642   if$
643   format.edition output
644   new.block
645   note output
646   fin.entry
647 }
648  
649 FUNCTION {booklet}
650 { output.bibitem
651   format.authors output
652   author format.key output
653   output.year.check
654   format.btitle "title" output.check
655   new.block
656   howpublished output
657   address output
658   new.block
659   note output
660   fin.entry
661 }
662  
663 FUNCTION {inbook}
664 { output.bibitem
665   author empty$
666     { format.editors "author and editor" output.check
667       editor format.key output
668     }
669     { format.authors output.nonnull
670       crossref missing$
671         { "author and editor" editor either.or.check }
672         'skip$
673       if$
674     }
675   if$
676   output.year.check
677   format.btitle "title" output.check
678   crossref missing$
679     { format.bvolume output
680       format.chapter.pages "chapter and pages" output.check
681       format.number.series output
682       new.block
683       address empty$
684         'skip$
685         { address ":" * output }
686       if$
687       publisher "publisher" output.check.extra
688     }
689     { format.chapter.pages "chapter and pages" output.check
690       new.block
691       format.book.crossref output.nonnull
692     }
693   if$
694   format.edition output
695   new.block
696   note output
697   fin.entry
698 }
699  
700 FUNCTION {incollection}
701 { output.bibitem
702   format.authors "author" output.check
703   author format.key output
704   output.year.check
705   format.title "title" output.check
706   new.block
707   crossref missing$
708     { format.in.ed.booktitle "booktitle" output.check
709       format.bvolume output
710       format.number.series output
711       new.block
712       address empty$
713         'skip$
714         { address ":" * output }
715       if$
716       publisher "publisher" output.check.extra
717       format.edition output
718       format.chapter.pages output
719     }
720     { format.incoll.inproc.crossref output.nonnull
721       format.chapter.pages output
722     }
723   if$
724   new.block
725   note output
726   fin.entry
727 }
728  
729 FUNCTION {inproceedings}
730 { output.bibitem
731   format.authors "author" output.check
732   author format.key output
733   output.year.check
734   format.title "title" output.check
735   new.block
736   crossref missing$
737     { format.in.booktitle.or.series "booktitle or series" output.check
738       format.bvolume output
739       new.sentence
740       address output
741       format.pages output
742     }
743     { format.incoll.inproc.crossref output.nonnull
744       format.pages output
745     }
746   if$
747   new.block
748   note output
749   fin.entry
750 }
751  
752 FUNCTION {conference} { inproceedings }
753  
754 FUNCTION {manual}
755 { output.bibitem
756   format.authors output
757   author format.key output
758   output.year.check
759   format.title "title" output.check
760   new.block
761   organization output
762   address output
763   format.edition output
764   new.block
765   note output
766   fin.entry
767 }
768  
769 FUNCTION {mastersthesis}
770 { output.bibitem
771   format.authors "author" output.check
772   author format.key output
773   output.year.check
774   format.title "title" output.check
775   new.block
776   "Master's thesis" format.thesis.type output.nonnull
777   school "school" output.check
778   address output
779   new.block
780   note output
781   fin.entry
782 }
783  
784 FUNCTION {misc}
785 { output.bibitem
786   format.authors output
787   author format.key output
788   output.year.check
789   format.title output
790   new.block
791   howpublished output
792   new.block
793   note output
794   fin.entry
795 }
796  
797 FUNCTION {phdthesis}
798 { output.bibitem
799   format.authors "author" output.check
800   author format.key output
801   output.year.check
802   format.title "title" output.check
803   new.block
804   "Ph.D. thesis" format.thesis.type output.nonnull
805   school "school" output.check
806   address output
807   new.block
808   note output
809   fin.entry
810 }
811  
812 FUNCTION {proceedings}
813 { output.bibitem
814   format.editors output
815   editor format.key output
816   output.year.check
817   format.title "title" output.check
818   format.bvolume output
819   format.number.series output
820   new.block
821   address empty$
822      'skip$
823      { address ":" * output }
824   if$
825   organization output.extra
826   publisher output
827   new.block
828   note output
829   fin.entry
830 }
831  
832 FUNCTION {techreport}
833 { output.bibitem
834   format.authors "author" output.check
835   author format.key output
836   output.year.check
837   format.title "title" output.check
838   new.block
839   format.tr.number output.nonnull
840   institution "institution" output.check
841   address output
842   new.block
843   note output
844   fin.entry
845 }
846  
847 FUNCTION {unpublished}
848 { output.bibitem
849   format.authors "author" output.check
850   author format.key output
851   output.year.check
852   format.title "title" output.check
853   new.block
854   note "note" output.check
855   fin.entry
856 }
857  
858 FUNCTION {default.type} { misc }
859
860 MACRO {jan} {"Jan."}
861
862 MACRO {feb} {"Feb."}
863
864 MACRO {mar} {"Mar."}
865
866 MACRO {apr} {"Apr,"}
867
868 MACRO {may} {"May"}
869
870 MACRO {jun} {"June"}
871
872 MACRO {jul} {"July"}
873
874 MACRO {aug} {"Aug."}
875
876 MACRO {sep} {"Sept."}
877
878 MACRO {oct} {"Oct."}
879
880 MACRO {nov} {"Nov."}
881
882 MACRO {dec} {"Dec."}
883
884 READ
885  
886 FUNCTION {sortify}
887 { purify$
888   "l" change.case$
889 }
890  
891 INTEGERS { len }
892  
893 FUNCTION {chop.word}
894 { 's :=
895   'len :=
896   s #1 len substring$ =
897     { s len #1 + global.max$ substring$ }
898     's
899   if$
900 }
901  
902 FUNCTION {format.lab.names}
903 { 's :=
904   s #1 "{vv~}{ll}" format.name$
905   s num.names$ duplicate$
906   #2 >
907     { pop$ " et~al." * }
908     { #2 <
909         'skip$
910         { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
911             { " et~al." * }
912             { " and " * s #2 "{vv~}{ll}" format.name$ * }
913           if$
914         }
915       if$
916     }
917   if$
918 }
919  
920 FUNCTION {author.key.label}
921 { author empty$
922     { key empty$
923         { cite$ #1 #3 substring$ }
924         'key
925       if$
926     }
927     { author format.lab.names }
928   if$
929 }
930  
931 FUNCTION {author.editor.key.label}
932 { author empty$
933     { editor empty$
934         { key empty$
935             { cite$ #1 #3 substring$ }
936             'key
937           if$
938         }
939         { editor format.lab.names }
940       if$
941     }
942     { author format.lab.names }
943   if$
944 }
945  
946 FUNCTION {editor.key.label}
947 { editor empty$
948     { key empty$
949         { cite$ #1 #3 substring$ }
950         'key
951       if$
952     }
953     { editor format.lab.names }
954   if$
955 }
956  
957 FUNCTION {calc.label}
958 { type$ "book" =
959   type$ "inbook" =
960   or
961     'author.editor.key.label
962     { type$ "proceedings" =
963         'editor.key.label
964         'author.key.label
965       if$
966     }
967   if$
968   "" swap$ * "}{"
969   *
970   year field.or.null purify$ #-1 #4 substring$
971   *
972   'label :=
973 }
974  
975 FUNCTION {sort.format.names}
976 { 's :=
977   #1 'nameptr :=
978   ""
979   s num.names$ 'numnames :=
980   numnames 'namesleft :=
981     { namesleft #0 > }
982     { nameptr #1 >
983         { "   " * }
984         'skip$
985       if$
986       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't :=
987       nameptr numnames = t "others" = and
988         { "et al" * }
989         { t sortify * }
990       if$
991       nameptr #1 + 'nameptr :=
992       namesleft #1 - 'namesleft :=
993     }
994   while$
995 }
996  
997 FUNCTION {sort.format.title}
998 { 't :=
999   "A " #2
1000     "An " #3
1001       "The " #4 t chop.word
1002     chop.word
1003   chop.word
1004   sortify
1005   #1 global.max$ substring$
1006 }
1007  
1008 FUNCTION {author.sort}
1009 { author empty$
1010     { key empty$
1011         { "to sort, need author or key in " cite$ * warning$
1012           ""
1013         }
1014         { key sortify }
1015       if$
1016     }
1017     { author sort.format.names }
1018   if$
1019 }
1020  
1021 FUNCTION {author.editor.sort}
1022 { author empty$
1023     { editor empty$
1024         { key empty$
1025             { "to sort, need author, editor, or key in " cite$ * warning$
1026               ""
1027             }
1028             { key sortify }
1029           if$
1030         }
1031         { editor sort.format.names }
1032       if$
1033     }
1034     { author sort.format.names }
1035   if$
1036 }
1037  
1038 FUNCTION {editor.sort}
1039 { editor empty$
1040     { key empty$
1041         { "to sort, need editor or key in " cite$ * warning$
1042           ""
1043         }
1044         { key sortify }
1045       if$
1046     }
1047     { editor sort.format.names }
1048   if$
1049 }
1050  
1051 FUNCTION {presort}
1052 { calc.label
1053   label sortify
1054   "    "
1055   *
1056   type$ "book" =
1057   type$ "inbook" =
1058   or
1059     'author.editor.sort
1060     { type$ "proceedings" =
1061         'editor.sort
1062         'author.sort
1063       if$
1064     }
1065   if$
1066   #1 entry.max$ substring$
1067   'sort.label :=
1068   sort.label
1069   *
1070   "    "
1071   *
1072   title field.or.null
1073   sort.format.title
1074   *
1075   #1 entry.max$ substring$
1076   'sort.key$ :=
1077 }
1078  
1079 ITERATE {presort}
1080  
1081 SORT            % by label, sort.label, title---for final label calculation
1082  
1083 STRINGS { last.label next.extra }
1084  
1085 INTEGERS { last.extra.num }
1086  
1087 FUNCTION {initialize.extra.label.stuff}
1088 { #0 int.to.chr$ 'last.label :=
1089   "" 'next.extra :=
1090   #0 'last.extra.num :=
1091 }
1092  
1093 FUNCTION {forward.pass}
1094 { last.label label =
1095     { last.extra.num #1 + 'last.extra.num :=
1096       last.extra.num int.to.chr$ 'extra.label :=
1097     }
1098     { "a" chr.to.int$ 'last.extra.num :=
1099       "" 'extra.label :=
1100       label 'last.label :=
1101     }
1102   if$
1103 }
1104  
1105 FUNCTION {reverse.pass}
1106 { next.extra "b" =
1107     { "a" 'extra.label := }
1108     'skip$
1109   if$
1110   label extra.label * "}" * 'label :=
1111   extra.label 'next.extra :=
1112 }
1113  
1114 EXECUTE {initialize.extra.label.stuff}
1115  
1116 ITERATE {forward.pass}
1117  
1118 REVERSE {reverse.pass}
1119  
1120 FUNCTION {bib.sort.order}
1121 { sort.label
1122   "    "
1123   *
1124   year field.or.null sortify
1125   *
1126   "    "
1127   *
1128   title field.or.null
1129   sort.format.title
1130   *
1131   #1 entry.max$ substring$
1132   'sort.key$ :=
1133 }
1134  
1135 ITERATE {bib.sort.order}
1136  
1137 SORT            % by sort.label, year, title---giving final bibliography order
1138  
1139 FUNCTION {begin.bib}
1140 { preamble$ empty$
1141     'skip$
1142     { preamble$ write$ newline$ }
1143   if$
1144   "\begin{thebibliography}{00}" write$ newline$
1145 }
1146  
1147 EXECUTE {begin.bib}
1148  
1149 EXECUTE {init.state.consts}
1150  
1151 ITERATE {call.type$}
1152  
1153 FUNCTION {end.bib}
1154 { newline$
1155   "\end{thebibliography}" write$ newline$
1156 }
1157  
1158 EXECUTE {end.bib}
1159