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