jkf 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +0 -10
- data/LICENSE.txt +1 -0
- data/README.md +8 -4
- data/jkf.gemspec +5 -3
- data/lib/jkf/converter/base.rb +1 -1
- data/lib/jkf/converter/csa.rb +4 -7
- data/lib/jkf/converter/kif.rb +5 -10
- data/lib/jkf/converter/kifuable.rb +3 -3
- data/lib/jkf/parser/base.rb +1 -1
- data/lib/jkf/parser/csa.rb +281 -286
- data/lib/jkf/parser/ki2.rb +3 -2
- data/lib/jkf/parser/kif.rb +3 -6
- data/lib/jkf/parser/kifuable.rb +2 -2
- data/lib/jkf/version.rb +1 -1
- data/lib/jkf.rb +1 -0
- data/manifest.scm +4 -102
- metadata +20 -13
- data/.github/workflows/ci.yml +0 -16
- data/.hound.yml +0 -3
- data/.rubocop.yml +0 -75
- data/.rubocop_todo.yml +0 -7
- data/Guardfile +0 -27
- data/bin/console +0 -15
- data/bin/setup +0 -8
data/lib/jkf/parser/csa.rb
CHANGED
@@ -17,29 +17,29 @@ module Jkf
|
|
17
17
|
s0 = @scanner.pos
|
18
18
|
if parse_version22 == :failed
|
19
19
|
@scanner.pos = s0
|
20
|
-
|
21
|
-
else
|
22
|
-
s1 = parse_information
|
23
|
-
s1 = nil if s1 == :failed
|
24
|
-
s2 = parse_initial_board
|
25
|
-
if s2 == :failed
|
26
|
-
@scanner.pos = s0
|
27
|
-
s0 = :failed
|
28
|
-
else
|
29
|
-
s3 = parse_moves
|
30
|
-
s3 = nil if s3 == :failed
|
31
|
-
@reported_pos = s0
|
32
|
-
s0 = -> (info, ini, ms) do
|
33
|
-
ret = { 'header' => info['header'], 'initial' => ini, 'moves' => ms }
|
34
|
-
if info && info['players']
|
35
|
-
ret['header']['先手'] = info['players'][0] if info['players'][0]
|
36
|
-
ret['header']['後手'] = info['players'][1] if info['players'][1]
|
37
|
-
end
|
38
|
-
ret
|
39
|
-
end.call(s1, s2, s3)
|
40
|
-
end
|
20
|
+
return :failed
|
41
21
|
end
|
42
|
-
|
22
|
+
|
23
|
+
s1 = parse_information
|
24
|
+
s1 = nil if s1 == :failed
|
25
|
+
s2 = parse_initial_board
|
26
|
+
if s2 == :failed
|
27
|
+
@scanner.pos = s0
|
28
|
+
return :failed
|
29
|
+
end
|
30
|
+
|
31
|
+
s3 = parse_moves
|
32
|
+
s3 = nil if s3 == :failed
|
33
|
+
@reported_pos = s0
|
34
|
+
info = s1
|
35
|
+
ini = s2
|
36
|
+
ms = s3
|
37
|
+
ret = { 'header' => info['header'], 'initial' => ini, 'moves' => ms }
|
38
|
+
if info && info['players']
|
39
|
+
ret['header']['先手'] = info['players'][0] if info['players'][0]
|
40
|
+
ret['header']['後手'] = info['players'][1] if info['players'][1]
|
41
|
+
end
|
42
|
+
ret
|
43
43
|
end
|
44
44
|
|
45
45
|
# version22 : comment* "V2.2" nl
|
@@ -49,17 +49,16 @@ module Jkf
|
|
49
49
|
s2 = match_str('V2.2')
|
50
50
|
if s2 == :failed
|
51
51
|
@scanner.pos = s0
|
52
|
-
|
53
|
-
else
|
54
|
-
s3 = parse_nl
|
55
|
-
if s3 == :failed
|
56
|
-
@scanner.pos = s0
|
57
|
-
s0 = :failed
|
58
|
-
else
|
59
|
-
s0 = [s1, s2, s3]
|
60
|
-
end
|
52
|
+
return :failed
|
61
53
|
end
|
62
|
-
|
54
|
+
|
55
|
+
s3 = parse_nl
|
56
|
+
if s3 == :failed
|
57
|
+
@scanner.pos = s0
|
58
|
+
return :failed
|
59
|
+
end
|
60
|
+
|
61
|
+
[s1, s2, s3]
|
63
62
|
end
|
64
63
|
|
65
64
|
# information : players? headers
|
@@ -70,12 +69,11 @@ module Jkf
|
|
70
69
|
s2 = parse_headers
|
71
70
|
if s2 == :failed
|
72
71
|
@scanner.pos = s0
|
73
|
-
|
74
|
-
else
|
75
|
-
@reported_pos = s0
|
76
|
-
s0 = { 'players' => s1, 'header' => s2 }
|
72
|
+
return :failed
|
77
73
|
end
|
78
|
-
|
74
|
+
|
75
|
+
@reported_pos = s0
|
76
|
+
{ 'players' => s1, 'header' => s2 }
|
79
77
|
end
|
80
78
|
|
81
79
|
# headers : header*
|
@@ -88,13 +86,12 @@ module Jkf
|
|
88
86
|
s2 = parse_header
|
89
87
|
end
|
90
88
|
@reported_pos = s0
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end.call(s1)
|
89
|
+
header = s1
|
90
|
+
ret = {}
|
91
|
+
header.each do |data|
|
92
|
+
ret[normalize_header_key(data['k'])] = data['v']
|
93
|
+
end
|
94
|
+
ret
|
98
95
|
end
|
99
96
|
|
100
97
|
# header : comment* "$" [^:]+ ":" nonls nl
|
@@ -103,36 +100,38 @@ module Jkf
|
|
103
100
|
parse_comments
|
104
101
|
if match_str('$') == :failed
|
105
102
|
@scanner.pos = s0
|
106
|
-
|
107
|
-
|
103
|
+
return :failed
|
104
|
+
end
|
105
|
+
|
106
|
+
s4 = match_regexp(/[^:]/)
|
107
|
+
if s4 == :failed
|
108
|
+
@scanner.pos = s0
|
109
|
+
return :failed
|
110
|
+
end
|
111
|
+
|
112
|
+
s3 = []
|
113
|
+
while s4 != :failed
|
114
|
+
s3 << s4
|
108
115
|
s4 = match_regexp(/[^:]/)
|
109
|
-
if s4 == :failed
|
110
|
-
s3 = :failed
|
111
|
-
else
|
112
|
-
s3 = []
|
113
|
-
while s4 != :failed
|
114
|
-
s3 << s4
|
115
|
-
s4 = match_regexp(/[^:]/)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
if s3 == :failed
|
119
|
-
@scanner.pos = s0
|
120
|
-
s0 = :failed
|
121
|
-
elsif match_str(':') != :failed
|
122
|
-
s4 = parse_nonls
|
123
|
-
if parse_nl == :failed
|
124
|
-
@scanner.pos = s0
|
125
|
-
s0 = :failed
|
126
|
-
else
|
127
|
-
@reported_pos = s0
|
128
|
-
s0 = { 'k' => s3.join, 'v' => s4.join }
|
129
|
-
end
|
130
|
-
else
|
131
|
-
@scanner.pos = s0
|
132
|
-
s0 = :failed
|
133
|
-
end
|
134
116
|
end
|
135
|
-
|
117
|
+
|
118
|
+
if s3 == :failed
|
119
|
+
@scanner.pos = s0
|
120
|
+
return :failed
|
121
|
+
end
|
122
|
+
if match_str(':') == :failed
|
123
|
+
@scanner.pos = s0
|
124
|
+
return :failed
|
125
|
+
end
|
126
|
+
|
127
|
+
s4 = parse_nonls
|
128
|
+
if parse_nl == :failed
|
129
|
+
@scanner.pos = s0
|
130
|
+
return :failed
|
131
|
+
end
|
132
|
+
|
133
|
+
@reported_pos = s0
|
134
|
+
{ 'k' => s3.join, 'v' => s4.join }
|
136
135
|
end
|
137
136
|
|
138
137
|
# csa1 : players? initialboard? moves
|
@@ -145,19 +144,19 @@ module Jkf
|
|
145
144
|
s3 = parse_moves
|
146
145
|
if s3 == :failed
|
147
146
|
@scanner.pos = s0
|
148
|
-
|
149
|
-
else
|
150
|
-
@reported_pos = s0
|
151
|
-
s0 = -> (ply, ini, ms) do
|
152
|
-
ret = { 'header' => {}, 'initial' => ini, 'moves' => ms }
|
153
|
-
if ply
|
154
|
-
ret['header']['先手'] = ply[0] if ply[0]
|
155
|
-
ret['header']['後手'] = ply[1] if ply[1]
|
156
|
-
end
|
157
|
-
ret
|
158
|
-
end.call(s1, s2, s3)
|
147
|
+
return :failed
|
159
148
|
end
|
160
|
-
|
149
|
+
|
150
|
+
@reported_pos = s0
|
151
|
+
ply = s1
|
152
|
+
ini = s2
|
153
|
+
ms = s3
|
154
|
+
ret = { 'header' => {}, 'initial' => ini, 'moves' => ms }
|
155
|
+
if ply
|
156
|
+
ret['header']['先手'] = ply[0] if ply[0]
|
157
|
+
ret['header']['後手'] = ply[1] if ply[1]
|
158
|
+
end
|
159
|
+
ret
|
161
160
|
end
|
162
161
|
|
163
162
|
# players : comment* ("N+" nonls nl)? comment* ("N-" nonls nl)?
|
@@ -232,7 +231,7 @@ module Jkf
|
|
232
231
|
:failed
|
233
232
|
elsif parse_nl != :failed
|
234
233
|
@reported_pos = s0
|
235
|
-
|
234
|
+
lambda do |data, koma, teban|
|
236
235
|
if data == 'NO'
|
237
236
|
data = koma
|
238
237
|
else
|
@@ -267,7 +266,7 @@ module Jkf
|
|
267
266
|
s0 = :failed
|
268
267
|
else
|
269
268
|
@reported_pos = s0
|
270
|
-
s0 =
|
269
|
+
s0 = lambda do |ps|
|
271
270
|
ret = { 'preset' => 'OTHER', 'data' => { 'board' => hirate } }
|
272
271
|
ps.each do |piece|
|
273
272
|
ret['data']['board'][piece['xy']['x'] - 1][piece['xy']['y'] - 1] = {}
|
@@ -294,7 +293,7 @@ module Jkf
|
|
294
293
|
end
|
295
294
|
if s1 != :failed
|
296
295
|
@reported_pos = s0
|
297
|
-
s1 =
|
296
|
+
s1 = lambda do |lines|
|
298
297
|
board = []
|
299
298
|
9.times do |i|
|
300
299
|
line = []
|
@@ -314,36 +313,39 @@ module Jkf
|
|
314
313
|
s0 = @scanner.pos
|
315
314
|
if match_str('P') == :failed
|
316
315
|
@scanner.pos = s0
|
317
|
-
|
318
|
-
|
316
|
+
return :failed
|
317
|
+
end
|
318
|
+
|
319
|
+
if match_digit == :failed
|
320
|
+
@scanner.pos = s0
|
321
|
+
return :failed
|
322
|
+
end
|
323
|
+
|
324
|
+
s4 = parse_masu
|
325
|
+
if s4 == :failed
|
326
|
+
@scanner.pos = s0
|
327
|
+
return :failed
|
328
|
+
end
|
329
|
+
|
330
|
+
s3 = []
|
331
|
+
while s4 != :failed
|
332
|
+
s3 << s4
|
319
333
|
s4 = parse_masu
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
s3 = []
|
324
|
-
while s4 != :failed
|
325
|
-
s3 << s4
|
326
|
-
s4 = parse_masu
|
327
|
-
end
|
328
|
-
end
|
329
|
-
if s3 == :failed
|
330
|
-
@scanner.pos = s0
|
331
|
-
s0 = :failed
|
332
|
-
else
|
333
|
-
s4 = parse_nl
|
334
|
-
if s4 == :failed
|
335
|
-
@scanner.pos = s0
|
336
|
-
s0 = :failed
|
337
|
-
else
|
338
|
-
@reported_pos = s0
|
339
|
-
s0 = s3
|
340
|
-
end
|
341
|
-
end
|
342
|
-
else
|
334
|
+
end
|
335
|
+
|
336
|
+
if s3 == :failed
|
343
337
|
@scanner.pos = s0
|
344
|
-
|
338
|
+
return :failed
|
345
339
|
end
|
346
|
-
|
340
|
+
|
341
|
+
s4 = parse_nl
|
342
|
+
if s4 == :failed
|
343
|
+
@scanner.pos = s0
|
344
|
+
return :failed
|
345
|
+
end
|
346
|
+
|
347
|
+
@reported_pos = s0
|
348
|
+
s3
|
347
349
|
end
|
348
350
|
|
349
351
|
# masu : teban piece | " * "
|
@@ -392,36 +394,37 @@ module Jkf
|
|
392
394
|
s0 = @scanner.pos
|
393
395
|
if match_str('P') == :failed
|
394
396
|
@scanner.pos = s0
|
395
|
-
|
396
|
-
else
|
397
|
-
s2 = parse_teban
|
398
|
-
if s2 == :failed
|
399
|
-
@scanner.pos = s0
|
400
|
-
s0 = :failed
|
401
|
-
else
|
402
|
-
s4 = parse_xy_piece
|
403
|
-
if s4 == :failed
|
404
|
-
s3 = :failed
|
405
|
-
else
|
406
|
-
s3 = []
|
407
|
-
while s4 != :failed
|
408
|
-
s3 << s4
|
409
|
-
s4 = parse_xy_piece
|
410
|
-
end
|
411
|
-
end
|
412
|
-
if s3 == :failed
|
413
|
-
@scanner.pos = s0
|
414
|
-
s0 = :failed
|
415
|
-
elsif parse_nl != :failed
|
416
|
-
@reported_pos = s0
|
417
|
-
s0 = { 'teban' => s2, 'pieces' => s3 }
|
418
|
-
else
|
419
|
-
@scanner.pos = s0
|
420
|
-
s0 = :failed
|
421
|
-
end
|
422
|
-
end
|
397
|
+
return :failed
|
423
398
|
end
|
424
|
-
|
399
|
+
|
400
|
+
s2 = parse_teban
|
401
|
+
if s2 == :failed
|
402
|
+
@scanner.pos = s0
|
403
|
+
return :failed
|
404
|
+
end
|
405
|
+
|
406
|
+
s4 = parse_xy_piece
|
407
|
+
if s4 == :failed
|
408
|
+
@scanner.pos = s0
|
409
|
+
return :failed
|
410
|
+
end
|
411
|
+
|
412
|
+
s3 = []
|
413
|
+
while s4 != :failed
|
414
|
+
s3 << s4
|
415
|
+
s4 = parse_xy_piece
|
416
|
+
end
|
417
|
+
if s3 == :failed
|
418
|
+
@scanner.pos = s0
|
419
|
+
return :failed
|
420
|
+
end
|
421
|
+
if parse_nl == :failed
|
422
|
+
@scanner.pos = s0
|
423
|
+
return :failed
|
424
|
+
end
|
425
|
+
|
426
|
+
@reported_pos = s0
|
427
|
+
{ 'teban' => s2, 'pieces' => s3 }
|
425
428
|
end
|
426
429
|
|
427
430
|
# moves : firstboard move* comment*
|
@@ -430,19 +433,18 @@ module Jkf
|
|
430
433
|
s1 = parse_firstboard
|
431
434
|
if s1 == :failed
|
432
435
|
@scanner.pos = s0
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
+
return :failed
|
437
|
+
end
|
438
|
+
|
439
|
+
s2 = []
|
440
|
+
s3 = parse_move
|
441
|
+
while s3 != :failed
|
442
|
+
s2 << s3
|
436
443
|
s3 = parse_move
|
437
|
-
while s3 != :failed
|
438
|
-
s2 << s3
|
439
|
-
s3 = parse_move
|
440
|
-
end
|
441
|
-
parse_comments
|
442
|
-
@reported_pos = s0
|
443
|
-
s0 = s2.unshift(s1)
|
444
444
|
end
|
445
|
-
|
445
|
+
parse_comments
|
446
|
+
@reported_pos = s0
|
447
|
+
s0 = s2.unshift(s1)
|
446
448
|
end
|
447
449
|
|
448
450
|
# firstboard : comment*
|
@@ -460,25 +462,25 @@ module Jkf
|
|
460
462
|
s1 = parse_special_move if s1 == :failed
|
461
463
|
if s1 == :failed
|
462
464
|
@scanner.pos = s0
|
463
|
-
|
465
|
+
return :failed
|
466
|
+
end
|
467
|
+
|
468
|
+
s2 = parse_time
|
469
|
+
s2 = nil if s2 == :failed
|
470
|
+
s3 = parse_comments
|
471
|
+
@reported_pos = s0
|
472
|
+
move = s1
|
473
|
+
time = s2
|
474
|
+
comments = s3
|
475
|
+
ret = {}
|
476
|
+
ret['comments'] = comments unless comments.empty?
|
477
|
+
ret['time'] = time if time
|
478
|
+
if move['special']
|
479
|
+
ret['special'] = move['special']
|
464
480
|
else
|
465
|
-
|
466
|
-
s2 = nil if s2 == :failed
|
467
|
-
s3 = parse_comments
|
468
|
-
@reported_pos = s0
|
469
|
-
s0 = -> (move, time, comments) do
|
470
|
-
ret = {}
|
471
|
-
ret['comments'] = comments unless comments.empty?
|
472
|
-
ret['time'] = time if time
|
473
|
-
if move['special']
|
474
|
-
ret['special'] = move['special']
|
475
|
-
else
|
476
|
-
ret['move'] = move
|
477
|
-
end
|
478
|
-
ret
|
479
|
-
end.call(s1, s2, s3)
|
481
|
+
ret['move'] = move
|
480
482
|
end
|
481
|
-
|
483
|
+
ret
|
482
484
|
end
|
483
485
|
|
484
486
|
# normalmove : teban xy xy piece nl
|
@@ -487,37 +489,39 @@ module Jkf
|
|
487
489
|
s1 = parse_teban
|
488
490
|
if s1 == :failed
|
489
491
|
@scanner.pos = s0
|
490
|
-
|
491
|
-
else
|
492
|
-
s2 = parse_xy
|
493
|
-
if s2 == :failed
|
494
|
-
@scanner.pos = s0
|
495
|
-
s0 = :failed
|
496
|
-
else
|
497
|
-
s3 = parse_xy
|
498
|
-
if s3 == :failed
|
499
|
-
@scanner.pos = s0
|
500
|
-
s0 = :failed
|
501
|
-
else
|
502
|
-
s4 = parse_piece
|
503
|
-
if s4 == :failed
|
504
|
-
@scanner.pos = s0
|
505
|
-
s0 = :failed
|
506
|
-
elsif parse_nl != :failed
|
507
|
-
@reported_pos = s0
|
508
|
-
s0 = -> (color, from, to, piece) do
|
509
|
-
ret = { 'color' => color, 'to' => to, 'piece' => piece }
|
510
|
-
ret['from'] = from if from['x'] != 0
|
511
|
-
ret
|
512
|
-
end.call(s1, s2, s3, s4)
|
513
|
-
else
|
514
|
-
@scanner.pos = s0
|
515
|
-
s0 = :failed
|
516
|
-
end
|
517
|
-
end
|
518
|
-
end
|
492
|
+
return :failed
|
519
493
|
end
|
520
|
-
|
494
|
+
|
495
|
+
s2 = parse_xy
|
496
|
+
if s2 == :failed
|
497
|
+
@scanner.pos = s0
|
498
|
+
return :failed
|
499
|
+
end
|
500
|
+
|
501
|
+
s3 = parse_xy
|
502
|
+
if s3 == :failed
|
503
|
+
@scanner.pos = s0
|
504
|
+
return :failed
|
505
|
+
end
|
506
|
+
|
507
|
+
s4 = parse_piece
|
508
|
+
if s4 == :failed
|
509
|
+
@scanner.pos = s0
|
510
|
+
return :failed
|
511
|
+
end
|
512
|
+
if parse_nl == :failed
|
513
|
+
@scanner.pos = s0
|
514
|
+
return :failed
|
515
|
+
end
|
516
|
+
|
517
|
+
@reported_pos = s0
|
518
|
+
color = s1
|
519
|
+
from = s2
|
520
|
+
to = s3
|
521
|
+
piece = s4
|
522
|
+
ret = { 'color' => color, 'to' => to, 'piece' => piece }
|
523
|
+
ret['from'] = from if from['x'] != 0
|
524
|
+
ret
|
521
525
|
end
|
522
526
|
|
523
527
|
# specialmove : "%" [-+_A-Z]+ nl
|
@@ -526,30 +530,33 @@ module Jkf
|
|
526
530
|
s1 = match_str('%')
|
527
531
|
if s1 == :failed
|
528
532
|
@scanner.pos = s0
|
529
|
-
|
530
|
-
|
533
|
+
return :failed
|
534
|
+
end
|
535
|
+
|
536
|
+
s3 = match_regexp(/[-+_A-Z]/)
|
537
|
+
if s3 == :failed
|
538
|
+
@scanner.pos = s0
|
539
|
+
return :failed
|
540
|
+
end
|
541
|
+
|
542
|
+
s2 = []
|
543
|
+
while s3 != :failed
|
544
|
+
s2 << s3
|
531
545
|
s3 = match_regexp(/[-+_A-Z]/)
|
532
|
-
if s3 == :failed
|
533
|
-
s2 = :failed
|
534
|
-
else
|
535
|
-
s2 = []
|
536
|
-
while s3 != :failed
|
537
|
-
s2 << s3
|
538
|
-
s3 = match_regexp(/[-+_A-Z]/)
|
539
|
-
end
|
540
|
-
end
|
541
|
-
if s2 == :failed
|
542
|
-
@scanner.pos = s0
|
543
|
-
s0 = :failed
|
544
|
-
elsif parse_nl != :failed
|
545
|
-
@reported_pos = s0
|
546
|
-
s0 = { 'special' => s2.join }
|
547
|
-
else
|
548
|
-
@scanner.pos = s0
|
549
|
-
s0 = :failed
|
550
|
-
end
|
551
546
|
end
|
552
|
-
|
547
|
+
|
548
|
+
if s2 == :failed
|
549
|
+
@scanner.pos = s0
|
550
|
+
return :failed
|
551
|
+
end
|
552
|
+
|
553
|
+
if parse_nl == :failed
|
554
|
+
@scanner.pos = s0
|
555
|
+
return :failed
|
556
|
+
end
|
557
|
+
|
558
|
+
@reported_pos = s0
|
559
|
+
{ 'special' => s2.join }
|
553
560
|
end
|
554
561
|
|
555
562
|
# teban : "+" | "-"
|
@@ -578,17 +585,17 @@ module Jkf
|
|
578
585
|
s0 = @scanner.pos
|
579
586
|
if match_str("'") == :failed
|
580
587
|
@scanner.pos = s0
|
581
|
-
:failed
|
582
|
-
else
|
583
|
-
s2 = parse_nonls
|
584
|
-
if parse_nl == :failed
|
585
|
-
@scanner.pos = s0
|
586
|
-
:failed
|
587
|
-
else
|
588
|
-
@reported_pos = s0
|
589
|
-
s2.join
|
590
|
-
end
|
588
|
+
return :failed
|
591
589
|
end
|
590
|
+
|
591
|
+
s2 = parse_nonls
|
592
|
+
if parse_nl == :failed
|
593
|
+
@scanner.pos = s0
|
594
|
+
return :failed
|
595
|
+
end
|
596
|
+
|
597
|
+
@reported_pos = s0
|
598
|
+
s2.join
|
592
599
|
end
|
593
600
|
|
594
601
|
# comments : comment*
|
@@ -607,18 +614,17 @@ module Jkf
|
|
607
614
|
s0 = @scanner.pos
|
608
615
|
if match_str('T') == :failed
|
609
616
|
@scanner.pos = s0
|
610
|
-
|
611
|
-
else
|
612
|
-
s2 = match_digits
|
613
|
-
if parse_nl == :failed
|
614
|
-
@scanner.pos = s0
|
615
|
-
s0 = :failed
|
616
|
-
else
|
617
|
-
@reported_pos = s0
|
618
|
-
s0 = { 'now' => sec2time(s2.join.to_i) }
|
619
|
-
end
|
617
|
+
return :failed
|
620
618
|
end
|
621
|
-
|
619
|
+
|
620
|
+
s2 = match_digits
|
621
|
+
if parse_nl == :failed
|
622
|
+
@scanner.pos = s0
|
623
|
+
return :failed
|
624
|
+
end
|
625
|
+
|
626
|
+
@reported_pos = s0
|
627
|
+
{ 'now' => sec2time(s2.join.to_i) }
|
622
628
|
end
|
623
629
|
|
624
630
|
# xy : [0-9] [0-9]
|
@@ -627,18 +633,17 @@ module Jkf
|
|
627
633
|
s1 = match_digit
|
628
634
|
if s1 == :failed
|
629
635
|
@scanner.pos = s0
|
630
|
-
|
631
|
-
else
|
632
|
-
s2 = match_digit
|
633
|
-
if s2 == :failed
|
634
|
-
@scanner.pos = s0
|
635
|
-
s0 = :failed
|
636
|
-
else
|
637
|
-
@reported_pos = s0
|
638
|
-
s0 = { 'x' => s1.to_i, 'y' => s2.to_i }
|
639
|
-
end
|
636
|
+
return :failed
|
640
637
|
end
|
641
|
-
|
638
|
+
|
639
|
+
s2 = match_digit
|
640
|
+
if s2 == :failed
|
641
|
+
@scanner.pos = s0
|
642
|
+
return :failed
|
643
|
+
end
|
644
|
+
|
645
|
+
@reported_pos = s0
|
646
|
+
{ 'x' => s1.to_i, 'y' => s2.to_i }
|
642
647
|
end
|
643
648
|
|
644
649
|
# piece : [A-Z] [A-Z]
|
@@ -647,18 +652,17 @@ module Jkf
|
|
647
652
|
s1 = match_regexp(/[A-Z]/)
|
648
653
|
if s1 == :failed
|
649
654
|
@scanner.pos = s0
|
650
|
-
|
651
|
-
else
|
652
|
-
s2 = match_regexp(/[A-Z]/)
|
653
|
-
if s2 == :failed
|
654
|
-
@scanner.pos = s0
|
655
|
-
s0 = :failed
|
656
|
-
else
|
657
|
-
@reported_pos = s0
|
658
|
-
s0 = s1 + s2
|
659
|
-
end
|
655
|
+
return :failed
|
660
656
|
end
|
661
|
-
|
657
|
+
|
658
|
+
s2 = match_regexp(/[A-Z]/)
|
659
|
+
if s2 == :failed
|
660
|
+
@scanner.pos = s0
|
661
|
+
return :failed
|
662
|
+
end
|
663
|
+
|
664
|
+
@reported_pos = s0
|
665
|
+
s1 + s2
|
662
666
|
end
|
663
667
|
|
664
668
|
# xypiece : xy piece
|
@@ -667,18 +671,17 @@ module Jkf
|
|
667
671
|
s1 = parse_xy
|
668
672
|
if s1 == :failed
|
669
673
|
@scanner.pos = s0
|
670
|
-
|
671
|
-
else
|
672
|
-
s2 = parse_piece
|
673
|
-
if s2 == :failed
|
674
|
-
@scanner.pos = s0
|
675
|
-
s0 = :failed
|
676
|
-
else
|
677
|
-
@reported_pos = s0
|
678
|
-
s0 = { 'xy' => s1, 'piece' => s2 }
|
679
|
-
end
|
674
|
+
return :failed
|
680
675
|
end
|
681
|
-
|
676
|
+
|
677
|
+
s2 = parse_piece
|
678
|
+
if s2 == :failed
|
679
|
+
@scanner.pos = s0
|
680
|
+
return :failed
|
681
|
+
end
|
682
|
+
|
683
|
+
@reported_pos = s0
|
684
|
+
{ 'xy' => s1, 'piece' => s2 }
|
682
685
|
end
|
683
686
|
|
684
687
|
# nl : ("\r"? "\n") | " "* ","
|
@@ -755,15 +758,7 @@ module Jkf
|
|
755
758
|
|
756
759
|
# return empty board jkf
|
757
760
|
def generate_empty_board
|
758
|
-
|
759
|
-
9.times do |_i|
|
760
|
-
line = []
|
761
|
-
9.times do |_j|
|
762
|
-
line << {}
|
763
|
-
end
|
764
|
-
board << line
|
765
|
-
end
|
766
|
-
board
|
761
|
+
Array.new(9) { Array.new(9) { {} } }
|
767
762
|
end
|
768
763
|
|
769
764
|
# sec to time(m, s)
|