summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/refer-tools/refer.bst
blob: 8b7fe4b634b5563a9252624cf23294f0df1b4bcf (plain)
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
%From @mitvma.mit.edu:cjmchale@cs.tcd.ie Mon Jul  2 19:48:31 1990
%Return-Path: <@mitvma.mit.edu:cjmchale@cs.tcd.ie>
%Received: from mitvma.mit.edu by life.ai.mit.edu (4.1/AI-4.10) id AA07748; Mon, 2 Jul 90 19:48:24 EDT
%Received: from MITVMA.MIT.EDU by mitvma.mit.edu (IBM VM SMTP R1.2.1MX) with BSMTP id 4555; Mon, 02 Jul 90 19:47:32 EDT
%Received: from IRLEARN.UCD.IE by MITVMA.MIT.EDU (Mailer R2.05) with BSMTP id
% 0199; Mon, 02 Jul 90 19:47:23 EDT
%Received: from ccvax.ucd.ie by IRLEARN.UCD.IE (Mailer R2.03B) with BSMTP id
% 2688; Mon, 02 Jul 90 14:45:10 GMT
%Received: from cs.tcd.ie by ccvax.ucd.ie; Mon, 2 Jul 90 14:38 GMT
%Received: from csaran.cs.tcd.ie by cs.tcd.ie; Mon, 2 Jul 90 14:42 GMT
%Date: Mon, 2 Jul 90 14:39:44 BST
%From: cjmchale%cs.tcd.ie@mitvma.mit.edu
%Subject: Re: BibTex <-> Tib/Refer converter wanted
%Sender: cjmchale%cs.tcd.ie@mitvma.mit.edu
%To: tmb@wheaties.ai.mit.edu
%Newsgroups: comp.text.tex,comp.text
%In-Reply-To: <9290@life.ai.mit.edu>
%Organization: DSG, Dept. of Comp.Sc., Trinity College, Dublin, Ireland.
%Message-Id:  <9007021439.aa02454@csaran.cs.tcd.ie>
%Status: R
%
%In article <9290@life.ai.mit.edu> you write:
%>I am looking for a converter to convert BibTex bibliography files
%>to Tib/Refer files and vice versa. Even if you have just a
%>shell script that isn't completely general, that would be fine.
%>
%>                                       Thanks, Thomas.
%>
%>PS: thanks to everyone who responded to my question about refer-style
%>bibliography processors. The answer was to get Tib from ENEEVAX.UMD.EDU.
%
%You may not be aware of this but BibTeX is actually a (special
%purpose) programming language! The source code file for a BibTeX
%program is the bibliography style file (".bst"). BibTeX reads in the
%bibtex entries and the code in the ".bst" file munges them about and
%usually writes LaTeX code out. However, if you learn how to program
%BibTeX (as the local guru for its manual---it's only about 10 or 20
%pages long) then you could write your own custom ".bst" files that
%will do exactly what you want them to. In particular, instead of
%writing out LaTeX style code it could write out "Hello World" or even
%generate a file that looks quite like a refer style file.
%
%It would be difficult to get such a ".bst" file to convert TeX
%commands (which might be imbedded in the bib entries) to refer
%commands but the actual changing of "author=..." to %A ... is trivial
%(for the most part; there are a few mismatches between the fields that
%BibTeX and refer use).
%
%Anyway, I've written such a ".bst" file and a UNIX "sh" shell script
%to automate the process. I've included them below.
%
%------------------- Start of file "refer.bst" ---------------------
%
% 8/4/'90
% Hacked together by Ciaran McHale (cjmchale@cs.tcd.ie) to translate
% BibTeX bibliographies into refer format
% Based on a bib style file by Kannan Varadhan
%


ENTRY
  {                                     % entry fields
        abstract                % non standard
    address
        annote                  % non standard
    author
    booktitle
    chapter
    edition
    editor
    howpublished
    institution
    journal
    key
        keywords                % non standard
    month
    note
    number
    organization
    pages
    publisher
    school
    series
    title
    type
    volume
    year
  }
  {}                                    % no integer entry variables
  { label extra.label sort.label }      % label entry variables


STRINGS { s t a.name }


FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}

FUNCTION {and}
{   'skip$
    { pop$ #0 }
  if$
}

FUNCTION {or}
{   { pop$ #1 }
    'skip$
  if$
}

INTEGERS { nameptr namesleft numnames }

FUNCTION {handle.names}
{ 't :=         % type e.g. "A" for authors, "E" for editors
  's :=         % the string containing the names
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }

    { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 'a.name :=

      a.name "others" =
        'skip$  % don't print out "%A others"
        { "%" t * " " * a.name * write$ newline$ }
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}



MACRO {jan} {"January"}

MACRO {feb} {"February"}

MACRO {mar} {"March"}

MACRO {apr} {"April"}

MACRO {may} {"May"}

MACRO {jun} {"June"}

MACRO {jul} {"July"}

MACRO {aug} {"August"}

MACRO {sep} {"September"}

MACRO {oct} {"October"}

MACRO {nov} {"November"}

MACRO {dec} {"December"}






MACRO {acmcs} {"ACM Computing Surveys"}

MACRO {acta} {"Acta Informatica"}

MACRO {cacm} {"Communications of the ACM"}

MACRO {ibmjrd} {"IBM Journal of Research and Development"}

MACRO {ibmsj} {"IBM Systems Journal"}

MACRO {ieeese} {"IEEE Transactions on Software Engineering"}

MACRO {ieeetc} {"IEEE Transactions on Computers"}

MACRO {ieeetcad}
 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}

MACRO {ipl} {"Information Processing Letters"}

MACRO {jacm} {"Journal of the ACM"}

MACRO {jcss} {"Journal of Computer and System Sciences"}

MACRO {scp} {"Science of Computer Programming"}

MACRO {sicomp} {"SIAM Journal on Computing"}

MACRO {tocs} {"ACM Transactions on Computer Systems"}

MACRO {tods} {"ACM Transactions on Database Systems"}

MACRO {tog} {"ACM Transactions on Graphics"}

MACRO {toms} {"ACM Transactions on Mathematical Software"}

MACRO {toois} {"ACM Transactions on Office Information Systems"}

MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}

MACRO {tcs} {"Theoretical Computer Science"}





STRINGS { is.digit.tmp }

FUNCTION {is.digit}

{
  'is.digit.tmp :=
  is.digit.tmp "0" =
  is.digit.tmp "1" = or
  is.digit.tmp "2" = or
  is.digit.tmp "3" = or
  is.digit.tmp "4" = or
  is.digit.tmp "5" = or
  is.digit.tmp "6" = or
  is.digit.tmp "7" = or
  is.digit.tmp "8" = or
  is.digit.tmp "9" = or
}

FUNCTION {handle.maybe.empty}
{
  't :=
  duplicate$
  empty$
    'pop$
    { "%" t * " " * swap$ * write$ newline$ }
  if$
}

FUNCTION {translate}
{
  newline$      % get a blank line between each entry

  title "T" handle.maybe.empty
  booktitle "B" handle.maybe.empty

  % there may be multiple authors so handle it differently
  author empty$
    { " empty author in " cite$ * warning$ }
    { author "A" handle.names }
  if$
  editor "E" handle.maybe.empty
  journal "J" handle.maybe.empty
  keywords "K" handle.maybe.empty
  cite$ "L" handle.maybe.empty
  volume "V" handle.maybe.empty
  abstract "X" handle.maybe.empty

  % The date, if present may be just the year or both the month and year
  % or might even be just the month
  month empty$ year empty$ and
    'skip$      % no date of publication so nothing to do
    {
      month empty$      % I'm using the if statement because I'm not
        { "" }          % sure that--- month " " year * --- would work.
        { month " " * } % (The manual doesn't mention anything about
      if$               % this so I'm playing safe)
      year empty$
        { "" }
        { year }
      if$
      *
      "D" handle.maybe.empty
    }
  if$
  pages "P" handle.maybe.empty
  note "O" handle.maybe.empty
  number "N" handle.maybe.empty
  series "S" handle.maybe.empty
  annote "Y" handle.maybe.empty
  address "C" handle.maybe.empty

}


FUNCTION {article} { translate }
FUNCTION {book} { translate }
FUNCTION {booklet} { translate }
FUNCTION {inbook} { translate }
FUNCTION {incollection} { translate }
FUNCTION {inproceedings} { translate }
FUNCTION {manual} { translate }
FUNCTION {mastersthesis} { translate }
FUNCTION {misc} { translate }
FUNCTION {phdthesis} { translate }
FUNCTION {proceedings} { translate }
FUNCTION {techreport} { translate }
FUNCTION {unpublished} { translate }
FUNCTION {default.type} { translate }


READ

ITERATE {call.type$}
------------------- End of file "refer.bst" ---------------------

------------------- Start of file "bib2refer" ---------------------
#! /bin/sh
# Written by Ciaran McHale (cjmchale@cs.tcd.ie) 8/4/'90

FN=`basename $0`

case $# in
0)      echo "Usage: $FN <filename> [<filename>*]" ; exit 1 ;;
esac

#
# This shell script uses bibtex and a custom made bibliography style file
# to translate BibTeX bibliographies into refer format. It is based on
# another shell script written by Eamonn McManus, Alan Judge and Ciaran McHale.
#
STYLE=refer     # BibTeX-to-refer style file

FILE=tmp
RESULT=${FN}.out
BIBFILE=${FILE}.bib

# clean up if interrupted
trap 'rm ${FILE}.bbl ${FILE}.aux ${FILE}.blg ; exit 1' 1 2 3 15

> ${FILE}.bbl           # truncate the files
> ${FILE}.aux
> ${FILE}.blg

#
#Hand craft the .aux file
#
BIBRECD=""
for i
do
        file="`echo $i | sed 's/.bib//'`"
        BIBRECD="${BIBRECD},${file}"
done
BIBRECD="`echo $BIBRECD | sed 's/^,//'`"        # remove 1st " "

echo "\bibstyle{$STYLE}"        >> ${FILE}.aux
echo "\bibdata{$BIBRECD}"       >> ${FILE}.aux

# Read all the files (command line arguments) and use them to write
# the necessary info into the .aux file.
for i
do
        file="`echo $i | sed 's/.bib//'`"
        bibfile=${file}.bib
        echo FILE $bibfile has `egrep '^@' $bibfile | wc -l` records
        # create the .aux file with \citation commands in it
        sed -n 's/^@.*[{(][     ]*\(.*\)/\\citation {\1}/p' $bibfile  |
                sed 's/[,       ]//g' >>${FILE}.aux

done

bibtex $FILE
cp ${FILE}.bbl ${RESULT}

echo; echo ${FN}: output in ${RESULT}; echo

# Cleanup...
rm ${FILE}.bbl ${FILE}.aux ${FILE}.blg

exit 0
------------------- End of file "bib2refer" ---------------------


This was written as a quick hack and I haven't tested it thoroughly so
if you see any problems then be prepared to get out the BibTeX
programming manual and change a line or two (hopefully that won't be
necessary).


Ciaran.
--
Ciaran McHale
Department of Computer Science, Trinity College, Dublin 2, Ireland.
Telephone: +353-1-772941 ext 1538    FAX: +353-1-772204   Telex: 93782 TCD EI
email: cjmchale@cs.tcd.ie       or      cjmchale%cs.tcd.ie@cunyvm.cuny.edu
        My opinions and bad language do not represent Trinity