summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/gloss/glsplain.bst
blob: 675407b4c299c7906656b31ed87fb6554046b066 (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
% (c) 1998 Jose Luis Diaz, 1999-2002 Jose Luis Diaz and Javier Bezos.
% All Rights Reserved.
%
% This file is part of the gloss distribution release 1.5.2
% --------------------------------------------------------
%
% This file can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
%% History of v0.1
%% ~~~~~~~~~~~~~~~
%% 1997/06/25 (JLDdA) Original version, by Jose Luis Diaz de Arriba (and an
%%                    unindicted co-conspirator)
%% History of v1.0
%% ~~~~~~~~~~~~~~~
%% 1999/07/29 (JBL)   Rewritten in full. Now it warns if a required field is
%%                    missing, conforms the new gloss.sty syntax, and
%%                    writes headings for each letter. The heading,
%%                    short, and group fiels have been added.
%% History of v1.1-1.4
%% ~~~~~~~~~~~~~~~~~~~
%% 1999/10/10 (JBL)   Lots of changes.
%% History of v.1.5
%% ~~~~~~~~~~~~~~~~
%% 2001/08/02 (JBL)   Added the sort-short field for compatility 
%%                    with glsshort.bst

STRINGS { last.heading s t star.period}

ENTRY
  { word
    sort-word
    definition
    heading
    group
    short
	sort-short
  }
  {}
  { ucword }
  
FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}

FUNCTION {has.period}
{ duplicate$
  add.period$ =
}

FUNCTION {str.length}
{ 't :=
  #0
    { t empty$ not }
    { t #2 global.max$ substring$
	  't :=
	  #1 +
    }
  while$
}


FUNCTION {upper.first}
{ duplicate$
  #1 text.prefix$
  duplicate$
  "u" change.case$
  's :=
  str.length
  #1 + entry.max$ substring$
  s swap$ *
}

FUNCTION {check.required}
{ 's :=
  duplicate$ empty$
    { "Empty " s * " in " * cite$ * warning$ }
    'skip$
  if$
}

FUNCTION {field.or.null}
{ duplicate$ empty$
    { pop$ "" }
    'skip$
  if$
}

FUNCTION {push.sortword}
{ sort-word empty$ 
   { word field.or.null }
   'sort-word
  if$
}

FUNCTION {check.alpha}
{ duplicate$
  purify$
  empty$
    { "Non alphabetical " cite$ *
      " entry without group field" * warning$ }
    'skip$
  if$
}

FUNCTION {push.heading}
{ heading empty$
    { word field.or.null
      #1 text.prefix$
      check.alpha
    }
    'heading
    if$
}

FUNCTION {begin.entry}
{ newline$
  "\begin{glossitem" star.period * write$
  "}{" write$
  cite$ write$
  "}{" write$
  word write$
  "}{" write$
  ucword write$
  "}{" write$
  short field.or.null write$
  "}" write$
  newline$
}

FUNCTION {end.entry}
{ "\end{glossitem" star.period "}" * * write$
  newline$
}

FUNCTION {set.vars}
{ word field.or.null
  "word" check.required
  upper.first
  'ucword := 
}


FUNCTION {glossdef}
{ definition field.or.null
  "definition" check.required
  duplicate$ has.period
    { "*" }
	{ "" }
  if$
  'star.period :=    % definition is stored for later writing
  begin.entry        % this outputs word, ucword, and short
  write$             % writes definition
  end.entry
}

FUNCTION {gd}
{ definition field.or.null
  "definition" check.required
  duplicate$ has.period
    { "*" }
	{ "" }
  if$
  'star.period :=    % definition is stored for later
  begin.entry        % this outputs word, ucword, and short
  write$             % writes definition
  end.entry
}

FUNCTION {default.type} { glossdef }

FUNCTION {presort}
{ set.vars
  push.sortword
  group empty$
    { purify$ "L" }
    'group
  if$                    % sort-word heading
  swap$ *                % heading * sort-word
  "l" change.case$
  'sort.key$ :=
}

FUNCTION {begin.thegloss}
{ "\begin{thegloss}"   
  write$
  newline$
  preamble$ empty$
    'skip$
    { preamble$ write$ newline$ }
  if$
}

FUNCTION {end.thegloss}
{ newline$
  "\end{thegloss}" write$
  newline$
}

FUNCTION {call.entries}
  { group empty$
      'push.heading
      { heading empty$
          'skip$
          { "Ignoring heading because there is group field in "
            cite$ *
            warning$
          }
        if$
        group
      }
    if$
    "u" change.case$
    duplicate$
    group empty$
      'skip$
      { "$$$$$" * }
    if$
    duplicate$
    last.heading =
      { pop$ pop$ }
      { newline$
		'last.heading :=
        group empty$
          { "\glossheading{" }
          { "\glossgroup{" }
        if$
        swap$ * "}" *
        write$
        newline$
      }
    if$
    call.type$
  }

READ

ITERATE {presort}

SORT

EXECUTE {begin.thegloss}

ITERATE {call.entries}

EXECUTE {end.thegloss}