raf 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -1
- data/History.rdoc +2 -20
- data/LICENSE.txt +1 -1
- data/README.rdoc +6 -16
- data/RELEASE +1 -1
- data/VERSION +1 -1
- data/raf.gemspec +3 -1
- metadata +32 -63
- data/.document +0 -5
- data/bin/raf +0 -19
- data/bin/raf2html +0 -29
- data/lib/parserutility.rb +0 -21
- data/lib/raf.rb +0 -7
- data/lib/raf2html.rb +0 -157
- data/lib/raf2html_element.rb +0 -198
- data/lib/rafblockparser.output +0 -670
- data/lib/rafblockparser.ry +0 -358
- data/lib/rafblockparser.tab.rb +0 -715
- data/lib/rafelement.rb +0 -229
- data/lib/rafinlineparser.output +0 -1804
- data/lib/rafinlineparser.ry +0 -415
- data/lib/rafinlineparser.tab.rb +0 -972
- data/sample.raf +0 -4
- data/test/helper.rb +0 -18
- data/test/test_descblock.rb +0 -88
- data/test/test_emphasis.rb +0 -76
- data/test/test_erb.rb +0 -23
- data/test/test_footnote.rb +0 -38
- data/test/test_headline.rb +0 -43
- data/test/test_helper.rb +0 -2
- data/test/test_image.rb +0 -81
- data/test/test_italic.rb +0 -76
- data/test/test_itemlistblock.rb +0 -151
- data/test/test_numlistblock.rb +0 -342
- data/test/test_paragraph.rb +0 -76
- data/test/test_quoteblock.rb +0 -109
- data/test/test_reference.rb +0 -47
- data/test/test_ruby.rb +0 -66
- data/test/test_strike.rb +0 -76
- data/test/test_tableblock.rb +0 -63
- data/test/test_verb.rb +0 -86
- data/test/ts_block.rb +0 -10
- data/test/ts_inline.rb +0 -8
- data/test/ts_rafparser.rb +0 -4
data/lib/rafblockparser.tab.rb
DELETED
@@ -1,715 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.4.10
|
4
|
-
# from Racc grammer file "".
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'racc/parser.rb'
|
8
|
-
|
9
|
-
require "parserutility"
|
10
|
-
require "rafinlineparser.tab"
|
11
|
-
require "rafelement"
|
12
|
-
|
13
|
-
module Raf
|
14
|
-
|
15
|
-
class BlockParser < Racc::Parser
|
16
|
-
|
17
|
-
module_eval(<<'...end rafblockparser.ry/module_eval...', 'rafblockparser.ry', 120)
|
18
|
-
include ParserUtility
|
19
|
-
|
20
|
-
class Line
|
21
|
-
def initialize(line)
|
22
|
-
@content = line
|
23
|
-
# @indent = get_line_indent(line)
|
24
|
-
# @type = nil
|
25
|
-
end
|
26
|
-
attr_reader :indent, :no
|
27
|
-
attr_accessor :type, :content
|
28
|
-
alias indent_size indent
|
29
|
-
|
30
|
-
def get_line_indent
|
31
|
-
return 0 if @content.nil?
|
32
|
-
@content =~ /(\s*)/
|
33
|
-
$1.size
|
34
|
-
end
|
35
|
-
alias indent get_line_indent
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def initialize
|
40
|
-
@inline_parser = InlineParser.new
|
41
|
-
@metadata = {}
|
42
|
-
@inline_index = @inline_parser.index
|
43
|
-
@index = {}
|
44
|
-
@head_index = HeadIndex.new
|
45
|
-
end
|
46
|
-
attr_reader :metadata, :inline_index, :index
|
47
|
-
|
48
|
-
def parse(src)
|
49
|
-
@no = 0
|
50
|
-
@src = Array(src)
|
51
|
-
@line = Line.new("")
|
52
|
-
@line_pre = @line.dup
|
53
|
-
@indent_stack = []
|
54
|
-
@current_indent = 0
|
55
|
-
@current_type = :header
|
56
|
-
@yydebug = true
|
57
|
-
@view_token_type = false
|
58
|
-
do_parse
|
59
|
-
end
|
60
|
-
|
61
|
-
def on_error(token_id, value, stack)
|
62
|
-
lineno = @src[0..@no].to_s.split("\n").size
|
63
|
-
raise Racc::ParseError,
|
64
|
-
"rafblockpaser: line #{lineno}: syntax error on #{value.inspect}"
|
65
|
-
end
|
66
|
-
|
67
|
-
def next_token
|
68
|
-
@line_pre = @line.dup
|
69
|
-
@line = Line.new(@src[@no])
|
70
|
-
# puts "line: #{@line.content}" if @view_token_type
|
71
|
-
case @line.content
|
72
|
-
when nil
|
73
|
-
@line.content = ""
|
74
|
-
if_current_indent_equal("") do
|
75
|
-
puts "b: false: #{@line.content}" if @view_token_type
|
76
|
-
[false, false]
|
77
|
-
end
|
78
|
-
when /^$/
|
79
|
-
@line.content = ""
|
80
|
-
if_current_indent_equal("") do
|
81
|
-
if @current_type == :quote
|
82
|
-
puts "b: QUOTE: #{@line.content}" if @view_token_type
|
83
|
-
[:QUOTE, "\n"]
|
84
|
-
elsif @current_type == :descline
|
85
|
-
puts "b: DESCLINE: #{@line.content}" if @view_token_type
|
86
|
-
[:DESCLINE, " "]
|
87
|
-
else
|
88
|
-
puts "b: WHITELINE: #{@line.content}" if @view_token_type
|
89
|
-
@current_type = :whiteline
|
90
|
-
[:WHITELINE, :WHITELINE]
|
91
|
-
end
|
92
|
-
end
|
93
|
-
when /^\#(.*)/ # comment line
|
94
|
-
@no += 1
|
95
|
-
if @current_type == :header
|
96
|
-
puts "b: HEADER: #{@line.content}" if @view_token_type
|
97
|
-
[:HEADER, $1.strip]
|
98
|
-
else
|
99
|
-
puts "b: COMMENT(noop): #{@line.content}" if @view_token_type
|
100
|
-
next_token
|
101
|
-
end
|
102
|
-
when /^(={1,4})(?!=)\s*(?=\S)/, /^(\+{1,2})(?!\+)\s*(?=\S)/
|
103
|
-
rest = $' # '
|
104
|
-
rest.strip!
|
105
|
-
mark = $1
|
106
|
-
# if_current_indent_equal("") do
|
107
|
-
if_current_indent_equal(@line.indent) do
|
108
|
-
@current_type = :headline
|
109
|
-
puts "b: HEADLINE: #{@line.content}" if @view_token_type
|
110
|
-
[:HEADLINE, [mark_to_level(mark), rest]]
|
111
|
-
end
|
112
|
-
when /^\s\s+(.*)/ # type == quote
|
113
|
-
puts "b: 2 WHITE SPACE(#{@current_type}) : #{@line.content}" if @view_token_type
|
114
|
-
case @current_type
|
115
|
-
when :itemlist
|
116
|
-
if @line.content =~ /^(\s*)(\*)(\s+)(.*)/
|
117
|
-
line = $4.strip
|
118
|
-
if line.empty?
|
119
|
-
@no += 1
|
120
|
-
next_token
|
121
|
-
else
|
122
|
-
if_current_indent_equal(@line.indent) do
|
123
|
-
puts "b: ITEMLIST: [#{line}]" if @view_token_type
|
124
|
-
@current_type = :itemlist
|
125
|
-
[:ITEMLIST, line]
|
126
|
-
end
|
127
|
-
end
|
128
|
-
else
|
129
|
-
line = @line.content.strip
|
130
|
-
if line.empty?
|
131
|
-
@no += 1
|
132
|
-
next_token
|
133
|
-
else
|
134
|
-
puts "b: ITEMLISTCONTINUE: [#{line.empty?}] --" if @view_token_type
|
135
|
-
@no += 1
|
136
|
-
@current_type = :itemlist
|
137
|
-
[:ITEMLISTCONTINUE, line]
|
138
|
-
end
|
139
|
-
end
|
140
|
-
when :numlist
|
141
|
-
@line.content =~ /^(\s*)(\(\d+\))(\s+)(.*)/
|
142
|
-
if $4.nil?
|
143
|
-
@line.content =~ /^(\s*)(\d\.)(\s+)(.*)/
|
144
|
-
end
|
145
|
-
line = $4
|
146
|
-
line ||= @line.content.strip
|
147
|
-
if line.empty?
|
148
|
-
@no += 1
|
149
|
-
next_token
|
150
|
-
else
|
151
|
-
if_current_indent_equal(@line.indent) do
|
152
|
-
puts "b: NUMLIST: [#{line}]" if @view_token_type
|
153
|
-
@current_type = :numlist
|
154
|
-
[:NUMLIST, line]
|
155
|
-
end
|
156
|
-
end
|
157
|
-
else
|
158
|
-
@no += 1
|
159
|
-
if @current_type == :descline
|
160
|
-
@current_type = :descline
|
161
|
-
puts "b: DESCLINE: #{@line.content}" if @view_token_type
|
162
|
-
[:DESCLINE, $1 + "\n"]
|
163
|
-
else
|
164
|
-
@current_type = :quote
|
165
|
-
puts "b: QUOTE: #{$1}" if @view_token_type
|
166
|
-
[:QUOTE, @line.content.sub(" ","")]
|
167
|
-
end
|
168
|
-
end
|
169
|
-
when /^(\:)(.*)/ # type = desclist
|
170
|
-
if_current_indent_equal(@line.indent) do
|
171
|
-
@current_type = :descline
|
172
|
-
puts "b: DESCLINE_TILTE: #{$2.strip}" if @view_token_type
|
173
|
-
[:DESCLINE_TITLE, $2.strip]
|
174
|
-
end
|
175
|
-
when /^(\s*)(\*)(\s+)(.*)/ # type = itemlist
|
176
|
-
if_current_indent_equal(@line.indent) do
|
177
|
-
puts "b: ITEMLIST: #{@line.content}" if @view_token_type
|
178
|
-
@current_type = :itemlist
|
179
|
-
[:ITEMLIST, $4]
|
180
|
-
end
|
181
|
-
when /^(\s*)(\(\d+\))(\s+)(.*)/
|
182
|
-
if_current_indent_equal(@line.indent) do
|
183
|
-
puts "b: NUMLIST: #{@line.content}" if @view_token_type
|
184
|
-
@current_type = :numlist
|
185
|
-
[:NUMLIST, $4]
|
186
|
-
end
|
187
|
-
when /^(\s*)(\d+\.)(\s+)(.*)/ # type = numlist
|
188
|
-
if_current_indent_equal(@line.indent) do
|
189
|
-
puts "b: NUMLIST: #{@line.content}" if @view_token_type
|
190
|
-
@current_type = :numlist
|
191
|
-
[:NUMLIST, $4]
|
192
|
-
end
|
193
|
-
when /^\|.*/ # type = table
|
194
|
-
@no += 1
|
195
|
-
@current_type = :table
|
196
|
-
lines = @line.content.chomp.split("|")
|
197
|
-
lines.shift
|
198
|
-
[:TABLELINE, lines]
|
199
|
-
when /(.*)/ # type == plain
|
200
|
-
@current_type = :plain
|
201
|
-
if_current_indent_equal(@line.indent) do
|
202
|
-
puts "b: PLAIN: #{@line.content}" if @view_token_type
|
203
|
-
[:PLAIN, @line.content]
|
204
|
-
end
|
205
|
-
else
|
206
|
-
puts "raise : #{@line}"
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def if_current_indent_equal(ident)
|
211
|
-
indent_space = 2
|
212
|
-
puts "current: #{@current_indent}, line: #{@line.indent}, stack #{@indent_stack.size}:" if @view_token_type
|
213
|
-
indent_sabun = @current_indent - @line.indent
|
214
|
-
if indent_sabun >= -1 and indent_sabun <= 1
|
215
|
-
@no += 1
|
216
|
-
yield
|
217
|
-
elsif @current_indent < @line.indent
|
218
|
-
((@line.indent - @current_indent) / indent_space).times do
|
219
|
-
@indent_stack.push("")
|
220
|
-
end
|
221
|
-
@current_indent = @line.indent
|
222
|
-
puts "b: INDENT" if @view_token_type
|
223
|
-
[:INDENT, :INDENT]
|
224
|
-
else
|
225
|
-
@indent_stack.pop
|
226
|
-
@current_indent = @line.indent if @line.indent == @indent_stack.size * indent_space
|
227
|
-
puts "b: DEDENT" if @view_token_type
|
228
|
-
[:DEDENT, :DEDENT]
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
...end rafblockparser.ry/module_eval...
|
233
|
-
##### State transition tables begin ###
|
234
|
-
|
235
|
-
racc_action_table = [
|
236
|
-
13, 12, 14, 16, 17, 46, 19, 23, 35, 25,
|
237
|
-
25, 29, 31, 13, 12, 14, 16, 17, 25, 19,
|
238
|
-
23, 47, 25, 37, 29, 31, 23, 29, 25, 37,
|
239
|
-
29, 37, 52, 29, 48, 29, 35, 51, 25, 35,
|
240
|
-
49, 25, 41, 40, 50, 38, 32, 53 ]
|
241
|
-
|
242
|
-
racc_action_check = [
|
243
|
-
0, 0, 0, 0, 0, 25, 0, 0, 35, 0,
|
244
|
-
35, 0, 0, 2, 2, 2, 2, 2, 21, 2,
|
245
|
-
2, 27, 2, 8, 2, 2, 23, 8, 23, 37,
|
246
|
-
23, 44, 44, 37, 30, 44, 43, 43, 43, 7,
|
247
|
-
32, 7, 18, 17, 39, 15, 1, 45 ]
|
248
|
-
|
249
|
-
racc_action_pointer = [
|
250
|
-
-2, 46, 11, nil, nil, nil, nil, 30, 14, nil,
|
251
|
-
nil, nil, nil, nil, nil, 40, nil, 36, 34, nil,
|
252
|
-
nil, 7, nil, 17, nil, -7, nil, 8, nil, nil,
|
253
|
-
20, nil, 40, nil, nil, -1, nil, 20, nil, 37,
|
254
|
-
nil, nil, nil, 27, 22, 35, nil, nil, nil, nil,
|
255
|
-
nil, nil, nil, nil ]
|
256
|
-
|
257
|
-
racc_action_default = [
|
258
|
-
-46, -46, -1, -2, -4, -5, -6, -7, -8, -9,
|
259
|
-
-10, -11, -12, -13, -14, -15, -16, -21, -22, -23,
|
260
|
-
-25, -27, -28, -46, -30, -32, -36, -38, -39, -41,
|
261
|
-
-43, -44, -46, -3, -26, -46, -37, -46, -17, -18,
|
262
|
-
-19, -24, -31, -46, -46, -33, -34, -42, -45, 54,
|
263
|
-
-20, -29, -40, -35 ]
|
264
|
-
|
265
|
-
racc_goto_table = [
|
266
|
-
36, 34, 44, 43, 3, 39, 33, 2, 42, 45,
|
267
|
-
1, nil, nil, nil, nil, 43, 44, nil, nil, nil,
|
268
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
269
|
-
nil, nil, nil, nil, nil, nil, 36, 34 ]
|
270
|
-
|
271
|
-
racc_goto_check = [
|
272
|
-
20, 15, 8, 7, 3, 13, 3, 2, 18, 19,
|
273
|
-
1, nil, nil, nil, nil, 7, 8, nil, nil, nil,
|
274
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
275
|
-
nil, nil, nil, nil, nil, nil, 20, 15 ]
|
276
|
-
|
277
|
-
racc_goto_pointer = [
|
278
|
-
nil, 10, 7, 4, nil, nil, nil, -20, -21, nil,
|
279
|
-
nil, nil, nil, -12, nil, -6, nil, nil, -13, -16,
|
280
|
-
-8, nil, nil, nil ]
|
281
|
-
|
282
|
-
racc_goto_default = [
|
283
|
-
nil, nil, nil, nil, 4, 5, 6, 7, 8, 9,
|
284
|
-
10, 11, 15, nil, 18, 20, 21, 22, 24, nil,
|
285
|
-
26, 27, 28, 30 ]
|
286
|
-
|
287
|
-
racc_reduce_table = [
|
288
|
-
0, 0, :racc_error,
|
289
|
-
1, 17, :_reduce_1,
|
290
|
-
1, 18, :_reduce_2,
|
291
|
-
2, 18, :_reduce_3,
|
292
|
-
1, 19, :_reduce_none,
|
293
|
-
1, 19, :_reduce_5,
|
294
|
-
1, 19, :_reduce_none,
|
295
|
-
1, 19, :_reduce_7,
|
296
|
-
1, 19, :_reduce_8,
|
297
|
-
1, 19, :_reduce_none,
|
298
|
-
1, 19, :_reduce_none,
|
299
|
-
1, 19, :_reduce_none,
|
300
|
-
1, 19, :_reduce_12,
|
301
|
-
1, 20, :_reduce_13,
|
302
|
-
1, 27, :_reduce_14,
|
303
|
-
1, 21, :_reduce_15,
|
304
|
-
1, 28, :_reduce_16,
|
305
|
-
2, 28, :_reduce_17,
|
306
|
-
2, 25, :_reduce_18,
|
307
|
-
1, 29, :_reduce_19,
|
308
|
-
2, 29, :_reduce_20,
|
309
|
-
0, 29, :_reduce_none,
|
310
|
-
1, 22, :_reduce_22,
|
311
|
-
1, 30, :_reduce_23,
|
312
|
-
2, 30, :_reduce_24,
|
313
|
-
1, 23, :_reduce_25,
|
314
|
-
2, 23, :_reduce_26,
|
315
|
-
1, 31, :_reduce_27,
|
316
|
-
1, 31, :_reduce_28,
|
317
|
-
3, 33, :_reduce_29,
|
318
|
-
1, 32, :_reduce_30,
|
319
|
-
2, 32, :_reduce_31,
|
320
|
-
1, 34, :_reduce_32,
|
321
|
-
2, 34, :_reduce_33,
|
322
|
-
1, 35, :_reduce_34,
|
323
|
-
2, 35, :_reduce_35,
|
324
|
-
1, 24, :_reduce_36,
|
325
|
-
2, 24, :_reduce_37,
|
326
|
-
1, 36, :_reduce_38,
|
327
|
-
1, 36, :_reduce_39,
|
328
|
-
3, 38, :_reduce_40,
|
329
|
-
1, 37, :_reduce_41,
|
330
|
-
2, 37, :_reduce_42,
|
331
|
-
1, 26, :_reduce_43,
|
332
|
-
1, 39, :_reduce_44,
|
333
|
-
2, 39, :_reduce_45 ]
|
334
|
-
|
335
|
-
racc_reduce_n = 46
|
336
|
-
|
337
|
-
racc_shift_n = 54
|
338
|
-
|
339
|
-
racc_token_table = {
|
340
|
-
false => 0,
|
341
|
-
:error => 1,
|
342
|
-
:HEADER => 2,
|
343
|
-
:WHITELINE => 3,
|
344
|
-
:HEADLINE => 4,
|
345
|
-
:PLAIN => 5,
|
346
|
-
:DESCLINE_TITLE => 6,
|
347
|
-
:DESCLINE => 7,
|
348
|
-
:QUOTE => 8,
|
349
|
-
:INDENT => 9,
|
350
|
-
:DEDENT => 10,
|
351
|
-
:ITEMLIST => 11,
|
352
|
-
:ITEMLISTCONTINUE => 12,
|
353
|
-
:NUMLIST => 13,
|
354
|
-
:TABLELINE => 14,
|
355
|
-
:DUMMY => 15 }
|
356
|
-
|
357
|
-
racc_nt_base = 16
|
358
|
-
|
359
|
-
racc_use_result_var = false
|
360
|
-
|
361
|
-
Racc_arg = [
|
362
|
-
racc_action_table,
|
363
|
-
racc_action_check,
|
364
|
-
racc_action_default,
|
365
|
-
racc_action_pointer,
|
366
|
-
racc_goto_table,
|
367
|
-
racc_goto_check,
|
368
|
-
racc_goto_default,
|
369
|
-
racc_goto_pointer,
|
370
|
-
racc_nt_base,
|
371
|
-
racc_reduce_table,
|
372
|
-
racc_token_table,
|
373
|
-
racc_shift_n,
|
374
|
-
racc_reduce_n,
|
375
|
-
racc_use_result_var ]
|
376
|
-
|
377
|
-
Racc_token_to_s_table = [
|
378
|
-
"$end",
|
379
|
-
"error",
|
380
|
-
"HEADER",
|
381
|
-
"WHITELINE",
|
382
|
-
"HEADLINE",
|
383
|
-
"PLAIN",
|
384
|
-
"DESCLINE_TITLE",
|
385
|
-
"DESCLINE",
|
386
|
-
"QUOTE",
|
387
|
-
"INDENT",
|
388
|
-
"DEDENT",
|
389
|
-
"ITEMLIST",
|
390
|
-
"ITEMLISTCONTINUE",
|
391
|
-
"NUMLIST",
|
392
|
-
"TABLELINE",
|
393
|
-
"DUMMY",
|
394
|
-
"$start",
|
395
|
-
"document",
|
396
|
-
"blocks",
|
397
|
-
"block",
|
398
|
-
"header",
|
399
|
-
"paragraph",
|
400
|
-
"quote_block",
|
401
|
-
"itemlist_blocks",
|
402
|
-
"numlist_blocks",
|
403
|
-
"desc_block",
|
404
|
-
"table_block",
|
405
|
-
"headline",
|
406
|
-
"plain_texts",
|
407
|
-
"desclines",
|
408
|
-
"quotes",
|
409
|
-
"itemlist_block",
|
410
|
-
"itemlists",
|
411
|
-
"itemlist_indent_blocks",
|
412
|
-
"itemlistitems",
|
413
|
-
"itemlist_continues",
|
414
|
-
"numlist_block",
|
415
|
-
"numlists",
|
416
|
-
"numlist_indent_blocks",
|
417
|
-
"tablelines" ]
|
418
|
-
|
419
|
-
Racc_debug_parser = false
|
420
|
-
|
421
|
-
##### State transition tables end #####
|
422
|
-
|
423
|
-
# reduce 0 omitted
|
424
|
-
|
425
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 10)
|
426
|
-
def _reduce_1(val, _values)
|
427
|
-
val[0].compact
|
428
|
-
end
|
429
|
-
.,.,
|
430
|
-
|
431
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 12)
|
432
|
-
def _reduce_2(val, _values)
|
433
|
-
val
|
434
|
-
end
|
435
|
-
.,.,
|
436
|
-
|
437
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 13)
|
438
|
-
def _reduce_3(val, _values)
|
439
|
-
[val[0], val[1]].flatten
|
440
|
-
end
|
441
|
-
.,.,
|
442
|
-
|
443
|
-
# reduce 4 omitted
|
444
|
-
|
445
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 16)
|
446
|
-
def _reduce_5(val, _values)
|
447
|
-
val[0]
|
448
|
-
end
|
449
|
-
.,.,
|
450
|
-
|
451
|
-
# reduce 6 omitted
|
452
|
-
|
453
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 18)
|
454
|
-
def _reduce_7(val, _values)
|
455
|
-
ItemList.new(val[0].flatten)
|
456
|
-
end
|
457
|
-
.,.,
|
458
|
-
|
459
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 19)
|
460
|
-
def _reduce_8(val, _values)
|
461
|
-
NumList.new(val[0].flatten)
|
462
|
-
end
|
463
|
-
.,.,
|
464
|
-
|
465
|
-
# reduce 9 omitted
|
466
|
-
|
467
|
-
# reduce 10 omitted
|
468
|
-
|
469
|
-
# reduce 11 omitted
|
470
|
-
|
471
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 23)
|
472
|
-
def _reduce_12(val, _values)
|
473
|
-
WhiteLine.new
|
474
|
-
end
|
475
|
-
.,.,
|
476
|
-
|
477
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 27)
|
478
|
-
def _reduce_13(val, _values)
|
479
|
-
name, val = val[0].split(":",2)
|
480
|
-
if name.nil? or val.nil?
|
481
|
-
else
|
482
|
-
@metadata.update({name.strip.to_sym => val.strip })
|
483
|
-
end
|
484
|
-
nil
|
485
|
-
end
|
486
|
-
.,.,
|
487
|
-
|
488
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 35)
|
489
|
-
def _reduce_14(val, _values)
|
490
|
-
# val[0] is like [level, title, index]
|
491
|
-
title = val[0][1]
|
492
|
-
level = val[0][0]
|
493
|
-
if level == 1
|
494
|
-
@metadata[:subject] ||= title
|
495
|
-
else
|
496
|
-
@head_index.update(level)
|
497
|
-
end
|
498
|
-
|
499
|
-
@index[:head] ||= []
|
500
|
-
@index[:head] << {:title => title, :level => level, :index => @head_index.to_s}
|
501
|
-
HeadLine.new([level, title, @index[:head].size, @head_index.to_s])
|
502
|
-
end
|
503
|
-
.,.,
|
504
|
-
|
505
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 48)
|
506
|
-
def _reduce_15(val, _values)
|
507
|
-
Paragraph.new @inline_parser.parse(val)
|
508
|
-
end
|
509
|
-
.,.,
|
510
|
-
|
511
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 50)
|
512
|
-
def _reduce_16(val, _values)
|
513
|
-
val[0]
|
514
|
-
end
|
515
|
-
.,.,
|
516
|
-
|
517
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 51)
|
518
|
-
def _reduce_17(val, _values)
|
519
|
-
val[0] + val[1]
|
520
|
-
end
|
521
|
-
.,.,
|
522
|
-
|
523
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 55)
|
524
|
-
def _reduce_18(val, _values)
|
525
|
-
if val[1].nil?
|
526
|
-
lines = [Plain.new("")]
|
527
|
-
else
|
528
|
-
lines = @inline_parser.parse(val[1])
|
529
|
-
end
|
530
|
-
Desc.new([val[0], lines])
|
531
|
-
|
532
|
-
end
|
533
|
-
.,.,
|
534
|
-
|
535
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 64)
|
536
|
-
def _reduce_19(val, _values)
|
537
|
-
val[0]
|
538
|
-
end
|
539
|
-
.,.,
|
540
|
-
|
541
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 65)
|
542
|
-
def _reduce_20(val, _values)
|
543
|
-
val[0] + val[1]
|
544
|
-
end
|
545
|
-
.,.,
|
546
|
-
|
547
|
-
# reduce 21 omitted
|
548
|
-
|
549
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 70)
|
550
|
-
def _reduce_22(val, _values)
|
551
|
-
qu = val[0].strip ; Quote.new([qu]) unless qu.empty?
|
552
|
-
end
|
553
|
-
.,.,
|
554
|
-
|
555
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 72)
|
556
|
-
def _reduce_23(val, _values)
|
557
|
-
val[0]
|
558
|
-
end
|
559
|
-
.,.,
|
560
|
-
|
561
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 73)
|
562
|
-
def _reduce_24(val, _values)
|
563
|
-
val[0] + val[1]
|
564
|
-
end
|
565
|
-
.,.,
|
566
|
-
|
567
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 77)
|
568
|
-
def _reduce_25(val, _values)
|
569
|
-
val[0]
|
570
|
-
end
|
571
|
-
.,.,
|
572
|
-
|
573
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 78)
|
574
|
-
def _reduce_26(val, _values)
|
575
|
-
val[0] << val[1]
|
576
|
-
end
|
577
|
-
.,.,
|
578
|
-
|
579
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 80)
|
580
|
-
def _reduce_27(val, _values)
|
581
|
-
val[0]
|
582
|
-
end
|
583
|
-
.,.,
|
584
|
-
|
585
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 81)
|
586
|
-
def _reduce_28(val, _values)
|
587
|
-
val[0]
|
588
|
-
end
|
589
|
-
.,.,
|
590
|
-
|
591
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 83)
|
592
|
-
def _reduce_29(val, _values)
|
593
|
-
val
|
594
|
-
end
|
595
|
-
.,.,
|
596
|
-
|
597
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 85)
|
598
|
-
def _reduce_30(val, _values)
|
599
|
-
[PlainTextBlock.new(@inline_parser.parse(val[0]))]
|
600
|
-
end
|
601
|
-
.,.,
|
602
|
-
|
603
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 86)
|
604
|
-
def _reduce_31(val, _values)
|
605
|
-
val[0] << PlainTextBlock.new(@inline_parser.parse(val[1]))
|
606
|
-
end
|
607
|
-
.,.,
|
608
|
-
|
609
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 88)
|
610
|
-
def _reduce_32(val, _values)
|
611
|
-
val[0]
|
612
|
-
end
|
613
|
-
.,.,
|
614
|
-
|
615
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 89)
|
616
|
-
def _reduce_33(val, _values)
|
617
|
-
val[0] + val[1]
|
618
|
-
end
|
619
|
-
.,.,
|
620
|
-
|
621
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 91)
|
622
|
-
def _reduce_34(val, _values)
|
623
|
-
"\n" + val[0]
|
624
|
-
end
|
625
|
-
.,.,
|
626
|
-
|
627
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 92)
|
628
|
-
def _reduce_35(val, _values)
|
629
|
-
val[0] + "\n" + val[1]
|
630
|
-
end
|
631
|
-
.,.,
|
632
|
-
|
633
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 96)
|
634
|
-
def _reduce_36(val, _values)
|
635
|
-
val[0]
|
636
|
-
end
|
637
|
-
.,.,
|
638
|
-
|
639
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 97)
|
640
|
-
def _reduce_37(val, _values)
|
641
|
-
val[0] << val[1]
|
642
|
-
end
|
643
|
-
.,.,
|
644
|
-
|
645
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 99)
|
646
|
-
def _reduce_38(val, _values)
|
647
|
-
val[0]
|
648
|
-
end
|
649
|
-
.,.,
|
650
|
-
|
651
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 100)
|
652
|
-
def _reduce_39(val, _values)
|
653
|
-
val[0]
|
654
|
-
end
|
655
|
-
.,.,
|
656
|
-
|
657
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 102)
|
658
|
-
def _reduce_40(val, _values)
|
659
|
-
val
|
660
|
-
end
|
661
|
-
.,.,
|
662
|
-
|
663
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 104)
|
664
|
-
def _reduce_41(val, _values)
|
665
|
-
[PlainTextBlock.new(@inline_parser.parse(val[0]))]
|
666
|
-
end
|
667
|
-
.,.,
|
668
|
-
|
669
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 105)
|
670
|
-
def _reduce_42(val, _values)
|
671
|
-
val[0] << PlainTextBlock.new(@inline_parser.parse(val[1]))
|
672
|
-
end
|
673
|
-
.,.,
|
674
|
-
|
675
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 110)
|
676
|
-
def _reduce_43(val, _values)
|
677
|
-
Table.new(val[0])
|
678
|
-
end
|
679
|
-
.,.,
|
680
|
-
|
681
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 112)
|
682
|
-
def _reduce_44(val, _values)
|
683
|
-
val
|
684
|
-
end
|
685
|
-
.,.,
|
686
|
-
|
687
|
-
module_eval(<<'.,.,', 'rafblockparser.ry', 113)
|
688
|
-
def _reduce_45(val, _values)
|
689
|
-
val[0] << val[1]
|
690
|
-
end
|
691
|
-
.,.,
|
692
|
-
|
693
|
-
def _reduce_none(val, _values)
|
694
|
-
val[0]
|
695
|
-
end
|
696
|
-
|
697
|
-
end # class BlockParser
|
698
|
-
|
699
|
-
if __FILE__ == $0
|
700
|
-
raf = BlockParser.new
|
701
|
-
src = $stdin.readlines
|
702
|
-
nodes = raf.parse(src)
|
703
|
-
puts "----- index -----"
|
704
|
-
raf.index.each do |key,val|
|
705
|
-
puts key
|
706
|
-
val.each do |v| p v end
|
707
|
-
end
|
708
|
-
puts "----- info -----"
|
709
|
-
p raf.info
|
710
|
-
puts "----- output -----"
|
711
|
-
nodes.each do |n|
|
712
|
-
puts n.apply
|
713
|
-
end
|
714
|
-
end
|
715
|
-
end # end of module Raf
|