bibtex-ruby 4.0.16 → 4.1.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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6763b2b25cc0a95b714e3878ce24cd2fccdab8de
4
- data.tar.gz: d2118d74180e0cddb911a4e8e5f4e34292462098
3
+ metadata.gz: 8783657ade7bf716dc5e8e8efc22cc953e65ceca
4
+ data.tar.gz: 27870297854e15bb45f12055bcc7a09be62eba11
5
5
  SHA512:
6
- metadata.gz: 07cc756523db9c07be8262b955705e2fe95a136694be08c076393c8607da9a3df67afde0828421dcc06bc20e93b4a38e6713d44d746d8c4a66cfd9022e5791a6
7
- data.tar.gz: e6fa9083cadcfbc7e2f1c919e18385b8f061c6e2576a9307066bf591fd4fee7ab34816766eada8de9e8c59f67b5245de025f3ea0720ff98e23ae3f2812940d50
6
+ metadata.gz: f43096cd39d610a93af92eba33c2e61f4c4e869cb95b83d6477dc980d74e380b0b3fadf126647691d731d653457db36974c03c88afc74b236d7d5204016a14bd
7
+ data.tar.gz: dc0570d2c762ab894efcd3700cf730c5a6fde3dc43dfca13ec9eb0915c435e26ce926e3950a7f81c9cb5eb92d7079bae7a9f2f2c4b7e64fe43da91bd10f7c835
@@ -84,4 +84,3 @@ Feature: BibTeX Names
84
84
  | {Barnes and} {Noble, Inc.} | {Barnes and} | | {Noble, Inc.} | |
85
85
  | {Barnes} {and} {Noble,} {Inc.} | {Barnes} {and} {Noble,} | | {Inc.} | |
86
86
  | Charles Louis Xavier Joseph de la Vallee Poussin | Charles Louis Xavier Joseph | de la | Vallee Poussin | |
87
-
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.11
3
+ # This file is automatically generated by Racc 1.4.14
4
4
  # from Racc grammer file "".
5
5
  #
6
6
 
@@ -11,19 +11,20 @@ require 'strscan'
11
11
  module BibTeX
12
12
  class NameParser < Racc::Parser
13
13
 
14
- module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
14
+ module_eval(<<'...end names.y/module_eval...', 'names.y', 116)
15
15
 
16
16
  @patterns = {
17
17
  :and => /,?\s+and\s+/io,
18
18
  :space => /\s+/o,
19
19
  :comma => /,/o,
20
- :lower => /[[:lower:]][^\s\{\}\d\\,]*/o,
21
- :upper => /[[:upper:]][^\s\{\}\d\\,]*/uo,
22
- :symbols => /(\d|\\.)+/o,
20
+ :lower => /[[:lower:]][[:lower:][:upper:]]*/uo,
21
+ :upper => /[[:upper:]][[:lower:][:upper:].]*/uo,
22
+ :other => /[^\s,\{\}\\[:upper:][:lower:]]+/uo,
23
23
  :lbrace => /\{/o,
24
24
  :rbrace => /\}/o,
25
- :period => /./o,
26
- :braces => /[\{\}]/o
25
+ :braces => /[\{\}]/o,
26
+ :escape => /\\./o,
27
+ :last_first => /[\p{Han}\p{Hiragana}\p{Katakana}\p{Hangul}]/uo
27
28
  }
28
29
 
29
30
  class << self
@@ -55,7 +56,8 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
55
56
  def scan(input)
56
57
  @src = StringScanner.new(input)
57
58
  @brace_level = 0
58
- @stack = []
59
+ @last_and = 0
60
+ @stack = [[:ANDFL,'(^start)']]
59
61
  @word = [:PWORD,'']
60
62
  do_scan
61
63
  end
@@ -67,9 +69,10 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
67
69
  case
68
70
  when @src.scan(NameParser.patterns[:and])
69
71
  push_word
70
- @stack.push([:AND,@src.matched])
72
+ @last_and = @stack.length
73
+ @stack.push([:ANDFL,@src.matched])
71
74
 
72
- when @src.scan(NameParser.patterns[:space])
75
+ when @src.skip(NameParser.patterns[:space])
73
76
  push_word
74
77
 
75
78
  when @src.scan(NameParser.patterns[:comma])
@@ -84,7 +87,8 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
84
87
  is_uppercase
85
88
  @word[1] << @src.matched
86
89
 
87
- when @src.scan(NameParser.patterns[:symbols])
90
+ when @src.scan(NameParser.patterns[:other])
91
+ check_name_order
88
92
  @word[1] << @src.matched
89
93
 
90
94
  when @src.scan(NameParser.patterns[:lbrace])
@@ -94,8 +98,11 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
94
98
  when @src.scan(NameParser.patterns[:rbrace])
95
99
  error_unbalanced
96
100
 
97
- when @src.scan(NameParser.patterns[:period])
101
+ when @src.scan(NameParser.patterns[:escape])
98
102
  @word[1] << @src.matched
103
+
104
+ else
105
+ error_invalid
99
106
  end
100
107
  end
101
108
 
@@ -118,6 +125,11 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
118
125
  @word[0] = :UWORD if @word[0] == :PWORD
119
126
  end
120
127
 
128
+ def check_name_order
129
+ return if RUBY_VERSION < '1.9'
130
+ @stack[@last_and][0] = :ANDLF if @stack[@last_and][0] != :ANDLF && @src.matched =~ NameParser.patterns[:last_first]
131
+ end
132
+
121
133
  def scan_literal
122
134
  @brace_level = 1
123
135
 
@@ -146,95 +158,120 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 94)
146
158
  BibTeX.log.warn("NameParser: unbalanced braces at position #{@src.pos}; brace level #{@brace_level}.")
147
159
  end
148
160
 
161
+ def error_invalid
162
+ @stack.push [:ERROR,@src.getch]
163
+ BibTeX.log.warn("NameParser: invalid character at position #{@src.pos}; brace level #{@brace_level}.")
164
+ end
165
+
149
166
  # -*- racc -*-
150
167
  ...end names.y/module_eval...
151
168
  ##### State transition tables begin ###
152
169
 
153
170
  racc_action_table = [
154
- -15, -27, -15, -29, 27, -28, -15, -27, -27, -29,
155
- -15, -28, 36, 24, -27, 34, 33, 35, 21, 19,
156
- 22, 10, 16, 11, 34, 33, 35, 34, 33, 35,
157
- 10, 8, 11, 21, 28, 22, 34, 33, 35, 34,
158
- 33, 35, 10, 8, 11, 21, 19, 22, 38, 23,
159
- 13, 12 ]
171
+ -37, 6, -25, -38, 26, -39, -37, -37, 34, -38,
172
+ -38, -39, -39, -22, 42, -25, -37, 4, 5, -22,
173
+ -22, -24, -37, -37, -22, 42, -25, -24, -24, -24,
174
+ -22, -22, 16, 14, 17, -24, -24, -26, 24, 40,
175
+ 25, -26, 24, 51, 25, 24, 23, 25, 16, 29,
176
+ 17, 24, 32, 25, 24, 37, 25, 24, 32, 25,
177
+ -20, -20, -20, 24, 43, 25, 49, 48, 50, 24,
178
+ 37, 25, 49, 48, 50, 49, 48, 50, 49, 48,
179
+ 50, 49, 48, 50, 4, 5, 54, 56, 54 ]
160
180
 
161
181
  racc_action_check = [
162
- 19, 16, 19, 11, 18, 10, 19, 16, 8, 11,
163
- 8, 10, 26, 12, 8, 32, 32, 32, 6, 6,
164
- 6, 5, 5, 5, 36, 36, 36, 27, 27, 27,
165
- 13, 13, 13, 20, 20, 20, 38, 38, 38, 23,
166
- 23, 23, 0, 0, 0, 15, 15, 15, 30, 7,
167
- 2, 1 ]
182
+ 14, 1, 14, 16, 6, 17, 14, 14, 13, 16,
183
+ 16, 17, 17, 23, 31, 23, 29, 0, 0, 23,
184
+ 23, 40, 29, 29, 37, 36, 37, 40, 40, 51,
185
+ 37, 37, 4, 4, 4, 51, 51, 21, 21, 21,
186
+ 21, 38, 38, 38, 38, 5, 5, 5, 10, 10,
187
+ 10, 11, 11, 11, 20, 20, 20, 28, 28, 28,
188
+ 32, 32, 32, 33, 33, 33, 34, 34, 34, 39,
189
+ 39, 39, 42, 42, 42, 47, 47, 47, 54, 54,
190
+ 54, 56, 56, 56, 2, 2, 41, 45, 53 ]
168
191
 
169
192
  racc_action_pointer = [
170
- 39, 51, 44, nil, nil, 18, 15, 47, 8, nil,
171
- 5, 3, 13, 27, nil, 42, 1, nil, 2, 0,
172
- 30, nil, nil, 36, nil, nil, 10, 24, nil, nil,
173
- 46, nil, 12, nil, nil, nil, 21, nil, 33, nil,
174
- nil, nil ]
193
+ 11, 1, 78, nil, 29, 42, 4, nil, nil, nil,
194
+ 45, 48, nil, 6, 0, nil, 3, 5, nil, nil,
195
+ 51, 35, nil, 13, nil, nil, nil, nil, 54, 16,
196
+ nil, 12, 57, 60, 63, nil, 23, 24, 39, 66,
197
+ 21, 84, 69, nil, nil, 85, nil, 72, nil, nil,
198
+ nil, 29, nil, 86, 75, nil, 78, nil, nil, nil ]
175
199
 
176
200
  racc_action_default = [
177
- -1, -30, -2, -3, -5, -16, -30, -30, -12, -19,
178
- -21, -22, -30, -30, -6, -30, -12, -20, -8, -13,
179
- -16, -21, -22, -25, 42, -4, -7, -25, -14, -9,
180
- -17, -23, -26, -27, -28, -29, -25, -10, -25, -24,
181
- -11, -18 ]
201
+ -1, -40, -2, -3, -40, -40, -40, -4, -5, -7,
202
+ -26, -40, -11, -40, -19, -29, -31, -32, -6, -12,
203
+ -40, -23, -15, -19, -31, -32, 60, -8, -40, -19,
204
+ -30, -10, -25, -26, -35, -13, -40, -20, -23, -40,
205
+ -19, -9, -35, -21, -16, -27, -33, -36, -37, -38,
206
+ -39, -21, -14, -40, -35, -17, -35, -34, -18, -28 ]
182
207
 
183
208
  racc_goto_table = [
184
- 4, 17, 3, 20, 29, 14, 15, 2, 37, 18,
185
- 41, 1, 20, 4, nil, 25, 17, 40, 26, nil,
186
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
187
- nil, nil, 39 ]
209
+ 9, 10, 21, 19, 31, 30, 27, 44, 11, 20,
210
+ 3, 1, 7, 36, 28, 55, 30, 38, 35, 12,
211
+ 22, 41, 2, 8, 18, 39, 59, 58, 30, nil,
212
+ nil, nil, 53, 30, nil, nil, 38, 52, nil, nil,
213
+ nil, nil, nil, 57 ]
188
214
 
189
215
  racc_goto_check = [
190
- 4, 10, 3, 5, 8, 4, 6, 2, 8, 7,
191
- 9, 1, 5, 4, nil, 3, 10, 8, 7, nil,
192
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
193
- nil, nil, 4 ]
216
+ 6, 7, 7, 11, 9, 14, 6, 12, 8, 8,
217
+ 3, 1, 3, 9, 8, 12, 14, 7, 11, 10,
218
+ 10, 9, 2, 4, 5, 8, 13, 12, 14, nil,
219
+ nil, nil, 9, 14, nil, nil, 7, 11, nil, nil,
220
+ nil, nil, nil, 6 ]
194
221
 
195
222
  racc_goto_pointer = [
196
- nil, 11, 7, 2, 0, -3, 1, 3, -19, -28,
197
- -4, nil ]
223
+ nil, 11, 22, 10, 19, 19, -4, -3, 4, -7,
224
+ 15, -2, -27, -30, -5, nil ]
198
225
 
199
226
  racc_goto_default = [
200
- nil, nil, nil, nil, 31, 5, 6, 7, nil, 30,
201
- 9, 32 ]
227
+ nil, nil, nil, nil, nil, nil, 46, 33, nil, 13,
228
+ nil, nil, nil, 45, 15, 47 ]
202
229
 
203
230
  racc_reduce_table = [
204
231
  0, 0, :racc_error,
205
- 0, 9, :_reduce_1,
206
- 1, 9, :_reduce_none,
207
- 1, 10, :_reduce_3,
208
- 3, 10, :_reduce_4,
209
- 1, 11, :_reduce_5,
210
- 2, 11, :_reduce_6,
211
- 3, 11, :_reduce_7,
212
- 2, 11, :_reduce_8,
213
- 3, 11, :_reduce_9,
214
- 4, 11, :_reduce_10,
215
- 5, 11, :_reduce_11,
216
- 1, 14, :_reduce_none,
232
+ 0, 10, :_reduce_1,
233
+ 1, 10, :_reduce_none,
234
+ 1, 11, :_reduce_3,
235
+ 2, 11, :_reduce_4,
236
+ 2, 12, :_reduce_5,
237
+ 2, 12, :_reduce_6,
238
+ 1, 13, :_reduce_7,
239
+ 2, 13, :_reduce_8,
240
+ 3, 13, :_reduce_9,
241
+ 2, 13, :_reduce_10,
242
+ 1, 13, :_reduce_none,
243
+ 1, 14, :_reduce_12,
217
244
  2, 14, :_reduce_13,
218
245
  3, 14, :_reduce_14,
246
+ 1, 14, :_reduce_none,
247
+ 3, 19, :_reduce_16,
248
+ 4, 19, :_reduce_17,
249
+ 5, 19, :_reduce_18,
250
+ 1, 17, :_reduce_none,
251
+ 2, 17, :_reduce_20,
252
+ 3, 17, :_reduce_21,
253
+ 1, 20, :_reduce_22,
254
+ 1, 20, :_reduce_23,
255
+ 2, 20, :_reduce_24,
256
+ 1, 18, :_reduce_none,
257
+ 1, 18, :_reduce_26,
258
+ 1, 21, :_reduce_27,
259
+ 3, 21, :_reduce_28,
260
+ 1, 16, :_reduce_29,
261
+ 2, 16, :_reduce_30,
262
+ 1, 23, :_reduce_none,
263
+ 1, 23, :_reduce_none,
264
+ 1, 24, :_reduce_none,
265
+ 2, 24, :_reduce_34,
266
+ 0, 22, :_reduce_none,
267
+ 1, 22, :_reduce_none,
219
268
  1, 15, :_reduce_none,
220
269
  1, 15, :_reduce_none,
221
- 1, 16, :_reduce_17,
222
- 3, 16, :_reduce_18,
223
- 1, 13, :_reduce_none,
224
- 2, 13, :_reduce_20,
225
- 1, 18, :_reduce_none,
226
- 1, 18, :_reduce_none,
227
- 1, 19, :_reduce_none,
228
- 2, 19, :_reduce_24,
229
- 0, 17, :_reduce_none,
230
- 1, 17, :_reduce_none,
231
- 1, 12, :_reduce_none,
232
- 1, 12, :_reduce_none,
233
- 1, 12, :_reduce_none ]
270
+ 1, 15, :_reduce_none ]
234
271
 
235
- racc_reduce_n = 30
272
+ racc_reduce_n = 40
236
273
 
237
- racc_shift_n = 42
274
+ racc_shift_n = 60
238
275
 
239
276
  racc_token_table = {
240
277
  false => 0,
@@ -243,10 +280,11 @@ racc_token_table = {
243
280
  :UWORD => 3,
244
281
  :LWORD => 4,
245
282
  :PWORD => 5,
246
- :AND => 6,
247
- :ERROR => 7 }
283
+ :ANDFL => 6,
284
+ :ANDLF => 7,
285
+ :ERROR => 8 }
248
286
 
249
- racc_nt_base = 8
287
+ racc_nt_base = 9
250
288
 
251
289
  racc_use_result_var = true
252
290
 
@@ -273,16 +311,21 @@ Racc_token_to_s_table = [
273
311
  "UWORD",
274
312
  "LWORD",
275
313
  "PWORD",
276
- "AND",
314
+ "ANDFL",
315
+ "ANDLF",
277
316
  "ERROR",
278
317
  "$start",
279
318
  "result",
280
319
  "names",
281
320
  "name",
321
+ "flname",
322
+ "lfname",
282
323
  "word",
283
324
  "u_words",
284
325
  "von",
285
326
  "last",
327
+ "comma",
328
+ "lastfirst",
286
329
  "first",
287
330
  "opt_words",
288
331
  "u_word",
@@ -296,7 +339,7 @@ Racc_debug_parser = false
296
339
 
297
340
  module_eval(<<'.,.,', 'names.y', 31)
298
341
  def _reduce_1(val, _values, result)
299
- result = []
342
+ result = []
300
343
  result
301
344
  end
302
345
  .,.,
@@ -305,139 +348,212 @@ module_eval(<<'.,.,', 'names.y', 31)
305
348
 
306
349
  module_eval(<<'.,.,', 'names.y', 33)
307
350
  def _reduce_3(val, _values, result)
308
- result = [val[0]]
351
+ result = [val[0]]
309
352
  result
310
353
  end
311
354
  .,.,
312
355
 
313
356
  module_eval(<<'.,.,', 'names.y', 34)
314
357
  def _reduce_4(val, _values, result)
315
- result << val[2]
358
+ result << val[1]
316
359
  result
317
360
  end
318
361
  .,.,
319
362
 
320
- module_eval(<<'.,.,', 'names.y', 38)
363
+ module_eval(<<'.,.,', 'names.y', 36)
321
364
  def _reduce_5(val, _values, result)
322
- result = Name.new(:last => val[0])
323
-
365
+ result = Name.new(val[1])
324
366
  result
325
367
  end
326
368
  .,.,
327
369
 
328
- module_eval(<<'.,.,', 'names.y', 42)
370
+ module_eval(<<'.,.,', 'names.y', 37)
329
371
  def _reduce_6(val, _values, result)
330
- result = Name.new(:first => val[0], :last => val[1])
331
-
372
+ result = Name.new(val[1])
332
373
  result
333
374
  end
334
375
  .,.,
335
376
 
336
- module_eval(<<'.,.,', 'names.y', 46)
377
+ module_eval(<<'.,.,', 'names.y', 41)
337
378
  def _reduce_7(val, _values, result)
338
- result = Name.new(:first => val[0], :von => val[1], :last => val[2])
339
-
379
+ result = { :last => val[0] }
380
+
340
381
  result
341
382
  end
342
383
  .,.,
343
384
 
344
- module_eval(<<'.,.,', 'names.y', 50)
385
+ module_eval(<<'.,.,', 'names.y', 45)
345
386
  def _reduce_8(val, _values, result)
346
- result = Name.new(:von => val[0], :last => val[1])
347
-
387
+ result = { :first => val[0].join(' '), :last => val[1] }
388
+
348
389
  result
349
390
  end
350
391
  .,.,
351
392
 
352
- module_eval(<<'.,.,', 'names.y', 54)
393
+ module_eval(<<'.,.,', 'names.y', 49)
353
394
  def _reduce_9(val, _values, result)
354
- result = Name.new(:last => val[0], :jr => val[2][0], :first => val[2][1])
355
-
395
+ result = { :first => val[0].join(' '), :von => val[1], :last => val[2] }
396
+
356
397
  result
357
398
  end
358
399
  .,.,
359
400
 
360
- module_eval(<<'.,.,', 'names.y', 58)
401
+ module_eval(<<'.,.,', 'names.y', 53)
361
402
  def _reduce_10(val, _values, result)
362
- result = Name.new(:von => val[0], :last => val[1], :jr => val[3][0], :first => val[3][1])
363
-
403
+ result = { :von => val[0], :last => val[1] }
404
+
364
405
  result
365
406
  end
366
407
  .,.,
367
408
 
368
- module_eval(<<'.,.,', 'names.y', 62)
369
- def _reduce_11(val, _values, result)
370
- result = Name.new(:von => val[0,2].join(' '), :last => val[2], :jr => val[4][0], :first => val[4][1])
409
+ # reduce 11 omitted
371
410
 
411
+ module_eval(<<'.,.,', 'names.y', 59)
412
+ def _reduce_12(val, _values, result)
413
+ result = { :last => val[0][0], :first => val[0][1] }
414
+
372
415
  result
373
416
  end
374
417
  .,.,
375
418
 
376
- # reduce 12 omitted
377
-
378
- module_eval(<<'.,.,', 'names.y', 67)
419
+ module_eval(<<'.,.,', 'names.y', 63)
379
420
  def _reduce_13(val, _values, result)
380
- result = val.join(' ')
421
+ result = { :von => val[0], :last => val[1][0], :first => val[1][1] }
422
+
381
423
  result
382
424
  end
383
425
  .,.,
384
426
 
385
- module_eval(<<'.,.,', 'names.y', 68)
427
+ module_eval(<<'.,.,', 'names.y', 67)
386
428
  def _reduce_14(val, _values, result)
387
- result = val.join(' ')
429
+ result = { :von => val[0..1].join(' '), :last => val[2][0], :first => val[2][1] }
430
+
388
431
  result
389
432
  end
390
433
  .,.,
391
434
 
392
435
  # reduce 15 omitted
393
436
 
394
- # reduce 16 omitted
437
+ module_eval(<<'.,.,', 'names.y', 73)
438
+ def _reduce_16(val, _values, result)
439
+ result = { :last => val[0], :jr => val[2][0], :first => val[2][1] }
440
+
441
+ result
442
+ end
443
+ .,.,
395
444
 
396
- module_eval(<<'.,.,', 'names.y', 72)
445
+ module_eval(<<'.,.,', 'names.y', 77)
397
446
  def _reduce_17(val, _values, result)
398
- result = [nil,val[0]]
447
+ result = { :von => val[0], :last => val[1], :jr => val[3][0], :first => val[3][1] }
448
+
399
449
  result
400
450
  end
401
451
  .,.,
402
452
 
403
- module_eval(<<'.,.,', 'names.y', 73)
453
+ module_eval(<<'.,.,', 'names.y', 81)
404
454
  def _reduce_18(val, _values, result)
405
- result = [val[0],val[2]]
455
+ result = { :von => val[0..1].join(' '), :last => val[2], :jr => val[4][0], :first => val[4][1] }
456
+
406
457
  result
407
458
  end
408
459
  .,.,
409
460
 
410
461
  # reduce 19 omitted
411
462
 
412
- module_eval(<<'.,.,', 'names.y', 76)
463
+ module_eval(<<'.,.,', 'names.y', 85)
413
464
  def _reduce_20(val, _values, result)
414
- result = val.join(' ')
465
+ result = val.join(' ')
415
466
  result
416
467
  end
417
468
  .,.,
418
469
 
419
- # reduce 21 omitted
470
+ module_eval(<<'.,.,', 'names.y', 86)
471
+ def _reduce_21(val, _values, result)
472
+ result = val.join(' ')
473
+ result
474
+ end
475
+ .,.,
420
476
 
421
- # reduce 22 omitted
477
+ module_eval(<<'.,.,', 'names.y', 88)
478
+ def _reduce_22(val, _values, result)
479
+ result = [val[0], nil]
480
+ result
481
+ end
482
+ .,.,
422
483
 
423
- # reduce 23 omitted
484
+ module_eval(<<'.,.,', 'names.y', 89)
485
+ def _reduce_23(val, _values, result)
486
+ result = [val[0][0], val[0][1] ? val[0][1..-1].join(' ') : nil]
487
+ result
488
+ end
489
+ .,.,
424
490
 
425
- module_eval(<<'.,.,', 'names.y', 81)
491
+ module_eval(<<'.,.,', 'names.y', 90)
426
492
  def _reduce_24(val, _values, result)
427
- result = val.join(' ')
493
+ result = [val[0][0], (val[0][1..-1] << val[1]).join(' ')]
428
494
  result
429
495
  end
430
496
  .,.,
431
497
 
432
498
  # reduce 25 omitted
433
499
 
434
- # reduce 26 omitted
500
+ module_eval(<<'.,.,', 'names.y', 92)
501
+ def _reduce_26(val, _values, result)
502
+ result = val[0].join(' ')
503
+ result
504
+ end
505
+ .,.,
506
+
507
+ module_eval(<<'.,.,', 'names.y', 94)
508
+ def _reduce_27(val, _values, result)
509
+ result = [nil,val[0]]
510
+ result
511
+ end
512
+ .,.,
513
+
514
+ module_eval(<<'.,.,', 'names.y', 95)
515
+ def _reduce_28(val, _values, result)
516
+ result = [val[0],val[2]]
517
+ result
518
+ end
519
+ .,.,
520
+
521
+ module_eval(<<'.,.,', 'names.y', 97)
522
+ def _reduce_29(val, _values, result)
523
+ result = [val[0]]
524
+ result
525
+ end
526
+ .,.,
527
+
528
+ module_eval(<<'.,.,', 'names.y', 98)
529
+ def _reduce_30(val, _values, result)
530
+ result << val[1]
531
+ result
532
+ end
533
+ .,.,
534
+
535
+ # reduce 31 omitted
536
+
537
+ # reduce 32 omitted
538
+
539
+ # reduce 33 omitted
540
+
541
+ module_eval(<<'.,.,', 'names.y', 103)
542
+ def _reduce_34(val, _values, result)
543
+ result = val.join(' ')
544
+ result
545
+ end
546
+ .,.,
547
+
548
+ # reduce 35 omitted
549
+
550
+ # reduce 36 omitted
435
551
 
436
- # reduce 27 omitted
552
+ # reduce 37 omitted
437
553
 
438
- # reduce 28 omitted
554
+ # reduce 38 omitted
439
555
 
440
- # reduce 29 omitted
556
+ # reduce 39 omitted
441
557
 
442
558
  def _reduce_none(val, _values, result)
443
559
  val[0]
@@ -23,7 +23,7 @@
23
23
 
24
24
  class BibTeX::NameParser
25
25
 
26
- token COMMA UWORD LWORD PWORD AND ERROR
26
+ token COMMA UWORD LWORD PWORD ANDFL ANDLF ERROR
27
27
 
28
28
  expect 0
29
29
 
@@ -31,50 +31,72 @@ rule
31
31
 
32
32
  result : { result = [] } | names
33
33
 
34
- names : name { result = [val[0]] }
35
- | names AND name { result << val[2] }
36
-
37
- name : word
38
- {
39
- result = Name.new(:last => val[0])
40
- }
41
- | u_words word
42
- {
43
- result = Name.new(:first => val[0], :last => val[1])
44
- }
45
- | u_words von last
46
- {
47
- result = Name.new(:first => val[0], :von => val[1], :last => val[2])
48
- }
49
- | von last
50
- {
51
- result = Name.new(:von => val[0], :last => val[1])
52
- }
53
- | last COMMA first
54
- {
55
- result = Name.new(:last => val[0], :jr => val[2][0], :first => val[2][1])
56
- }
57
- | von last COMMA first
58
- {
59
- result = Name.new(:von => val[0], :last => val[1], :jr => val[3][0], :first => val[3][1])
60
- }
61
- | u_words von last COMMA first
62
- {
63
- result = Name.new(:von => val[0,2].join(' '), :last => val[2], :jr => val[4][0], :first => val[4][1])
64
- }
65
- ;
34
+ names : name { result = [val[0]] }
35
+ | names name { result << val[1] }
36
+
37
+ name : ANDFL flname { result = Name.new(val[1]) }
38
+ | ANDLF lfname { result = Name.new(val[1]) }
39
+
40
+ flname : word
41
+ {
42
+ result = { :last => val[0] }
43
+ }
44
+ | u_words word
45
+ {
46
+ result = { :first => val[0].join(' '), :last => val[1] }
47
+ }
48
+ | u_words von last
49
+ {
50
+ result = { :first => val[0].join(' '), :von => val[1], :last => val[2] }
51
+ }
52
+ | von last
53
+ {
54
+ result = { :von => val[0], :last => val[1] }
55
+ }
56
+ | comma
57
+
58
+ lfname : lastfirst
59
+ {
60
+ result = { :last => val[0][0], :first => val[0][1] }
61
+ }
62
+ | von lastfirst
63
+ {
64
+ result = { :von => val[0], :last => val[1][0], :first => val[1][1] }
65
+ }
66
+ | u_words von lastfirst
67
+ {
68
+ result = { :von => val[0..1].join(' '), :last => val[2][0], :first => val[2][1] }
69
+ }
70
+ | comma
71
+
72
+ comma : last COMMA first
73
+ {
74
+ result = { :last => val[0], :jr => val[2][0], :first => val[2][1] }
75
+ }
76
+ | von last COMMA first
77
+ {
78
+ result = { :von => val[0], :last => val[1], :jr => val[3][0], :first => val[3][1] }
79
+ }
80
+ | u_words von last COMMA first
81
+ {
82
+ result = { :von => val[0..1].join(' '), :last => val[2], :jr => val[4][0], :first => val[4][1] }
83
+ }
66
84
 
67
85
  von : LWORD
68
86
  | von LWORD { result = val.join(' ') }
69
87
  | von u_words LWORD { result = val.join(' ') }
70
88
 
71
- last : LWORD | u_words
89
+ lastfirst : LWORD { result = [val[0], nil] }
90
+ | u_words { result = [val[0][0], val[0][1] ? val[0][1..-1].join(' ') : nil] }
91
+ | u_words LWORD { result = [val[0][0], (val[0][1..-1] << val[1]).join(' ')] }
92
+
93
+ last : LWORD | u_words { result = val[0].join(' ') }
72
94
 
73
95
  first : opt_words { result = [nil,val[0]] }
74
96
  | opt_words COMMA opt_words { result = [val[0],val[2]] }
75
97
 
76
- u_words : u_word
77
- | u_words u_word { result = val.join(' ') }
98
+ u_words : u_word { result = [val[0]] }
99
+ | u_words u_word { result << val[1] }
78
100
 
79
101
  u_word : UWORD | PWORD
80
102
 
@@ -96,13 +118,14 @@ require 'strscan'
96
118
  :and => /,?\s+and\s+/io,
97
119
  :space => /\s+/o,
98
120
  :comma => /,/o,
99
- :lower => /[[:lower:]][^\s\{\}\d\\,]*/o,
100
- :upper => /[[:upper:]][^\s\{\}\d\\,]*/uo,
101
- :symbols => /(\d|\\.)+/o,
121
+ :lower => /[[:lower:]][[:lower:][:upper:]]*/uo,
122
+ :upper => /[[:upper:]][[:lower:][:upper:].]*/uo,
123
+ :other => /[^\s,\{\}\\[:upper:][:lower:]]+/uo,
102
124
  :lbrace => /\{/o,
103
125
  :rbrace => /\}/o,
104
- :period => /./o,
105
- :braces => /[\{\}]/o
126
+ :braces => /[\{\}]/o,
127
+ :escape => /\\./o,
128
+ :last_first => /[\p{Han}\p{Hiragana}\p{Katakana}\p{Hangul}]/uo
106
129
  }
107
130
 
108
131
  class << self
@@ -134,7 +157,8 @@ require 'strscan'
134
157
  def scan(input)
135
158
  @src = StringScanner.new(input)
136
159
  @brace_level = 0
137
- @stack = []
160
+ @last_and = 0
161
+ @stack = [[:ANDFL,'(^start)']]
138
162
  @word = [:PWORD,'']
139
163
  do_scan
140
164
  end
@@ -146,9 +170,10 @@ require 'strscan'
146
170
  case
147
171
  when @src.scan(NameParser.patterns[:and])
148
172
  push_word
149
- @stack.push([:AND,@src.matched])
173
+ @last_and = @stack.length
174
+ @stack.push([:ANDFL,@src.matched])
150
175
 
151
- when @src.scan(NameParser.patterns[:space])
176
+ when @src.skip(NameParser.patterns[:space])
152
177
  push_word
153
178
 
154
179
  when @src.scan(NameParser.patterns[:comma])
@@ -163,7 +188,8 @@ require 'strscan'
163
188
  is_uppercase
164
189
  @word[1] << @src.matched
165
190
 
166
- when @src.scan(NameParser.patterns[:symbols])
191
+ when @src.scan(NameParser.patterns[:other])
192
+ check_name_order
167
193
  @word[1] << @src.matched
168
194
 
169
195
  when @src.scan(NameParser.patterns[:lbrace])
@@ -173,8 +199,11 @@ require 'strscan'
173
199
  when @src.scan(NameParser.patterns[:rbrace])
174
200
  error_unbalanced
175
201
 
176
- when @src.scan(NameParser.patterns[:period])
202
+ when @src.scan(NameParser.patterns[:escape])
177
203
  @word[1] << @src.matched
204
+
205
+ else
206
+ error_invalid
178
207
  end
179
208
  end
180
209
 
@@ -197,6 +226,11 @@ require 'strscan'
197
226
  @word[0] = :UWORD if @word[0] == :PWORD
198
227
  end
199
228
 
229
+ def check_name_order
230
+ return if RUBY_VERSION < '1.9'
231
+ @stack[@last_and][0] = :ANDLF if @stack[@last_and][0] != :ANDLF && @src.matched =~ NameParser.patterns[:last_first]
232
+ end
233
+
200
234
  def scan_literal
201
235
  @brace_level = 1
202
236
 
@@ -225,4 +259,9 @@ require 'strscan'
225
259
  BibTeX.log.warn("NameParser: unbalanced braces at position #{@src.pos}; brace level #{@brace_level}.")
226
260
  end
227
261
 
262
+ def error_invalid
263
+ @stack.push [:ERROR,@src.getch]
264
+ BibTeX.log.warn("NameParser: invalid character at position #{@src.pos}; brace level #{@brace_level}.")
265
+ end
266
+
228
267
  # -*- racc -*-
@@ -19,8 +19,8 @@
19
19
  module BibTeX
20
20
  module Version
21
21
  MAJOR = 4
22
- MINOR = 0
23
- PATCH = 16
22
+ MINOR = 1
23
+ PATCH = 0
24
24
  BUILD = nil
25
25
 
26
26
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibtex-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.16
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-27 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: latex-decode