raf 0.0.0 → 0.0.1
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.
- data/COPYING +674 -0
- data/Gemfile.lock +20 -0
- data/History.rdoc +2 -0
- data/LICENSE.txt +11 -17
- data/README.rdoc +2 -13
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bin/raf2html +18 -0
- data/lib/default.css +116 -0
- data/lib/parserutility.rb +18 -0
- data/lib/raf2html.rb +167 -0
- data/lib/raf2html_element.rb +195 -0
- data/lib/rafblockparser.output +670 -0
- data/lib/rafblockparser.ry +356 -0
- data/lib/rafblockparser.tab.rb +717 -0
- data/lib/rafelement.rb +219 -0
- data/lib/rafinlineparser.output +1804 -0
- data/lib/rafinlineparser.ry +451 -0
- data/lib/rafinlineparser.tab.rb +1117 -0
- data/raf.gemspec +118 -0
- data/test/test_descblock.rb +88 -0
- data/test/test_emphasis.rb +76 -0
- data/test/test_erb.rb +23 -0
- data/test/test_footnote.rb +38 -0
- data/test/test_headline.rb +43 -0
- data/test/test_headline_and_itemlist.rb +40 -0
- data/test/test_helper.rb +2 -0
- data/test/test_image.rb +81 -0
- data/test/test_italic.rb +76 -0
- data/test/test_itemlistblock.rb +151 -0
- data/test/test_numlistblock.rb +342 -0
- data/test/test_paragraph.rb +76 -0
- data/test/test_quoteblock.rb +109 -0
- data/test/test_reference.rb +47 -0
- data/test/test_ruby.rb +66 -0
- data/test/test_strike.rb +76 -0
- data/test/test_tableblock.rb +63 -0
- data/test/test_verb.rb +86 -0
- data/test/ts_block.rb +9 -0
- data/test/ts_inline.rb +8 -0
- data/test/ts_rafparser.rb +4 -0
- metadata +67 -12
- data/lib/raf.rb +0 -0
- data/test/test_raf.rb +0 -7
@@ -0,0 +1,717 @@
|
|
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 "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', 118)
|
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
|
+
@info = {}
|
42
|
+
@inline_index = @inline_parser.index
|
43
|
+
@index = {}
|
44
|
+
@head_index = HeadIndex.new
|
45
|
+
end
|
46
|
+
attr_reader :info, :inline_index, :index
|
47
|
+
|
48
|
+
def parse(src)
|
49
|
+
@no = 0
|
50
|
+
@src = src.to_a
|
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
|
+
7, 11, 14, 17, 20, 49, 24, 27, 34, 1,
|
237
|
+
1, 6, 9, 7, 11, 14, 17, 20, 38, 24,
|
238
|
+
27, 40, 1, 37, 6, 9, 37, 6, 1, 27,
|
239
|
+
6, 1, 39, 6, 37, 53, 43, 32, 6, 34,
|
240
|
+
52, 1, 34, 50, 1, 51, 42, 45 ]
|
241
|
+
|
242
|
+
racc_action_check = [
|
243
|
+
0, 0, 0, 0, 0, 33, 0, 0, 5, 0,
|
244
|
+
5, 0, 0, 23, 23, 23, 23, 23, 13, 23,
|
245
|
+
23, 20, 23, 37, 23, 23, 8, 37, 30, 27,
|
246
|
+
8, 27, 19, 27, 47, 47, 22, 1, 47, 46,
|
247
|
+
46, 46, 34, 41, 34, 43, 21, 25 ]
|
248
|
+
|
249
|
+
racc_action_pointer = [
|
250
|
+
-2, 25, nil, nil, nil, -1, nil, nil, 17, nil,
|
251
|
+
nil, nil, nil, 5, nil, nil, nil, nil, nil, 18,
|
252
|
+
14, 41, 36, 11, nil, 39, nil, 20, nil, nil,
|
253
|
+
17, nil, nil, -7, 33, nil, nil, 14, nil, nil,
|
254
|
+
nil, 36, nil, 45, nil, nil, 30, 25, nil, nil,
|
255
|
+
nil, nil, nil, nil ]
|
256
|
+
|
257
|
+
racc_action_default = [
|
258
|
+
-46, -32, -28, -6, -30, -7, -41, -13, -8, -44,
|
259
|
+
-36, -12, -9, -38, -14, -10, -39, -16, -11, -43,
|
260
|
+
-21, -15, -46, -1, -23, -22, -2, -46, -25, -4,
|
261
|
+
-27, -5, -34, -33, -46, -26, -37, -46, -42, -45,
|
262
|
+
-19, -18, -17, -46, -3, -24, -46, -46, -31, -35,
|
263
|
+
-20, 54, -29, -40 ]
|
264
|
+
|
265
|
+
racc_goto_table = [
|
266
|
+
35, 36, 26, 47, 46, 41, 23, 48, 33, 22,
|
267
|
+
nil, 46, nil, 47, nil, nil, nil, nil, nil, nil,
|
268
|
+
nil, nil, nil, nil, nil, 44, nil, nil, nil, nil,
|
269
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
270
|
+
36, 35 ]
|
271
|
+
|
272
|
+
racc_goto_check = [
|
273
|
+
15, 20, 3, 8, 7, 13, 2, 18, 19, 1,
|
274
|
+
nil, 7, nil, 8, nil, nil, nil, nil, nil, nil,
|
275
|
+
nil, nil, nil, nil, nil, 3, nil, nil, nil, nil,
|
276
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
277
|
+
20, 15 ]
|
278
|
+
|
279
|
+
racc_goto_pointer = [
|
280
|
+
nil, 9, 6, 2, nil, nil, nil, -23, -24, nil,
|
281
|
+
nil, nil, nil, -15, nil, -5, nil, nil, -23, 7,
|
282
|
+
-7, nil, nil, nil ]
|
283
|
+
|
284
|
+
racc_goto_default = [
|
285
|
+
nil, nil, nil, nil, 29, 31, 3, 5, 8, 12,
|
286
|
+
15, 18, 21, nil, 25, 28, 30, 2, 4, nil,
|
287
|
+
10, 13, 16, 19 ]
|
288
|
+
|
289
|
+
racc_reduce_table = [
|
290
|
+
0, 0, :racc_error,
|
291
|
+
1, 17, :_reduce_1,
|
292
|
+
1, 18, :_reduce_2,
|
293
|
+
2, 18, :_reduce_3,
|
294
|
+
1, 19, :_reduce_none,
|
295
|
+
1, 19, :_reduce_5,
|
296
|
+
1, 19, :_reduce_none,
|
297
|
+
1, 19, :_reduce_7,
|
298
|
+
1, 19, :_reduce_8,
|
299
|
+
1, 19, :_reduce_none,
|
300
|
+
1, 19, :_reduce_none,
|
301
|
+
1, 19, :_reduce_none,
|
302
|
+
1, 19, :_reduce_12,
|
303
|
+
1, 20, :_reduce_13,
|
304
|
+
1, 27, :_reduce_14,
|
305
|
+
1, 21, :_reduce_15,
|
306
|
+
1, 28, :_reduce_16,
|
307
|
+
2, 28, :_reduce_17,
|
308
|
+
2, 25, :_reduce_18,
|
309
|
+
1, 29, :_reduce_19,
|
310
|
+
2, 29, :_reduce_20,
|
311
|
+
0, 29, :_reduce_none,
|
312
|
+
1, 22, :_reduce_22,
|
313
|
+
1, 30, :_reduce_23,
|
314
|
+
2, 30, :_reduce_24,
|
315
|
+
1, 23, :_reduce_25,
|
316
|
+
2, 23, :_reduce_26,
|
317
|
+
1, 31, :_reduce_27,
|
318
|
+
1, 31, :_reduce_28,
|
319
|
+
3, 33, :_reduce_29,
|
320
|
+
1, 32, :_reduce_30,
|
321
|
+
2, 32, :_reduce_31,
|
322
|
+
1, 34, :_reduce_32,
|
323
|
+
2, 34, :_reduce_33,
|
324
|
+
1, 35, :_reduce_34,
|
325
|
+
2, 35, :_reduce_35,
|
326
|
+
1, 24, :_reduce_36,
|
327
|
+
2, 24, :_reduce_37,
|
328
|
+
1, 36, :_reduce_38,
|
329
|
+
1, 36, :_reduce_39,
|
330
|
+
3, 38, :_reduce_40,
|
331
|
+
1, 37, :_reduce_41,
|
332
|
+
2, 37, :_reduce_42,
|
333
|
+
1, 26, :_reduce_43,
|
334
|
+
1, 39, :_reduce_44,
|
335
|
+
2, 39, :_reduce_45 ]
|
336
|
+
|
337
|
+
racc_reduce_n = 46
|
338
|
+
|
339
|
+
racc_shift_n = 54
|
340
|
+
|
341
|
+
racc_token_table = {
|
342
|
+
false => 0,
|
343
|
+
:error => 1,
|
344
|
+
:HEADER => 2,
|
345
|
+
:WHITELINE => 3,
|
346
|
+
:HEADLINE => 4,
|
347
|
+
:PLAIN => 5,
|
348
|
+
:DESCLINE_TITLE => 6,
|
349
|
+
:DESCLINE => 7,
|
350
|
+
:QUOTE => 8,
|
351
|
+
:INDENT => 9,
|
352
|
+
:DEDENT => 10,
|
353
|
+
:ITEMLIST => 11,
|
354
|
+
:ITEMLISTCONTINUE => 12,
|
355
|
+
:NUMLIST => 13,
|
356
|
+
:TABLELINE => 14,
|
357
|
+
:DUMMY => 15 }
|
358
|
+
|
359
|
+
racc_nt_base = 16
|
360
|
+
|
361
|
+
racc_use_result_var = false
|
362
|
+
|
363
|
+
Racc_arg = [
|
364
|
+
racc_action_table,
|
365
|
+
racc_action_check,
|
366
|
+
racc_action_default,
|
367
|
+
racc_action_pointer,
|
368
|
+
racc_goto_table,
|
369
|
+
racc_goto_check,
|
370
|
+
racc_goto_default,
|
371
|
+
racc_goto_pointer,
|
372
|
+
racc_nt_base,
|
373
|
+
racc_reduce_table,
|
374
|
+
racc_token_table,
|
375
|
+
racc_shift_n,
|
376
|
+
racc_reduce_n,
|
377
|
+
racc_use_result_var ]
|
378
|
+
|
379
|
+
Racc_token_to_s_table = [
|
380
|
+
"$end",
|
381
|
+
"error",
|
382
|
+
"HEADER",
|
383
|
+
"WHITELINE",
|
384
|
+
"HEADLINE",
|
385
|
+
"PLAIN",
|
386
|
+
"DESCLINE_TITLE",
|
387
|
+
"DESCLINE",
|
388
|
+
"QUOTE",
|
389
|
+
"INDENT",
|
390
|
+
"DEDENT",
|
391
|
+
"ITEMLIST",
|
392
|
+
"ITEMLISTCONTINUE",
|
393
|
+
"NUMLIST",
|
394
|
+
"TABLELINE",
|
395
|
+
"DUMMY",
|
396
|
+
"$start",
|
397
|
+
"document",
|
398
|
+
"blocks",
|
399
|
+
"block",
|
400
|
+
"header",
|
401
|
+
"paragraph",
|
402
|
+
"quote_block",
|
403
|
+
"itemlist_blocks",
|
404
|
+
"numlist_blocks",
|
405
|
+
"desc_block",
|
406
|
+
"table_block",
|
407
|
+
"headline",
|
408
|
+
"plain_texts",
|
409
|
+
"desclines",
|
410
|
+
"quotes",
|
411
|
+
"itemlist_block",
|
412
|
+
"itemlists",
|
413
|
+
"itemlist_indent_blocks",
|
414
|
+
"itemlistitems",
|
415
|
+
"itemlist_continues",
|
416
|
+
"numlist_block",
|
417
|
+
"numlists",
|
418
|
+
"numlist_indent_blocks",
|
419
|
+
"tablelines" ]
|
420
|
+
|
421
|
+
Racc_debug_parser = false
|
422
|
+
|
423
|
+
##### State transition tables end #####
|
424
|
+
|
425
|
+
# reduce 0 omitted
|
426
|
+
|
427
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 8)
|
428
|
+
def _reduce_1(val, _values)
|
429
|
+
val[0].compact
|
430
|
+
end
|
431
|
+
.,.,
|
432
|
+
|
433
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 10)
|
434
|
+
def _reduce_2(val, _values)
|
435
|
+
val
|
436
|
+
end
|
437
|
+
.,.,
|
438
|
+
|
439
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 11)
|
440
|
+
def _reduce_3(val, _values)
|
441
|
+
[val[0], val[1]].flatten
|
442
|
+
end
|
443
|
+
.,.,
|
444
|
+
|
445
|
+
# reduce 4 omitted
|
446
|
+
|
447
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 14)
|
448
|
+
def _reduce_5(val, _values)
|
449
|
+
val[0]
|
450
|
+
end
|
451
|
+
.,.,
|
452
|
+
|
453
|
+
# reduce 6 omitted
|
454
|
+
|
455
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 16)
|
456
|
+
def _reduce_7(val, _values)
|
457
|
+
ItemList.new(val[0].flatten)
|
458
|
+
end
|
459
|
+
.,.,
|
460
|
+
|
461
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 17)
|
462
|
+
def _reduce_8(val, _values)
|
463
|
+
NumList.new(val[0].flatten)
|
464
|
+
end
|
465
|
+
.,.,
|
466
|
+
|
467
|
+
# reduce 9 omitted
|
468
|
+
|
469
|
+
# reduce 10 omitted
|
470
|
+
|
471
|
+
# reduce 11 omitted
|
472
|
+
|
473
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 21)
|
474
|
+
def _reduce_12(val, _values)
|
475
|
+
WhiteLine.new
|
476
|
+
end
|
477
|
+
.,.,
|
478
|
+
|
479
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 25)
|
480
|
+
def _reduce_13(val, _values)
|
481
|
+
name, val = val[0].split(":",2)
|
482
|
+
if name.nil? or val.nil?
|
483
|
+
else
|
484
|
+
@info.update({name.strip.to_sym => val.strip })
|
485
|
+
end
|
486
|
+
nil
|
487
|
+
end
|
488
|
+
.,.,
|
489
|
+
|
490
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 33)
|
491
|
+
def _reduce_14(val, _values)
|
492
|
+
# val[0] is like [level, title, index]
|
493
|
+
title = val[0][1]
|
494
|
+
level = val[0][0]
|
495
|
+
if level == 1
|
496
|
+
@info[:subject] ||= title
|
497
|
+
else
|
498
|
+
@head_index.update(level)
|
499
|
+
end
|
500
|
+
|
501
|
+
@index[:head] ||= []
|
502
|
+
@index[:head] << {:title => title, :level => level, :index => @head_index.to_s}
|
503
|
+
HeadLine.new([level, title, @index[:head].size, @head_index.to_s])
|
504
|
+
end
|
505
|
+
.,.,
|
506
|
+
|
507
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 46)
|
508
|
+
def _reduce_15(val, _values)
|
509
|
+
Paragraph.new @inline_parser.parse(val)
|
510
|
+
end
|
511
|
+
.,.,
|
512
|
+
|
513
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 48)
|
514
|
+
def _reduce_16(val, _values)
|
515
|
+
val[0]
|
516
|
+
end
|
517
|
+
.,.,
|
518
|
+
|
519
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 49)
|
520
|
+
def _reduce_17(val, _values)
|
521
|
+
val[0] + val[1]
|
522
|
+
end
|
523
|
+
.,.,
|
524
|
+
|
525
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 53)
|
526
|
+
def _reduce_18(val, _values)
|
527
|
+
if val[1].nil?
|
528
|
+
lines = [Plain.new("")]
|
529
|
+
else
|
530
|
+
lines = @inline_parser.parse(val[1])
|
531
|
+
end
|
532
|
+
Desc.new([val[0], lines])
|
533
|
+
|
534
|
+
end
|
535
|
+
.,.,
|
536
|
+
|
537
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 62)
|
538
|
+
def _reduce_19(val, _values)
|
539
|
+
val[0]
|
540
|
+
end
|
541
|
+
.,.,
|
542
|
+
|
543
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 63)
|
544
|
+
def _reduce_20(val, _values)
|
545
|
+
val[0] + val[1]
|
546
|
+
end
|
547
|
+
.,.,
|
548
|
+
|
549
|
+
# reduce 21 omitted
|
550
|
+
|
551
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 68)
|
552
|
+
def _reduce_22(val, _values)
|
553
|
+
qu = val[0].strip ; Quote.new([qu]) unless qu.empty?
|
554
|
+
end
|
555
|
+
.,.,
|
556
|
+
|
557
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 70)
|
558
|
+
def _reduce_23(val, _values)
|
559
|
+
val[0]
|
560
|
+
end
|
561
|
+
.,.,
|
562
|
+
|
563
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 71)
|
564
|
+
def _reduce_24(val, _values)
|
565
|
+
val[0] + val[1]
|
566
|
+
end
|
567
|
+
.,.,
|
568
|
+
|
569
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 75)
|
570
|
+
def _reduce_25(val, _values)
|
571
|
+
val[0]
|
572
|
+
end
|
573
|
+
.,.,
|
574
|
+
|
575
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 76)
|
576
|
+
def _reduce_26(val, _values)
|
577
|
+
val[0] << val[1]
|
578
|
+
end
|
579
|
+
.,.,
|
580
|
+
|
581
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 78)
|
582
|
+
def _reduce_27(val, _values)
|
583
|
+
val[0]
|
584
|
+
end
|
585
|
+
.,.,
|
586
|
+
|
587
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 79)
|
588
|
+
def _reduce_28(val, _values)
|
589
|
+
val[0]
|
590
|
+
end
|
591
|
+
.,.,
|
592
|
+
|
593
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 81)
|
594
|
+
def _reduce_29(val, _values)
|
595
|
+
val
|
596
|
+
end
|
597
|
+
.,.,
|
598
|
+
|
599
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 83)
|
600
|
+
def _reduce_30(val, _values)
|
601
|
+
[PlainTextBlock.new(@inline_parser.parse(val[0]))]
|
602
|
+
end
|
603
|
+
.,.,
|
604
|
+
|
605
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 84)
|
606
|
+
def _reduce_31(val, _values)
|
607
|
+
val[0] << PlainTextBlock.new(@inline_parser.parse(val[1]))
|
608
|
+
end
|
609
|
+
.,.,
|
610
|
+
|
611
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 86)
|
612
|
+
def _reduce_32(val, _values)
|
613
|
+
val[0]
|
614
|
+
end
|
615
|
+
.,.,
|
616
|
+
|
617
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 87)
|
618
|
+
def _reduce_33(val, _values)
|
619
|
+
val[0] + val[1]
|
620
|
+
end
|
621
|
+
.,.,
|
622
|
+
|
623
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 89)
|
624
|
+
def _reduce_34(val, _values)
|
625
|
+
"\n" + val[0]
|
626
|
+
end
|
627
|
+
.,.,
|
628
|
+
|
629
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 90)
|
630
|
+
def _reduce_35(val, _values)
|
631
|
+
val[0] + "\n" + val[1]
|
632
|
+
end
|
633
|
+
.,.,
|
634
|
+
|
635
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 94)
|
636
|
+
def _reduce_36(val, _values)
|
637
|
+
val[0]
|
638
|
+
end
|
639
|
+
.,.,
|
640
|
+
|
641
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 95)
|
642
|
+
def _reduce_37(val, _values)
|
643
|
+
val[0] << val[1]
|
644
|
+
end
|
645
|
+
.,.,
|
646
|
+
|
647
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 97)
|
648
|
+
def _reduce_38(val, _values)
|
649
|
+
val[0]
|
650
|
+
end
|
651
|
+
.,.,
|
652
|
+
|
653
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 98)
|
654
|
+
def _reduce_39(val, _values)
|
655
|
+
val[0]
|
656
|
+
end
|
657
|
+
.,.,
|
658
|
+
|
659
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 100)
|
660
|
+
def _reduce_40(val, _values)
|
661
|
+
val
|
662
|
+
end
|
663
|
+
.,.,
|
664
|
+
|
665
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 102)
|
666
|
+
def _reduce_41(val, _values)
|
667
|
+
[PlainTextBlock.new(@inline_parser.parse(val[0]))]
|
668
|
+
end
|
669
|
+
.,.,
|
670
|
+
|
671
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 103)
|
672
|
+
def _reduce_42(val, _values)
|
673
|
+
val[0] << PlainTextBlock.new(@inline_parser.parse(val[1]))
|
674
|
+
end
|
675
|
+
.,.,
|
676
|
+
|
677
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 108)
|
678
|
+
def _reduce_43(val, _values)
|
679
|
+
Table.new(val[0])
|
680
|
+
end
|
681
|
+
.,.,
|
682
|
+
|
683
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 110)
|
684
|
+
def _reduce_44(val, _values)
|
685
|
+
val
|
686
|
+
end
|
687
|
+
.,.,
|
688
|
+
|
689
|
+
module_eval(<<'.,.,', 'rafblockparser.ry', 111)
|
690
|
+
def _reduce_45(val, _values)
|
691
|
+
val[0] << val[1]
|
692
|
+
end
|
693
|
+
.,.,
|
694
|
+
|
695
|
+
def _reduce_none(val, _values)
|
696
|
+
val[0]
|
697
|
+
end
|
698
|
+
|
699
|
+
end # class BlockParser
|
700
|
+
|
701
|
+
if __FILE__ == $0
|
702
|
+
raf = BlockParser.new
|
703
|
+
src = $stdin.readlines
|
704
|
+
nodes = raf.parse(src)
|
705
|
+
puts "----- index -----"
|
706
|
+
raf.index.each do |key,val|
|
707
|
+
puts key
|
708
|
+
val.each do |v| p v end
|
709
|
+
end
|
710
|
+
puts "----- info -----"
|
711
|
+
p raf.info
|
712
|
+
puts "----- output -----"
|
713
|
+
nodes.each do |n|
|
714
|
+
puts n.apply
|
715
|
+
end
|
716
|
+
end
|
717
|
+
end # end of module Raf
|