bibtex-ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bibtex-ruby might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/History.txt +3 -0
- data/LICENSE +621 -0
- data/Manifest +34 -0
- data/README.rdoc +152 -0
- data/Rakefile +54 -0
- data/bibtex-ruby.gemspec +36 -0
- data/examples/bib2html.rb +28 -0
- data/examples/markdown.bib +39 -0
- data/lib/bibtex.rb +51 -0
- data/lib/bibtex/bibliography.rb +175 -0
- data/lib/bibtex/bibtex.y +129 -0
- data/lib/bibtex/elements.rb +262 -0
- data/lib/bibtex/entry.rb +154 -0
- data/lib/bibtex/error.rb +37 -0
- data/lib/bibtex/lexer.rb +328 -0
- data/lib/bibtex/parser.output +578 -0
- data/lib/bibtex/parser.rb +467 -0
- data/lib/bibtex/string_replacement.rb +43 -0
- data/lib/extensions/core.rb +35 -0
- data/test/bib/00_empty.bib +0 -0
- data/test/bib/01_no_bibtex.bib +9 -0
- data/test/bib/02_string.bib +1 -0
- data/test/bib/03_string.bib +26 -0
- data/test/bib/04_string_replacement.bib +16 -0
- data/test/bib/05_comment.bib +15 -0
- data/test/bib/06_preamble.bib +12 -0
- data/test/bib/07_entry.bib +20 -0
- data/test/bib/08_decoret.bib +83 -0
- data/test/bib/09_errors.bib +67 -0
- data/test/bib/10_bibdesk.bib +47 -0
- data/test/test_bibtex.rb +58 -0
- data/test/test_comment.rb +24 -0
- data/test/test_entry.rb +35 -0
- data/test/test_preamble.rb +24 -0
- data/test/test_string.rb +77 -0
- metadata +155 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,467 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.6
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
|
9
|
+
require 'bibtex/lexer'
|
10
|
+
|
11
|
+
module BibTeX
|
12
|
+
class Parser < Racc::Parser
|
13
|
+
|
14
|
+
module_eval(<<'...end bibtex.y/module_eval...', 'bibtex.y', 89)
|
15
|
+
|
16
|
+
attr_reader :lexer
|
17
|
+
|
18
|
+
def initialize(options={})
|
19
|
+
@options = options
|
20
|
+
@options[:include] ||= [:errors]
|
21
|
+
@lexer = Lexer.new(options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse(input)
|
25
|
+
@yydebug = self.debug?
|
26
|
+
|
27
|
+
self.lexer.src = input
|
28
|
+
self.lexer.analyse
|
29
|
+
|
30
|
+
do_parse
|
31
|
+
end
|
32
|
+
|
33
|
+
def next_token
|
34
|
+
token = self.lexer.next_token
|
35
|
+
if token[0] == :ERROR
|
36
|
+
self.include_errors? ? token : next_token
|
37
|
+
else
|
38
|
+
[token[0],token[1][0]]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def debug?
|
43
|
+
@options[:debug] == true || ENV['DEBUG'] == true
|
44
|
+
end
|
45
|
+
|
46
|
+
def include_errors?
|
47
|
+
@options[:include].include?(:errors)
|
48
|
+
end
|
49
|
+
|
50
|
+
def on_error(tid, val, vstack)
|
51
|
+
#raise(ParseError, "Failed to parse BibTeX on value %s (%s) %s" % [val.inspect, token_to_str(tid) || '?', vstack.inspect])
|
52
|
+
Log.error("Failed to parse BibTeX on value %s (%s) %s" % [val.inspect, token_to_str(tid) || '?', vstack.inspect])
|
53
|
+
end
|
54
|
+
|
55
|
+
# -*- racc -*-
|
56
|
+
...end bibtex.y/module_eval...
|
57
|
+
##### State transition tables begin ###
|
58
|
+
|
59
|
+
racc_action_table = [
|
60
|
+
14, 52, 37, 32, 51, 38, 18, 32, 15, 33,
|
61
|
+
4, 16, 36, 33, 6, 4, 29, 5, 32, 6,
|
62
|
+
32, 35, 5, 27, 33, 26, 33, 26, 24, 42,
|
63
|
+
47, 40, 41, 43, 44, 22, 45, 46, 21, 20,
|
64
|
+
53, 19, 7, 44, 29, 44, 57 ]
|
65
|
+
|
66
|
+
racc_action_check = [
|
67
|
+
4, 38, 23, 38, 38, 26, 4, 46, 4, 38,
|
68
|
+
2, 4, 23, 46, 2, 0, 20, 2, 44, 0,
|
69
|
+
21, 22, 0, 18, 44, 17, 21, 37, 17, 28,
|
70
|
+
37, 27, 27, 30, 30, 16, 34, 35, 15, 14,
|
71
|
+
39, 7, 1, 49, 52, 55, 56 ]
|
72
|
+
|
73
|
+
racc_action_pointer = [
|
74
|
+
13, 42, 8, nil, -4, nil, nil, 41, nil, nil,
|
75
|
+
nil, nil, nil, nil, 31, 30, 27, 15, 15, nil,
|
76
|
+
11, 10, 11, -1, nil, nil, -2, 21, 16, nil,
|
77
|
+
20, nil, nil, nil, 23, 30, nil, 17, -7, 37,
|
78
|
+
nil, nil, nil, nil, 8, nil, -3, nil, nil, 29,
|
79
|
+
nil, nil, 39, nil, nil, 31, 33, nil ]
|
80
|
+
|
81
|
+
racc_action_default = [
|
82
|
+
-1, -34, -2, -3, -34, -6, -7, -34, -4, -5,
|
83
|
+
-8, -9, -10, -11, -34, -34, -34, -34, -34, 58,
|
84
|
+
-13, -34, -34, -34, -24, -28, -34, -34, -34, -14,
|
85
|
+
-34, -18, -20, -21, -34, -34, -22, -34, -34, -34,
|
86
|
+
-26, -27, -12, -15, -34, -16, -34, -23, -29, -31,
|
87
|
+
-30, -32, -13, -25, -19, -17, -34, -33 ]
|
88
|
+
|
89
|
+
racc_goto_table = [
|
90
|
+
28, 30, 25, 3, 1, 8, 11, 12, 13, 10,
|
91
|
+
9, 34, 54, 17, 23, 39, 2, 50, 49, nil,
|
92
|
+
nil, nil, 48, nil, nil, nil, 55, nil, nil, nil,
|
93
|
+
nil, nil, 56 ]
|
94
|
+
|
95
|
+
racc_goto_check = [
|
96
|
+
9, 10, 16, 3, 1, 3, 6, 7, 8, 5,
|
97
|
+
4, 11, 12, 13, 14, 15, 2, 17, 10, nil,
|
98
|
+
nil, nil, 16, nil, nil, nil, 10, nil, nil, nil,
|
99
|
+
nil, nil, 9 ]
|
100
|
+
|
101
|
+
racc_goto_pointer = [
|
102
|
+
nil, 4, 16, 3, 6, 5, 2, 3, 4, -20,
|
103
|
+
-20, -11, -32, 9, -3, -12, -15, -21 ]
|
104
|
+
|
105
|
+
racc_goto_default = [
|
106
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
107
|
+
nil, nil, 31, nil, nil, nil, nil, nil ]
|
108
|
+
|
109
|
+
racc_reduce_table = [
|
110
|
+
0, 0, :racc_error,
|
111
|
+
0, 18, :_reduce_1,
|
112
|
+
1, 18, :_reduce_2,
|
113
|
+
1, 19, :_reduce_3,
|
114
|
+
2, 19, :_reduce_4,
|
115
|
+
2, 20, :_reduce_5,
|
116
|
+
1, 20, :_reduce_6,
|
117
|
+
1, 20, :_reduce_7,
|
118
|
+
1, 21, :_reduce_8,
|
119
|
+
1, 21, :_reduce_9,
|
120
|
+
1, 21, :_reduce_10,
|
121
|
+
1, 21, :_reduce_11,
|
122
|
+
4, 22, :_reduce_12,
|
123
|
+
0, 26, :_reduce_13,
|
124
|
+
1, 26, :_reduce_14,
|
125
|
+
4, 24, :_reduce_15,
|
126
|
+
4, 23, :_reduce_16,
|
127
|
+
3, 28, :_reduce_17,
|
128
|
+
1, 27, :_reduce_18,
|
129
|
+
3, 27, :_reduce_19,
|
130
|
+
1, 29, :_reduce_20,
|
131
|
+
1, 29, :_reduce_21,
|
132
|
+
3, 25, :_reduce_22,
|
133
|
+
4, 25, :_reduce_23,
|
134
|
+
2, 25, :_reduce_24,
|
135
|
+
4, 30, :_reduce_25,
|
136
|
+
1, 32, :_reduce_26,
|
137
|
+
1, 32, :_reduce_27,
|
138
|
+
1, 31, :_reduce_28,
|
139
|
+
3, 31, :_reduce_29,
|
140
|
+
3, 33, :_reduce_30,
|
141
|
+
1, 34, :_reduce_31,
|
142
|
+
1, 34, :_reduce_32,
|
143
|
+
3, 34, :_reduce_33 ]
|
144
|
+
|
145
|
+
racc_reduce_n = 34
|
146
|
+
|
147
|
+
racc_shift_n = 58
|
148
|
+
|
149
|
+
racc_token_table = {
|
150
|
+
false => 0,
|
151
|
+
:error => 1,
|
152
|
+
:AT => 2,
|
153
|
+
:COMMA => 3,
|
154
|
+
:COMMENT => 4,
|
155
|
+
:CONTENT => 5,
|
156
|
+
:ERROR => 6,
|
157
|
+
:EQ => 7,
|
158
|
+
:LBRACE => 8,
|
159
|
+
:META_COMMENT => 9,
|
160
|
+
:NAME => 10,
|
161
|
+
:NUMBER => 11,
|
162
|
+
:PREAMBLE => 12,
|
163
|
+
:RBRACE => 13,
|
164
|
+
:SHARP => 14,
|
165
|
+
:STRING => 15,
|
166
|
+
:STRING_LITERAL => 16 }
|
167
|
+
|
168
|
+
racc_nt_base = 17
|
169
|
+
|
170
|
+
racc_use_result_var = true
|
171
|
+
|
172
|
+
Racc_arg = [
|
173
|
+
racc_action_table,
|
174
|
+
racc_action_check,
|
175
|
+
racc_action_default,
|
176
|
+
racc_action_pointer,
|
177
|
+
racc_goto_table,
|
178
|
+
racc_goto_check,
|
179
|
+
racc_goto_default,
|
180
|
+
racc_goto_pointer,
|
181
|
+
racc_nt_base,
|
182
|
+
racc_reduce_table,
|
183
|
+
racc_token_table,
|
184
|
+
racc_shift_n,
|
185
|
+
racc_reduce_n,
|
186
|
+
racc_use_result_var ]
|
187
|
+
|
188
|
+
Racc_token_to_s_table = [
|
189
|
+
"$end",
|
190
|
+
"error",
|
191
|
+
"AT",
|
192
|
+
"COMMA",
|
193
|
+
"COMMENT",
|
194
|
+
"CONTENT",
|
195
|
+
"ERROR",
|
196
|
+
"EQ",
|
197
|
+
"LBRACE",
|
198
|
+
"META_COMMENT",
|
199
|
+
"NAME",
|
200
|
+
"NUMBER",
|
201
|
+
"PREAMBLE",
|
202
|
+
"RBRACE",
|
203
|
+
"SHARP",
|
204
|
+
"STRING",
|
205
|
+
"STRING_LITERAL",
|
206
|
+
"$start",
|
207
|
+
"bibliography",
|
208
|
+
"objects",
|
209
|
+
"object",
|
210
|
+
"at_object",
|
211
|
+
"comment",
|
212
|
+
"string",
|
213
|
+
"preamble",
|
214
|
+
"entry",
|
215
|
+
"content",
|
216
|
+
"string_value",
|
217
|
+
"string_assignment",
|
218
|
+
"string_literal",
|
219
|
+
"entry_head",
|
220
|
+
"assignments",
|
221
|
+
"key",
|
222
|
+
"assignment",
|
223
|
+
"value" ]
|
224
|
+
|
225
|
+
Racc_debug_parser = true
|
226
|
+
|
227
|
+
##### State transition tables end #####
|
228
|
+
|
229
|
+
# reduce 0 omitted
|
230
|
+
|
231
|
+
module_eval(<<'.,.,', 'bibtex.y', 32)
|
232
|
+
def _reduce_1(val, _values, result)
|
233
|
+
result = Bibliography.new
|
234
|
+
result
|
235
|
+
end
|
236
|
+
.,.,
|
237
|
+
|
238
|
+
module_eval(<<'.,.,', 'bibtex.y', 33)
|
239
|
+
def _reduce_2(val, _values, result)
|
240
|
+
result = val[0]
|
241
|
+
result
|
242
|
+
end
|
243
|
+
.,.,
|
244
|
+
|
245
|
+
module_eval(<<'.,.,', 'bibtex.y', 35)
|
246
|
+
def _reduce_3(val, _values, result)
|
247
|
+
result = Bibliography.new << val[0]
|
248
|
+
result
|
249
|
+
end
|
250
|
+
.,.,
|
251
|
+
|
252
|
+
module_eval(<<'.,.,', 'bibtex.y', 36)
|
253
|
+
def _reduce_4(val, _values, result)
|
254
|
+
result << val[1]
|
255
|
+
result
|
256
|
+
end
|
257
|
+
.,.,
|
258
|
+
|
259
|
+
module_eval(<<'.,.,', 'bibtex.y', 38)
|
260
|
+
def _reduce_5(val, _values, result)
|
261
|
+
result = val[1]
|
262
|
+
result
|
263
|
+
end
|
264
|
+
.,.,
|
265
|
+
|
266
|
+
module_eval(<<'.,.,', 'bibtex.y', 39)
|
267
|
+
def _reduce_6(val, _values, result)
|
268
|
+
result = BibTeX::MetaComment.new(val[0])
|
269
|
+
result
|
270
|
+
end
|
271
|
+
.,.,
|
272
|
+
|
273
|
+
module_eval(<<'.,.,', 'bibtex.y', 40)
|
274
|
+
def _reduce_7(val, _values, result)
|
275
|
+
result = BibTeX::Error.new(val[0])
|
276
|
+
result
|
277
|
+
end
|
278
|
+
.,.,
|
279
|
+
|
280
|
+
module_eval(<<'.,.,', 'bibtex.y', 42)
|
281
|
+
def _reduce_8(val, _values, result)
|
282
|
+
result = val[0]
|
283
|
+
result
|
284
|
+
end
|
285
|
+
.,.,
|
286
|
+
|
287
|
+
module_eval(<<'.,.,', 'bibtex.y', 43)
|
288
|
+
def _reduce_9(val, _values, result)
|
289
|
+
result = val[0]
|
290
|
+
result
|
291
|
+
end
|
292
|
+
.,.,
|
293
|
+
|
294
|
+
module_eval(<<'.,.,', 'bibtex.y', 44)
|
295
|
+
def _reduce_10(val, _values, result)
|
296
|
+
result = val[0]
|
297
|
+
result
|
298
|
+
end
|
299
|
+
.,.,
|
300
|
+
|
301
|
+
module_eval(<<'.,.,', 'bibtex.y', 45)
|
302
|
+
def _reduce_11(val, _values, result)
|
303
|
+
result = val[0]
|
304
|
+
result
|
305
|
+
end
|
306
|
+
.,.,
|
307
|
+
|
308
|
+
module_eval(<<'.,.,', 'bibtex.y', 47)
|
309
|
+
def _reduce_12(val, _values, result)
|
310
|
+
result = BibTeX::Comment.new(val[2])
|
311
|
+
result
|
312
|
+
end
|
313
|
+
.,.,
|
314
|
+
|
315
|
+
module_eval(<<'.,.,', 'bibtex.y', 49)
|
316
|
+
def _reduce_13(val, _values, result)
|
317
|
+
result = ''
|
318
|
+
result
|
319
|
+
end
|
320
|
+
.,.,
|
321
|
+
|
322
|
+
module_eval(<<'.,.,', 'bibtex.y', 50)
|
323
|
+
def _reduce_14(val, _values, result)
|
324
|
+
result = val[0]
|
325
|
+
result
|
326
|
+
end
|
327
|
+
.,.,
|
328
|
+
|
329
|
+
module_eval(<<'.,.,', 'bibtex.y', 52)
|
330
|
+
def _reduce_15(val, _values, result)
|
331
|
+
result = BibTeX::Preamble.new(val[2])
|
332
|
+
result
|
333
|
+
end
|
334
|
+
.,.,
|
335
|
+
|
336
|
+
module_eval(<<'.,.,', 'bibtex.y', 54)
|
337
|
+
def _reduce_16(val, _values, result)
|
338
|
+
result = BibTeX::String.new(val[2][0],val[2][1]);
|
339
|
+
result
|
340
|
+
end
|
341
|
+
.,.,
|
342
|
+
|
343
|
+
module_eval(<<'.,.,', 'bibtex.y', 56)
|
344
|
+
def _reduce_17(val, _values, result)
|
345
|
+
result = [val[0].downcase.to_sym, val[2]]
|
346
|
+
result
|
347
|
+
end
|
348
|
+
.,.,
|
349
|
+
|
350
|
+
module_eval(<<'.,.,', 'bibtex.y', 58)
|
351
|
+
def _reduce_18(val, _values, result)
|
352
|
+
result = [val[0]]
|
353
|
+
result
|
354
|
+
end
|
355
|
+
.,.,
|
356
|
+
|
357
|
+
module_eval(<<'.,.,', 'bibtex.y', 59)
|
358
|
+
def _reduce_19(val, _values, result)
|
359
|
+
result << val[2]
|
360
|
+
result
|
361
|
+
end
|
362
|
+
.,.,
|
363
|
+
|
364
|
+
module_eval(<<'.,.,', 'bibtex.y', 61)
|
365
|
+
def _reduce_20(val, _values, result)
|
366
|
+
result = val[0].downcase.to_sym
|
367
|
+
result
|
368
|
+
end
|
369
|
+
.,.,
|
370
|
+
|
371
|
+
module_eval(<<'.,.,', 'bibtex.y', 62)
|
372
|
+
def _reduce_21(val, _values, result)
|
373
|
+
result = val[0]
|
374
|
+
result
|
375
|
+
end
|
376
|
+
.,.,
|
377
|
+
|
378
|
+
module_eval(<<'.,.,', 'bibtex.y', 64)
|
379
|
+
def _reduce_22(val, _values, result)
|
380
|
+
result = val[0] << val[1]
|
381
|
+
result
|
382
|
+
end
|
383
|
+
.,.,
|
384
|
+
|
385
|
+
module_eval(<<'.,.,', 'bibtex.y', 65)
|
386
|
+
def _reduce_23(val, _values, result)
|
387
|
+
result = val[0] << val[1]
|
388
|
+
result
|
389
|
+
end
|
390
|
+
.,.,
|
391
|
+
|
392
|
+
module_eval(<<'.,.,', 'bibtex.y', 66)
|
393
|
+
def _reduce_24(val, _values, result)
|
394
|
+
result = val[0]
|
395
|
+
result
|
396
|
+
end
|
397
|
+
.,.,
|
398
|
+
|
399
|
+
module_eval(<<'.,.,', 'bibtex.y', 68)
|
400
|
+
def _reduce_25(val, _values, result)
|
401
|
+
result = BibTeX::Entry.new(val[0].downcase.to_sym,val[2])
|
402
|
+
result
|
403
|
+
end
|
404
|
+
.,.,
|
405
|
+
|
406
|
+
module_eval(<<'.,.,', 'bibtex.y', 70)
|
407
|
+
def _reduce_26(val, _values, result)
|
408
|
+
result = val[0]
|
409
|
+
result
|
410
|
+
end
|
411
|
+
.,.,
|
412
|
+
|
413
|
+
module_eval(<<'.,.,', 'bibtex.y', 71)
|
414
|
+
def _reduce_27(val, _values, result)
|
415
|
+
result = val[0]
|
416
|
+
result
|
417
|
+
end
|
418
|
+
.,.,
|
419
|
+
|
420
|
+
module_eval(<<'.,.,', 'bibtex.y', 73)
|
421
|
+
def _reduce_28(val, _values, result)
|
422
|
+
result = val[0]
|
423
|
+
result
|
424
|
+
end
|
425
|
+
.,.,
|
426
|
+
|
427
|
+
module_eval(<<'.,.,', 'bibtex.y', 74)
|
428
|
+
def _reduce_29(val, _values, result)
|
429
|
+
result.merge!(val[2])
|
430
|
+
result
|
431
|
+
end
|
432
|
+
.,.,
|
433
|
+
|
434
|
+
module_eval(<<'.,.,', 'bibtex.y', 76)
|
435
|
+
def _reduce_30(val, _values, result)
|
436
|
+
result = { val[0].downcase.to_sym => val[2] }
|
437
|
+
result
|
438
|
+
end
|
439
|
+
.,.,
|
440
|
+
|
441
|
+
module_eval(<<'.,.,', 'bibtex.y', 78)
|
442
|
+
def _reduce_31(val, _values, result)
|
443
|
+
result = val[0]
|
444
|
+
result
|
445
|
+
end
|
446
|
+
.,.,
|
447
|
+
|
448
|
+
module_eval(<<'.,.,', 'bibtex.y', 79)
|
449
|
+
def _reduce_32(val, _values, result)
|
450
|
+
result = val[0]
|
451
|
+
result
|
452
|
+
end
|
453
|
+
.,.,
|
454
|
+
|
455
|
+
module_eval(<<'.,.,', 'bibtex.y', 80)
|
456
|
+
def _reduce_33(val, _values, result)
|
457
|
+
result = val[1]
|
458
|
+
result
|
459
|
+
end
|
460
|
+
.,.,
|
461
|
+
|
462
|
+
def _reduce_none(val, _values, result)
|
463
|
+
val[0]
|
464
|
+
end
|
465
|
+
|
466
|
+
end # class Parser
|
467
|
+
end # module BibTeX
|