raf-parser 0.2.0

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.
@@ -0,0 +1,415 @@
1
+ # Copyright (C) garin <garin54@gmail.com> 2011
2
+ # See the included file COPYING for details.
3
+ class InlineParser
4
+ token EM_OPEN EM_CLOSE ITALIC_OPEN ITALIC_CLOSE STRIKE_OPEN STRIKE_CLOSE LABEL_OPEN LABEL_CLOSE REFERENCE_OPEN REFERENCE_CLOSE VERB_OPEN VERB_CLOSE ERB_OPEN ERB_CLOSE HERB_OPEN FOOTNOTE_OPEN FOOTNOTE_CLOSE RUBY_OPEN RUBY_CLOSE IMAGE_OPEN IMAGE_CLOSE MANUEDO_OPEN MANUEDO_CLOSE OTHER
5
+ options no_result_var
6
+ rule
7
+ content :
8
+ | elements
9
+
10
+ elements : elements element { val[0].push(val[1]) }
11
+ | element { val }
12
+
13
+ element : emphasis
14
+ | italic
15
+ | strike
16
+ | label
17
+ | reference
18
+ | ruby
19
+ | footnote
20
+ | image
21
+ | verb
22
+ | erb
23
+ | herb
24
+ | manuedo
25
+ | normal_strings
26
+
27
+ # --- inline
28
+ emphasis : EM_OPEN content EM_CLOSE { Emphasis.new(val[1]) }
29
+ italic : ITALIC_OPEN content ITALIC_CLOSE { Italic.new(val[1]) }
30
+ strike : STRIKE_OPEN content STRIKE_CLOSE { Strike.new(val[1]) }
31
+ footnote : FOOTNOTE_OPEN content FOOTNOTE_CLOSE {
32
+ @index[:footnote] ||= []
33
+ @index[:footnote] << {:content => val[1] }
34
+ Footnote.new([val[1], @index[:footnote].size])
35
+ }
36
+
37
+ # --- inline end
38
+
39
+ # --- image
40
+ image_string : OTHER
41
+ | EM_OPEN
42
+ | EM_CLOSE
43
+ | ITALIC_OPEN
44
+ | ITALIC_CLOSE
45
+ | STRIKE_OPEN
46
+ | STRIKE_CLOSE
47
+ | RUBY_OPEN
48
+ | RUBY_CLOSE
49
+ | MANUEDO_OPEN
50
+ | MANUEDO_CLOSE
51
+ | ERB_OPEN
52
+ | ERB_CLOSE
53
+ | HERB_OPEN
54
+ | REFERENCE_OPEN
55
+ | REFERENCE_CLOSE
56
+ | LABEL_OPEN
57
+ | LABEL_CLOSE
58
+ | FOOTNOTE_OPEN
59
+ | FOOTNOTE_CLOSE
60
+ | VERB_OPEN
61
+ | VERB_CLOSE
62
+ | IMAGE_OPEN
63
+
64
+ image_strings : image_strings image_string { val.join }
65
+ | image_string { val[0] }
66
+ image : IMAGE_OPEN image_strings IMAGE_CLOSE { Image.new(val[1]) }
67
+
68
+ # --- image end
69
+ # --- ruby
70
+ ruby_string : OTHER
71
+ | EM_OPEN
72
+ | EM_CLOSE
73
+ | ITALIC_OPEN
74
+ | ITALIC_CLOSE
75
+ | STRIKE_OPEN
76
+ | STRIKE_CLOSE
77
+ | IMAGE_OPEN
78
+ | IMAGE_CLOSE
79
+ | MANUEDO_OPEN
80
+ | MANUEDO_CLOSE
81
+ | ERB_OPEN
82
+ | ERB_CLOSE
83
+ | HERB_OPEN
84
+ | REFERENCE_OPEN
85
+ | REFERENCE_CLOSE
86
+ | LABEL_OPEN
87
+ | LABEL_CLOSE
88
+ | RUBY_OPEN
89
+ | FOOTNOTE_OPEN
90
+ | FOOTNOTE_CLOSE
91
+ | VERB_OPEN
92
+ | VERB_CLOSE
93
+
94
+ ruby_strings : ruby_strings ruby_string { val.join }
95
+ | ruby_string { val[0] }
96
+
97
+ ruby : RUBY_OPEN ruby_strings RUBY_CLOSE {
98
+ base, text = val[1].split("|",2)
99
+ text ||= base
100
+ Ruby.new([base, text])
101
+ }
102
+
103
+ # --- ruby end
104
+ # --- erb
105
+ erb : ERB_OPEN verb_string ERB_CLOSE {
106
+ e = ERB.new("<%= #{val[1]} %>")
107
+ Plain.new(e.result) }
108
+ herb : HERB_OPEN verb_string ERB_CLOSE {
109
+ e = ERB.new("<% #{val[1]} %>")
110
+ Plain.new(e.result) }
111
+ # --- erb end
112
+ # --- manuedo
113
+ manuedo : MANUEDO_OPEN content MANUEDO_CLOSE { Manuedo.new(val[1]) }
114
+
115
+ # --- manuedo end
116
+
117
+ # --- label
118
+ label_string : OTHER { val[0] }
119
+
120
+
121
+ label_strings : label_strings label_string { val.join }
122
+ | label_string { val[0] }
123
+
124
+ label : LABEL_OPEN label_strings LABEL_CLOSE {
125
+ label, title = val[1].split("|",2)
126
+ title ||= label
127
+ @index[:label] ||= []
128
+ @index[:label] << {:title => title }
129
+ Label.new([label.to_code, title, @index[:label].size])
130
+ }
131
+
132
+ # --- labe end
133
+ # --- reference : start
134
+ reference_string : OTHER { val[0] }
135
+
136
+ reference_strings : reference_strings reference_string { val.join }
137
+ | reference_string { val[0] }
138
+
139
+ reference : REFERENCE_OPEN reference_strings REFERENCE_CLOSE {
140
+ title, uri = val[1].split("|",2)
141
+ uri ||= title
142
+ uri = "#" + uri.to_code if uri.gsub(/^\s*https*:\/\//,"") == uri
143
+ Reference.new([title, uri])
144
+ }
145
+ # --- reference : end
146
+ # --- verb
147
+ verb_string : OTHER
148
+ | EM_OPEN
149
+ | EM_CLOSE
150
+ | ITALIC_OPEN
151
+ | ITALIC_CLOSE
152
+ | STRIKE_OPEN
153
+ | STRIKE_CLOSE
154
+ | IMAGE_OPEN
155
+ | IMAGE_CLOSE
156
+ | MANUEDO_OPEN
157
+ | MANUEDO_CLOSE
158
+ | ERB_OPEN
159
+ | ERB_CLOSE
160
+ | HERB_OPEN
161
+ | REFERENCE_OPEN
162
+ | REFERENCE_CLOSE
163
+ | LABEL_OPEN
164
+ | LABEL_CLOSE
165
+ | RUBY_OPEN
166
+ | RUBY_CLOSE
167
+ | FOOTNOTE_OPEN
168
+ | FOOTNOTE_CLOSE
169
+ | VERB_OPEN
170
+
171
+ verb_strings : verb_string
172
+ | verb_strings verb_string { val }
173
+
174
+ verb : VERB_OPEN verb_strings VERB_CLOSE { Verb.new(val[1])}
175
+
176
+ # --- verb end
177
+ # --- normal
178
+ normal_strings : normal_string { Plain.new(val[0]) }
179
+ | normal_strings normal_string { Plain.new([val[0].contents, val[1]]) }
180
+
181
+ normal_string : OTHER { val[0] }
182
+ # --- normal end
183
+
184
+ ---- inner
185
+ include ParserUtility
186
+
187
+ EM_OPEN = '((*'
188
+ EM_OPEN_RE = /\A#{Regexp.quote(EM_OPEN)}/
189
+ EM_CLOSE = '*))'
190
+ EM_CLOSE_RE = /\A#{Regexp.quote(EM_CLOSE)}/
191
+
192
+ ITALIC_OPEN = '((_'
193
+ ITALIC_OPEN_RE = /\A#{Regexp.quote(ITALIC_OPEN)}/
194
+ ITALIC_CLOSE = '_))'
195
+ ITALIC_CLOSE_RE = /\A#{Regexp.quote(ITALIC_CLOSE)}/
196
+
197
+ STRIKE_OPEN = '((-'
198
+ STRIKE_OPEN_RE = /\A#{Regexp.quote(STRIKE_OPEN)}/
199
+ STRIKE_CLOSE = '-))'
200
+ STRIKE_CLOSE_RE = /\A#{Regexp.quote(STRIKE_CLOSE)}/
201
+
202
+ RUBY_OPEN = '((^'
203
+ RUBY_OPEN_RE = /\A#{Regexp.quote(RUBY_OPEN)}/
204
+ RUBY_CLOSE = '^))'
205
+ RUBY_CLOSE_RE = /\A#{Regexp.quote(RUBY_CLOSE)}/
206
+
207
+ FOOTNOTE_OPEN = '((['
208
+ FOOTNOTE_OPEN_RE = /\A#{Regexp.quote(FOOTNOTE_OPEN)}/
209
+ FOOTNOTE_CLOSE = ']))'
210
+ FOOTNOTE_CLOSE_RE = /\A#{Regexp.quote(FOOTNOTE_CLOSE)}/
211
+
212
+ IMAGE_OPEN = '(($'
213
+ IMAGE_OPEN_RE = /\A#{Regexp.quote(IMAGE_OPEN)}/
214
+ IMAGE_CLOSE = '$))'
215
+ IMAGE_CLOSE_RE = /\A#{Regexp.quote(IMAGE_CLOSE)}/
216
+
217
+ LABEL_OPEN = '((>'
218
+ LABEL_OPEN_RE = /\A#{Regexp.quote(LABEL_OPEN)}/
219
+ LABEL_CLOSE = '<))'
220
+ LABEL_CLOSE_RE = /\A#{Regexp.quote(LABEL_CLOSE)}/
221
+
222
+ LABEL_HTML_OPEN = '((&gt;'
223
+ LABEL_HTML_OPEN_RE = /\A#{Regexp.quote(LABEL_HTML_OPEN)}/
224
+ LABEL_HTML_CLOSE = '&lt;))'
225
+ LABEL_HTML_CLOSE_RE = /\A#{Regexp.quote(LABEL_HTML_CLOSE)}/
226
+
227
+ REFERENCE_OPEN = '((<'
228
+ REFERENCE_OPEN_RE = /\A#{Regexp.quote(REFERENCE_OPEN)}/
229
+ REFERENCE_CLOSE = '>))'
230
+ REFERENCE_CLOSE_RE = /\A#{Regexp.quote(REFERENCE_CLOSE)}/
231
+
232
+ REFERENCE_HTML_OPEN = '((<'
233
+ REFERENCE_HTML_OPEN_RE = /\A#{Regexp.quote(REFERENCE_HTML_OPEN)}/
234
+ REFERENCE_HTML_CLOSE = '>))'
235
+ REFERENCE_HTML_CLOSE_RE = /\A#{Regexp.quote(REFERENCE_HTML_CLOSE)}/
236
+
237
+ VERB_OPEN = "(('"
238
+ VERB_OPEN_RE = /\A#{Regexp.quote(VERB_OPEN)}/
239
+ VERB_CLOSE = "'))"
240
+ VERB_CLOSE_RE = /\A#{Regexp.quote(VERB_CLOSE)}/
241
+
242
+ MANUEDO_OPEN = "((/"
243
+ MANUEDO_OPEN_RE = /\A#{Regexp.quote(MANUEDO_OPEN)}/
244
+ MANUEDO_CLOSE = "/))"
245
+ MANUEDO_CLOSE_RE = /\A#{Regexp.quote(MANUEDO_CLOSE)}/
246
+
247
+ ERB_OPEN = "<%="
248
+ ERB_OPEN_RE = /\A#{Regexp.quote(ERB_OPEN)}/
249
+ ERB_CLOSE = "%>"
250
+ ERB_CLOSE_RE = /\A#{Regexp.quote(ERB_CLOSE)}/
251
+
252
+ HERB_OPEN = "<%"
253
+ HERB_OPEN_RE = /\A#{Regexp.quote(HERB_OPEN)}/
254
+
255
+ # URL = "URL:"
256
+ # URL_RE = /\A#{Regexp.quote(URL)}/
257
+
258
+ #other_re_mode = Regexp::EXTENDED
259
+ other_re_mode = Regexp::MULTILINE
260
+ OTHER_RE = Regexp.new(
261
+ "\\A.+?(?=#{Regexp.quote(EM_OPEN)}|#{Regexp.quote(EM_CLOSE)}|#{Regexp.quote(ITALIC_OPEN)}|#{Regexp.quote(ITALIC_CLOSE)}|#{Regexp.quote(STRIKE_OPEN)}|#{Regexp.quote(STRIKE_CLOSE)}|#{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|#{Regexp.quote(RUBY_OPEN)}|#{Regexp.quote(RUBY_CLOSE)}|#{Regexp.quote(IMAGE_OPEN)}|#{Regexp.quote(IMAGE_CLOSE)}|#{Regexp.quote(LABEL_OPEN)}|#{Regexp.quote(LABEL_CLOSE)}|#{Regexp.quote(LABEL_HTML_OPEN)}|#{Regexp.quote(LABEL_HTML_CLOSE)}|#{Regexp.quote(REFERENCE_OPEN)}|#{Regexp.quote(REFERENCE_CLOSE)}|#{Regexp.quote(REFERENCE_HTML_OPEN)}|#{Regexp.quote(REFERENCE_HTML_CLOSE)}|#{Regexp.quote(MANUEDO_OPEN)}|#{Regexp.quote(MANUEDO_CLOSE)}|#{Regexp.quote(VERB_OPEN)}|#{Regexp.quote(VERB_CLOSE)}|#{Regexp.quote(ERB_OPEN)}|#{Regexp.quote(ERB_CLOSE)}|#{Regexp.quote(HERB_OPEN)})", other_re_mode)
262
+
263
+ def parse(src)
264
+ @src = StringScanner.new(Array(src).join)
265
+ @pre = ""
266
+ @@yydebug = false
267
+ @view_token_type = false
268
+ do_parse
269
+ end
270
+ def initialize
271
+ @index = {}
272
+ end
273
+ attr_reader :index
274
+
275
+ def next_token
276
+ return [false, false] if @src.eos?
277
+ if ret = @src.scan(EM_OPEN_RE)
278
+ puts "i: EM_OPEN: #{ret}" if @view_token_type
279
+ @pre << ret
280
+ [:EM_OPEN, ret]
281
+ elsif ret = @src.scan(EM_CLOSE_RE)
282
+ puts "i: EM_CLOSE: #{ret}" if @view_token_type
283
+ @pre << ret
284
+ [:EM_CLOSE, ret]
285
+ elsif ret = @src.scan(ITALIC_OPEN_RE)
286
+ puts "i: ITALIC_OPEN: #{ret}" if @view_token_type
287
+ @pre << ret
288
+ [:ITALIC_OPEN, ret]
289
+ elsif ret = @src.scan(ITALIC_CLOSE_RE)
290
+ puts "i: ITALIC_CLOSE: #{ret}" if @view_token_type
291
+ @pre << ret
292
+ [:ITALIC_CLOSE, ret]
293
+ elsif ret = @src.scan(STRIKE_OPEN_RE)
294
+ @pre << ret
295
+ puts "i: STRIKE_OPEN: #{ret}" if @view_token_type
296
+ [:STRIKE_OPEN, ret]
297
+ elsif ret = @src.scan(STRIKE_CLOSE_RE)
298
+ @pre << ret
299
+ puts "i: STRIKE_CLOSE: #{ret}" if @view_token_type
300
+ [:STRIKE_CLOSE, ret]
301
+ elsif ret = @src.scan(LABEL_OPEN_RE)
302
+ @pre << ret
303
+ puts "i: LABEL_OPEN: #{ret}" if @view_token_type
304
+ [:LABEL_OPEN, ret]
305
+ elsif ret = @src.scan(LABEL_CLOSE_RE)
306
+ puts "i: LABEL_CLOSE: #{ret}" if @view_token_type
307
+ @pre << ret
308
+ [:LABEL_CLOSE, ret]
309
+ elsif ret = @src.scan(LABEL_HTML_OPEN_RE)
310
+ @pre << ret
311
+ puts "i: LABEL_OPEN: #{ret}" if @view_token_type
312
+ [:LABEL_OPEN, ret]
313
+ elsif ret = @src.scan(LABEL_HTML_CLOSE_RE)
314
+ puts "i: LABEL_CLOSE: #{ret}" if @view_token_type
315
+ @pre << ret
316
+ [:LABEL_CLOSE, ret]
317
+ elsif ret = @src.scan(REFERENCE_OPEN_RE)
318
+ puts "i: REFERENCE_OPEN: #{ret}" if @view_token_type
319
+ @pre << ret
320
+ [:REFERENCE_OPEN, ret]
321
+ elsif ret = @src.scan(REFERENCE_CLOSE_RE)
322
+ puts "i: REFERENCE_CLOSE: #{ret}" if @view_token_type
323
+ @pre << ret
324
+ [:REFERENCE_CLOSE, ret]
325
+ elsif ret = @src.scan(REFERENCE_HTML_OPEN_RE)
326
+ puts "i: REFERENCE_HTML_OPEN: #{ret}" if @view_token_type
327
+ @pre << ret
328
+ [:REFERENCE_OPEN, ret]
329
+ elsif ret = @src.scan(REFERENCE_HTML_CLOSE_RE)
330
+ puts "i: REFERENCE_HTML_CLOSE: #{ret}" if @view_token_type
331
+ @pre << ret
332
+ [:REFERENCE_CLOSE, ret]
333
+ elsif ret = @src.scan(VERB_OPEN_RE)
334
+ puts "i: VERB_OPEN: #{ret}" if @view_token_type
335
+ @pre << ret
336
+ [:VERB_OPEN, ret]
337
+ elsif ret = @src.scan(VERB_CLOSE_RE)
338
+ puts "i: VERB_CLOSE: #{ret}" if @view_token_type
339
+ @pre << ret
340
+ [:VERB_CLOSE, ret]
341
+ elsif ret = @src.scan(RUBY_OPEN_RE)
342
+ puts "i: RUBY_OPEN: #{ret}" if @view_token_type
343
+ @pre << ret
344
+ [:RUBY_OPEN, ret]
345
+ elsif ret = @src.scan(RUBY_CLOSE_RE)
346
+ puts "i: RUBY_CLOSE: #{ret}" if @view_token_type
347
+ @pre << ret
348
+ [:RUBY_CLOSE, ret]
349
+ elsif ret = @src.scan(FOOTNOTE_OPEN_RE)
350
+ puts "i: FOOTNOTE_OPEN: #{ret}" if @view_token_type
351
+ @pre << ret
352
+ [:FOOTNOTE_OPEN, ret]
353
+ elsif ret = @src.scan(FOOTNOTE_CLOSE_RE)
354
+ puts "i: FOOTNOTE_CLOSE: #{ret}" if @view_token_type
355
+ @pre << ret
356
+ [:FOOTNOTE_CLOSE, ret]
357
+ elsif ret = @src.scan(IMAGE_OPEN_RE)
358
+ puts "i: IMAGE_OPEN: #{ret}" if @view_token_type
359
+ @pre << ret
360
+ [:IMAGE_OPEN, ret]
361
+ elsif ret = @src.scan(IMAGE_CLOSE_RE)
362
+ puts "i: IMAGE_CLOSE: #{ret}" if @view_token_type
363
+ @pre << ret
364
+ [:IMAGE_CLOSE, ret]
365
+ elsif ret = @src.scan(MANUEDO_OPEN_RE)
366
+ puts "i: MANUEDO_OPEN: #{ret}" if @view_token_type
367
+ @pre << ret
368
+ [:MANUEDO_OPEN, ret]
369
+ elsif ret = @src.scan(MANUEDO_CLOSE_RE)
370
+ puts "i: MANUED_CLOSE: #{ret}" if @view_token_type
371
+ @pre << ret
372
+ [:MANUEDO_CLOSE, ret]
373
+ elsif ret = @src.scan(ERB_OPEN_RE)
374
+ puts "i: ERB_OPEN: #{ret}" if @view_token_type
375
+ @pre << ret
376
+ [:ERB_OPEN, ret]
377
+ elsif ret = @src.scan(ERB_CLOSE_RE)
378
+ puts "i: ERB_CLOSE: #{ret}" if @view_token_type
379
+ @pre << ret
380
+ [:ERB_CLOSE, ret]
381
+ elsif ret = @src.scan(HERB_OPEN_RE)
382
+ puts "i: HERB_OPEN: #{ret}" if @view_token_type
383
+ @pre << ret
384
+ [:HERB_OPEN, ret]
385
+ elsif ret = @src.scan(OTHER_RE)
386
+ puts "i: OTHER_RE: #{ret}" if @view_token_type
387
+ @pre << ret
388
+ [:OTHER, ret]
389
+ else
390
+ puts "i: OTHER_RE(else): #{ret}" if @view_token_type
391
+ ret = @src.rest
392
+ @pre << ret
393
+ @src.terminate
394
+ [:OTHER, ret]
395
+ end
396
+ end
397
+
398
+ ---- header
399
+ require "parserutility"
400
+ require 'strscan'
401
+ require 'erb'
402
+ require 'rafelement'
403
+
404
+ module Raf
405
+ ---- footer
406
+ if __FILE__ == $0
407
+ raf = InlineParser.new
408
+ src = $stdin.readline
409
+ nodes = raf.parse(src)
410
+ puts "----- output -----"
411
+ nodes.each do |n|
412
+ puts n.apply
413
+ end
414
+ end
415
+ end # end of module Raf
@@ -0,0 +1,972 @@
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 'strscan'
11
+ require 'erb'
12
+ require 'rafelement'
13
+
14
+ module Raf
15
+ class InlineParser < Racc::Parser
16
+
17
+ module_eval(<<'...end rafinlineparser.ry/module_eval...', 'rafinlineparser.ry', 185)
18
+ include ParserUtility
19
+
20
+ EM_OPEN = '((*'
21
+ EM_OPEN_RE = /\A#{Regexp.quote(EM_OPEN)}/
22
+ EM_CLOSE = '*))'
23
+ EM_CLOSE_RE = /\A#{Regexp.quote(EM_CLOSE)}/
24
+
25
+ ITALIC_OPEN = '((_'
26
+ ITALIC_OPEN_RE = /\A#{Regexp.quote(ITALIC_OPEN)}/
27
+ ITALIC_CLOSE = '_))'
28
+ ITALIC_CLOSE_RE = /\A#{Regexp.quote(ITALIC_CLOSE)}/
29
+
30
+ STRIKE_OPEN = '((-'
31
+ STRIKE_OPEN_RE = /\A#{Regexp.quote(STRIKE_OPEN)}/
32
+ STRIKE_CLOSE = '-))'
33
+ STRIKE_CLOSE_RE = /\A#{Regexp.quote(STRIKE_CLOSE)}/
34
+
35
+ RUBY_OPEN = '((^'
36
+ RUBY_OPEN_RE = /\A#{Regexp.quote(RUBY_OPEN)}/
37
+ RUBY_CLOSE = '^))'
38
+ RUBY_CLOSE_RE = /\A#{Regexp.quote(RUBY_CLOSE)}/
39
+
40
+ FOOTNOTE_OPEN = '((['
41
+ FOOTNOTE_OPEN_RE = /\A#{Regexp.quote(FOOTNOTE_OPEN)}/
42
+ FOOTNOTE_CLOSE = ']))'
43
+ FOOTNOTE_CLOSE_RE = /\A#{Regexp.quote(FOOTNOTE_CLOSE)}/
44
+
45
+ IMAGE_OPEN = '(($'
46
+ IMAGE_OPEN_RE = /\A#{Regexp.quote(IMAGE_OPEN)}/
47
+ IMAGE_CLOSE = '$))'
48
+ IMAGE_CLOSE_RE = /\A#{Regexp.quote(IMAGE_CLOSE)}/
49
+
50
+ LABEL_OPEN = '((>'
51
+ LABEL_OPEN_RE = /\A#{Regexp.quote(LABEL_OPEN)}/
52
+ LABEL_CLOSE = '<))'
53
+ LABEL_CLOSE_RE = /\A#{Regexp.quote(LABEL_CLOSE)}/
54
+
55
+ LABEL_HTML_OPEN = '((&gt;'
56
+ LABEL_HTML_OPEN_RE = /\A#{Regexp.quote(LABEL_HTML_OPEN)}/
57
+ LABEL_HTML_CLOSE = '&lt;))'
58
+ LABEL_HTML_CLOSE_RE = /\A#{Regexp.quote(LABEL_HTML_CLOSE)}/
59
+
60
+ REFERENCE_OPEN = '((<'
61
+ REFERENCE_OPEN_RE = /\A#{Regexp.quote(REFERENCE_OPEN)}/
62
+ REFERENCE_CLOSE = '>))'
63
+ REFERENCE_CLOSE_RE = /\A#{Regexp.quote(REFERENCE_CLOSE)}/
64
+
65
+ REFERENCE_HTML_OPEN = '((<'
66
+ REFERENCE_HTML_OPEN_RE = /\A#{Regexp.quote(REFERENCE_HTML_OPEN)}/
67
+ REFERENCE_HTML_CLOSE = '>))'
68
+ REFERENCE_HTML_CLOSE_RE = /\A#{Regexp.quote(REFERENCE_HTML_CLOSE)}/
69
+
70
+ VERB_OPEN = "(('"
71
+ VERB_OPEN_RE = /\A#{Regexp.quote(VERB_OPEN)}/
72
+ VERB_CLOSE = "'))"
73
+ VERB_CLOSE_RE = /\A#{Regexp.quote(VERB_CLOSE)}/
74
+
75
+ MANUEDO_OPEN = "((/"
76
+ MANUEDO_OPEN_RE = /\A#{Regexp.quote(MANUEDO_OPEN)}/
77
+ MANUEDO_CLOSE = "/))"
78
+ MANUEDO_CLOSE_RE = /\A#{Regexp.quote(MANUEDO_CLOSE)}/
79
+
80
+ ERB_OPEN = "<%="
81
+ ERB_OPEN_RE = /\A#{Regexp.quote(ERB_OPEN)}/
82
+ ERB_CLOSE = "%>"
83
+ ERB_CLOSE_RE = /\A#{Regexp.quote(ERB_CLOSE)}/
84
+
85
+ HERB_OPEN = "<%"
86
+ HERB_OPEN_RE = /\A#{Regexp.quote(HERB_OPEN)}/
87
+
88
+ # URL = "URL:"
89
+ # URL_RE = /\A#{Regexp.quote(URL)}/
90
+
91
+ #other_re_mode = Regexp::EXTENDED
92
+ other_re_mode = Regexp::MULTILINE
93
+ OTHER_RE = Regexp.new(
94
+ "\\A.+?(?=#{Regexp.quote(EM_OPEN)}|#{Regexp.quote(EM_CLOSE)}|#{Regexp.quote(ITALIC_OPEN)}|#{Regexp.quote(ITALIC_CLOSE)}|#{Regexp.quote(STRIKE_OPEN)}|#{Regexp.quote(STRIKE_CLOSE)}|#{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|#{Regexp.quote(RUBY_OPEN)}|#{Regexp.quote(RUBY_CLOSE)}|#{Regexp.quote(IMAGE_OPEN)}|#{Regexp.quote(IMAGE_CLOSE)}|#{Regexp.quote(LABEL_OPEN)}|#{Regexp.quote(LABEL_CLOSE)}|#{Regexp.quote(LABEL_HTML_OPEN)}|#{Regexp.quote(LABEL_HTML_CLOSE)}|#{Regexp.quote(REFERENCE_OPEN)}|#{Regexp.quote(REFERENCE_CLOSE)}|#{Regexp.quote(REFERENCE_HTML_OPEN)}|#{Regexp.quote(REFERENCE_HTML_CLOSE)}|#{Regexp.quote(MANUEDO_OPEN)}|#{Regexp.quote(MANUEDO_CLOSE)}|#{Regexp.quote(VERB_OPEN)}|#{Regexp.quote(VERB_CLOSE)}|#{Regexp.quote(ERB_OPEN)}|#{Regexp.quote(ERB_CLOSE)}|#{Regexp.quote(HERB_OPEN)})", other_re_mode)
95
+
96
+ def parse(src)
97
+ @src = StringScanner.new(Array(src).join)
98
+ @pre = ""
99
+ @@yydebug = false
100
+ @view_token_type = false
101
+ do_parse
102
+ end
103
+ def initialize
104
+ @index = {}
105
+ end
106
+ attr_reader :index
107
+
108
+ def next_token
109
+ return [false, false] if @src.eos?
110
+ if ret = @src.scan(EM_OPEN_RE)
111
+ puts "i: EM_OPEN: #{ret}" if @view_token_type
112
+ @pre << ret
113
+ [:EM_OPEN, ret]
114
+ elsif ret = @src.scan(EM_CLOSE_RE)
115
+ puts "i: EM_CLOSE: #{ret}" if @view_token_type
116
+ @pre << ret
117
+ [:EM_CLOSE, ret]
118
+ elsif ret = @src.scan(ITALIC_OPEN_RE)
119
+ puts "i: ITALIC_OPEN: #{ret}" if @view_token_type
120
+ @pre << ret
121
+ [:ITALIC_OPEN, ret]
122
+ elsif ret = @src.scan(ITALIC_CLOSE_RE)
123
+ puts "i: ITALIC_CLOSE: #{ret}" if @view_token_type
124
+ @pre << ret
125
+ [:ITALIC_CLOSE, ret]
126
+ elsif ret = @src.scan(STRIKE_OPEN_RE)
127
+ @pre << ret
128
+ puts "i: STRIKE_OPEN: #{ret}" if @view_token_type
129
+ [:STRIKE_OPEN, ret]
130
+ elsif ret = @src.scan(STRIKE_CLOSE_RE)
131
+ @pre << ret
132
+ puts "i: STRIKE_CLOSE: #{ret}" if @view_token_type
133
+ [:STRIKE_CLOSE, ret]
134
+ elsif ret = @src.scan(LABEL_OPEN_RE)
135
+ @pre << ret
136
+ puts "i: LABEL_OPEN: #{ret}" if @view_token_type
137
+ [:LABEL_OPEN, ret]
138
+ elsif ret = @src.scan(LABEL_CLOSE_RE)
139
+ puts "i: LABEL_CLOSE: #{ret}" if @view_token_type
140
+ @pre << ret
141
+ [:LABEL_CLOSE, ret]
142
+ elsif ret = @src.scan(LABEL_HTML_OPEN_RE)
143
+ @pre << ret
144
+ puts "i: LABEL_OPEN: #{ret}" if @view_token_type
145
+ [:LABEL_OPEN, ret]
146
+ elsif ret = @src.scan(LABEL_HTML_CLOSE_RE)
147
+ puts "i: LABEL_CLOSE: #{ret}" if @view_token_type
148
+ @pre << ret
149
+ [:LABEL_CLOSE, ret]
150
+ elsif ret = @src.scan(REFERENCE_OPEN_RE)
151
+ puts "i: REFERENCE_OPEN: #{ret}" if @view_token_type
152
+ @pre << ret
153
+ [:REFERENCE_OPEN, ret]
154
+ elsif ret = @src.scan(REFERENCE_CLOSE_RE)
155
+ puts "i: REFERENCE_CLOSE: #{ret}" if @view_token_type
156
+ @pre << ret
157
+ [:REFERENCE_CLOSE, ret]
158
+ elsif ret = @src.scan(REFERENCE_HTML_OPEN_RE)
159
+ puts "i: REFERENCE_HTML_OPEN: #{ret}" if @view_token_type
160
+ @pre << ret
161
+ [:REFERENCE_OPEN, ret]
162
+ elsif ret = @src.scan(REFERENCE_HTML_CLOSE_RE)
163
+ puts "i: REFERENCE_HTML_CLOSE: #{ret}" if @view_token_type
164
+ @pre << ret
165
+ [:REFERENCE_CLOSE, ret]
166
+ elsif ret = @src.scan(VERB_OPEN_RE)
167
+ puts "i: VERB_OPEN: #{ret}" if @view_token_type
168
+ @pre << ret
169
+ [:VERB_OPEN, ret]
170
+ elsif ret = @src.scan(VERB_CLOSE_RE)
171
+ puts "i: VERB_CLOSE: #{ret}" if @view_token_type
172
+ @pre << ret
173
+ [:VERB_CLOSE, ret]
174
+ elsif ret = @src.scan(RUBY_OPEN_RE)
175
+ puts "i: RUBY_OPEN: #{ret}" if @view_token_type
176
+ @pre << ret
177
+ [:RUBY_OPEN, ret]
178
+ elsif ret = @src.scan(RUBY_CLOSE_RE)
179
+ puts "i: RUBY_CLOSE: #{ret}" if @view_token_type
180
+ @pre << ret
181
+ [:RUBY_CLOSE, ret]
182
+ elsif ret = @src.scan(FOOTNOTE_OPEN_RE)
183
+ puts "i: FOOTNOTE_OPEN: #{ret}" if @view_token_type
184
+ @pre << ret
185
+ [:FOOTNOTE_OPEN, ret]
186
+ elsif ret = @src.scan(FOOTNOTE_CLOSE_RE)
187
+ puts "i: FOOTNOTE_CLOSE: #{ret}" if @view_token_type
188
+ @pre << ret
189
+ [:FOOTNOTE_CLOSE, ret]
190
+ elsif ret = @src.scan(IMAGE_OPEN_RE)
191
+ puts "i: IMAGE_OPEN: #{ret}" if @view_token_type
192
+ @pre << ret
193
+ [:IMAGE_OPEN, ret]
194
+ elsif ret = @src.scan(IMAGE_CLOSE_RE)
195
+ puts "i: IMAGE_CLOSE: #{ret}" if @view_token_type
196
+ @pre << ret
197
+ [:IMAGE_CLOSE, ret]
198
+ elsif ret = @src.scan(MANUEDO_OPEN_RE)
199
+ puts "i: MANUEDO_OPEN: #{ret}" if @view_token_type
200
+ @pre << ret
201
+ [:MANUEDO_OPEN, ret]
202
+ elsif ret = @src.scan(MANUEDO_CLOSE_RE)
203
+ puts "i: MANUED_CLOSE: #{ret}" if @view_token_type
204
+ @pre << ret
205
+ [:MANUEDO_CLOSE, ret]
206
+ elsif ret = @src.scan(ERB_OPEN_RE)
207
+ puts "i: ERB_OPEN: #{ret}" if @view_token_type
208
+ @pre << ret
209
+ [:ERB_OPEN, ret]
210
+ elsif ret = @src.scan(ERB_CLOSE_RE)
211
+ puts "i: ERB_CLOSE: #{ret}" if @view_token_type
212
+ @pre << ret
213
+ [:ERB_CLOSE, ret]
214
+ elsif ret = @src.scan(HERB_OPEN_RE)
215
+ puts "i: HERB_OPEN: #{ret}" if @view_token_type
216
+ @pre << ret
217
+ [:HERB_OPEN, ret]
218
+ elsif ret = @src.scan(OTHER_RE)
219
+ puts "i: OTHER_RE: #{ret}" if @view_token_type
220
+ @pre << ret
221
+ [:OTHER, ret]
222
+ else
223
+ puts "i: OTHER_RE(else): #{ret}" if @view_token_type
224
+ ret = @src.rest
225
+ @pre << ret
226
+ @src.terminate
227
+ [:OTHER, ret]
228
+ end
229
+ end
230
+
231
+ ...end rafinlineparser.ry/module_eval...
232
+ ##### State transition tables begin ###
233
+
234
+ racc_action_table = [
235
+ 17, 31, 18, 124, 19, 125, 26, 126, 27, 30,
236
+ 28, 123, 23, 131, 24, 20, 132, 22, 133, 21,
237
+ 114, 25, 122, 30, 64, 65, 66, 67, 68, 69,
238
+ 79, 80, 77, 78, 84, 85, 74, 75, 76, 82,
239
+ 83, 81, 130, 70, 71, 72, 73, 63, 17, 117,
240
+ 18, nil, 19, nil, 26, nil, 27, nil, 28, nil,
241
+ 23, nil, 24, 20, nil, 22, nil, 21, nil, 25,
242
+ nil, 30, 39, 40, 41, 42, 43, 44, 54, 55,
243
+ 52, 53, 58, 59, 49, 50, 51, 56, 57, 45,
244
+ 46, 60, 128, 47, 48, 38, 17, nil, 18, nil,
245
+ 19, nil, 26, nil, 27, 135, 28, nil, 23, 137,
246
+ 24, 20, 17, 22, 18, 21, 19, 25, 26, 30,
247
+ 27, 114, 28, 117, 23, nil, 24, 20, 17, 22,
248
+ 18, 21, 19, 25, 26, 30, 27, nil, 28, nil,
249
+ 23, nil, 24, 20, 17, 22, 18, 21, 19, 25,
250
+ 26, 30, 27, nil, 28, nil, 23, nil, 24, 20,
251
+ nil, 22, nil, 21, nil, 25, nil, 30, 39, 40,
252
+ 41, 42, 43, 44, 54, 55, 52, 53, 58, 59,
253
+ 49, 50, 51, 56, 57, 45, 46, 60, nil, 47,
254
+ 48, 38, 64, 65, 66, 67, 68, 69, 79, 80,
255
+ 77, 78, 84, 85, 74, 75, 76, 82, 83, 81,
256
+ nil, 70, 71, 72, 73, 63, 90, 91, 92, 93,
257
+ 94, 95, 105, 106, 103, 104, 111, nil, 100, 101,
258
+ 102, 109, 110, 107, 108, 96, 97, 98, 99, 89,
259
+ 90, 91, 92, 93, 94, 95, 105, 106, 103, 104,
260
+ 111, nil, 100, 101, 102, 109, 110, 107, 108, 96,
261
+ 97, 98, 99, 89, 17, nil, 18, nil, 19, nil,
262
+ 26, nil, 27, nil, 28, nil, 23, nil, 24, 20,
263
+ nil, 22, nil, 21, nil, 25, nil, 30, 90, 91,
264
+ 92, 93, 94, 95, 105, 106, 103, 104, 111, nil,
265
+ 100, 101, 102, 109, 110, 107, 108, 96, 97, 98,
266
+ 99, 89, 90, 91, 92, 93, 94, 95, 105, 106,
267
+ 103, 104, 111, 139, 100, 101, 102, 109, 110, 107,
268
+ 108, 96, 97, 98, 99, 89 ]
269
+
270
+ racc_action_check = [
271
+ 0, 1, 0, 35, 0, 36, 0, 37, 0, 16,
272
+ 0, 34, 0, 88, 0, 0, 112, 0, 113, 0,
273
+ 26, 0, 31, 0, 86, 86, 86, 86, 86, 86,
274
+ 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
275
+ 86, 86, 86, 86, 86, 86, 86, 86, 2, 27,
276
+ 2, nil, 2, nil, 2, nil, 2, nil, 2, nil,
277
+ 2, nil, 2, 2, nil, 2, nil, 2, nil, 2,
278
+ nil, 2, 61, 61, 61, 61, 61, 61, 61, 61,
279
+ 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
280
+ 61, 61, 61, 61, 61, 61, 17, nil, 17, nil,
281
+ 17, nil, 17, nil, 17, 115, 17, nil, 17, 118,
282
+ 17, 17, 18, 17, 18, 17, 18, 17, 18, 17,
283
+ 18, 115, 18, 118, 18, nil, 18, 18, 19, 18,
284
+ 19, 18, 19, 18, 19, 18, 19, nil, 19, nil,
285
+ 19, nil, 19, 19, 20, 19, 20, 19, 20, 19,
286
+ 20, 19, 20, nil, 20, nil, 20, nil, 20, 20,
287
+ nil, 20, nil, 20, nil, 20, nil, 20, 21, 21,
288
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
289
+ 21, 21, 21, 21, 21, 21, 21, 21, nil, 21,
290
+ 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
291
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
292
+ nil, 22, 22, 22, 22, 22, 23, 23, 23, 23,
293
+ 23, 23, 23, 23, 23, 23, 23, nil, 23, 23,
294
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
295
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
296
+ 24, nil, 24, 24, 24, 24, 24, 24, 24, 24,
297
+ 24, 24, 24, 24, 25, nil, 25, nil, 25, nil,
298
+ 25, nil, 25, nil, 25, nil, 25, nil, 25, 25,
299
+ nil, 25, nil, 25, nil, 25, nil, 25, 28, 28,
300
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, nil,
301
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
302
+ 28, 28, 121, 121, 121, 121, 121, 121, 121, 121,
303
+ 121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
304
+ 121, 121, 121, 121, 121, 121 ]
305
+
306
+ racc_action_pointer = [
307
+ -2, 1, 46, nil, nil, nil, nil, nil, nil, nil,
308
+ nil, nil, nil, nil, nil, nil, -16, 94, 110, 126,
309
+ 142, 166, 190, 214, 238, 262, -5, 24, 286, nil,
310
+ nil, 22, nil, nil, 8, -2, -2, -11, nil, nil,
311
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
312
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
313
+ nil, 70, nil, nil, nil, nil, nil, nil, nil, nil,
314
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
315
+ nil, nil, nil, nil, nil, nil, 22, nil, -2, nil,
316
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
317
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
318
+ nil, nil, 1, -6, nil, 96, nil, nil, 98, nil,
319
+ nil, 310, nil, nil, nil, nil, nil, nil, nil, nil,
320
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ]
321
+
322
+ racc_action_default = [
323
+ -1, -114, -2, -4, -5, -6, -7, -8, -9, -10,
324
+ -11, -12, -13, -14, -15, -16, -17, -1, -1, -1,
325
+ -1, -114, -114, -114, -114, -1, -114, -114, -114, -111,
326
+ -113, -114, -3, -112, -114, -114, -114, -114, -22, -23,
327
+ -24, -25, -26, -27, -28, -29, -30, -31, -32, -33,
328
+ -34, -35, -36, -37, -38, -39, -40, -41, -42, -43,
329
+ -44, -114, -46, -48, -49, -50, -51, -52, -53, -54,
330
+ -55, -56, -57, -58, -59, -60, -61, -62, -63, -64,
331
+ -65, -66, -67, -68, -69, -70, -114, -72, -114, -85,
332
+ -86, -87, -88, -89, -90, -91, -92, -93, -94, -95,
333
+ -96, -97, -98, -99, -100, -101, -102, -103, -104, -105,
334
+ -106, -107, -114, -114, -77, -114, -79, -81, -114, -83,
335
+ -108, -114, 140, -18, -19, -20, -21, -45, -47, -71,
336
+ -73, -74, -75, -76, -78, -80, -82, -84, -109, -110 ]
337
+
338
+ racc_goto_table = [
339
+ 88, 112, 119, 116, 87, 120, 62, 1, 86, 61,
340
+ 115, 32, 118, 121, 33, nil, nil, nil, nil, nil,
341
+ nil, nil, nil, nil, 34, 35, 36, 37, nil, nil,
342
+ nil, nil, 113, nil, nil, nil, nil, nil, nil, nil,
343
+ nil, nil, nil, nil, nil, nil, 127, nil, nil, nil,
344
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
345
+ nil, nil, nil, nil, nil, nil, nil, nil, 129, nil,
346
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
347
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
348
+ nil, nil, 134, 136, nil, nil, nil, nil, 138 ]
349
+
350
+ racc_goto_check = [
351
+ 21, 21, 24, 22, 19, 21, 17, 1, 20, 18,
352
+ 23, 3, 25, 26, 27, nil, nil, nil, nil, nil,
353
+ nil, nil, nil, nil, 1, 1, 1, 1, nil, nil,
354
+ nil, nil, 1, nil, nil, nil, nil, nil, nil, nil,
355
+ nil, nil, nil, nil, nil, nil, 17, nil, nil, nil,
356
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
357
+ nil, nil, nil, nil, nil, nil, nil, nil, 19, nil,
358
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
359
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
360
+ nil, nil, 22, 24, nil, nil, nil, nil, 21 ]
361
+
362
+ racc_goto_pointer = [
363
+ nil, 7, nil, 9, nil, nil, nil, nil, nil, nil,
364
+ nil, nil, nil, nil, nil, nil, nil, -15, -12, -18,
365
+ -14, -23, -23, -16, -25, -15, -15, -2 ]
366
+
367
+ racc_goto_default = [
368
+ nil, nil, 2, 3, 4, 5, 6, 7, 8, 9,
369
+ 10, 11, 12, 13, 14, 15, 16, nil, nil, nil,
370
+ nil, nil, nil, nil, nil, nil, nil, 29 ]
371
+
372
+ racc_reduce_table = [
373
+ 0, 0, :racc_error,
374
+ 0, 27, :_reduce_none,
375
+ 1, 27, :_reduce_none,
376
+ 2, 28, :_reduce_3,
377
+ 1, 28, :_reduce_4,
378
+ 1, 29, :_reduce_none,
379
+ 1, 29, :_reduce_none,
380
+ 1, 29, :_reduce_none,
381
+ 1, 29, :_reduce_none,
382
+ 1, 29, :_reduce_none,
383
+ 1, 29, :_reduce_none,
384
+ 1, 29, :_reduce_none,
385
+ 1, 29, :_reduce_none,
386
+ 1, 29, :_reduce_none,
387
+ 1, 29, :_reduce_none,
388
+ 1, 29, :_reduce_none,
389
+ 1, 29, :_reduce_none,
390
+ 1, 29, :_reduce_none,
391
+ 3, 30, :_reduce_18,
392
+ 3, 31, :_reduce_19,
393
+ 3, 32, :_reduce_20,
394
+ 3, 36, :_reduce_21,
395
+ 1, 43, :_reduce_none,
396
+ 1, 43, :_reduce_none,
397
+ 1, 43, :_reduce_none,
398
+ 1, 43, :_reduce_none,
399
+ 1, 43, :_reduce_none,
400
+ 1, 43, :_reduce_none,
401
+ 1, 43, :_reduce_none,
402
+ 1, 43, :_reduce_none,
403
+ 1, 43, :_reduce_none,
404
+ 1, 43, :_reduce_none,
405
+ 1, 43, :_reduce_none,
406
+ 1, 43, :_reduce_none,
407
+ 1, 43, :_reduce_none,
408
+ 1, 43, :_reduce_none,
409
+ 1, 43, :_reduce_none,
410
+ 1, 43, :_reduce_none,
411
+ 1, 43, :_reduce_none,
412
+ 1, 43, :_reduce_none,
413
+ 1, 43, :_reduce_none,
414
+ 1, 43, :_reduce_none,
415
+ 1, 43, :_reduce_none,
416
+ 1, 43, :_reduce_none,
417
+ 1, 43, :_reduce_none,
418
+ 2, 44, :_reduce_45,
419
+ 1, 44, :_reduce_46,
420
+ 3, 37, :_reduce_47,
421
+ 1, 45, :_reduce_none,
422
+ 1, 45, :_reduce_none,
423
+ 1, 45, :_reduce_none,
424
+ 1, 45, :_reduce_none,
425
+ 1, 45, :_reduce_none,
426
+ 1, 45, :_reduce_none,
427
+ 1, 45, :_reduce_none,
428
+ 1, 45, :_reduce_none,
429
+ 1, 45, :_reduce_none,
430
+ 1, 45, :_reduce_none,
431
+ 1, 45, :_reduce_none,
432
+ 1, 45, :_reduce_none,
433
+ 1, 45, :_reduce_none,
434
+ 1, 45, :_reduce_none,
435
+ 1, 45, :_reduce_none,
436
+ 1, 45, :_reduce_none,
437
+ 1, 45, :_reduce_none,
438
+ 1, 45, :_reduce_none,
439
+ 1, 45, :_reduce_none,
440
+ 1, 45, :_reduce_none,
441
+ 1, 45, :_reduce_none,
442
+ 1, 45, :_reduce_none,
443
+ 1, 45, :_reduce_none,
444
+ 2, 46, :_reduce_71,
445
+ 1, 46, :_reduce_72,
446
+ 3, 35, :_reduce_73,
447
+ 3, 39, :_reduce_74,
448
+ 3, 40, :_reduce_75,
449
+ 3, 41, :_reduce_76,
450
+ 1, 48, :_reduce_77,
451
+ 2, 49, :_reduce_78,
452
+ 1, 49, :_reduce_79,
453
+ 3, 33, :_reduce_80,
454
+ 1, 50, :_reduce_81,
455
+ 2, 51, :_reduce_82,
456
+ 1, 51, :_reduce_83,
457
+ 3, 34, :_reduce_84,
458
+ 1, 47, :_reduce_none,
459
+ 1, 47, :_reduce_none,
460
+ 1, 47, :_reduce_none,
461
+ 1, 47, :_reduce_none,
462
+ 1, 47, :_reduce_none,
463
+ 1, 47, :_reduce_none,
464
+ 1, 47, :_reduce_none,
465
+ 1, 47, :_reduce_none,
466
+ 1, 47, :_reduce_none,
467
+ 1, 47, :_reduce_none,
468
+ 1, 47, :_reduce_none,
469
+ 1, 47, :_reduce_none,
470
+ 1, 47, :_reduce_none,
471
+ 1, 47, :_reduce_none,
472
+ 1, 47, :_reduce_none,
473
+ 1, 47, :_reduce_none,
474
+ 1, 47, :_reduce_none,
475
+ 1, 47, :_reduce_none,
476
+ 1, 47, :_reduce_none,
477
+ 1, 47, :_reduce_none,
478
+ 1, 47, :_reduce_none,
479
+ 1, 47, :_reduce_none,
480
+ 1, 47, :_reduce_none,
481
+ 1, 52, :_reduce_none,
482
+ 2, 52, :_reduce_109,
483
+ 3, 38, :_reduce_110,
484
+ 1, 42, :_reduce_111,
485
+ 2, 42, :_reduce_112,
486
+ 1, 53, :_reduce_113 ]
487
+
488
+ racc_reduce_n = 114
489
+
490
+ racc_shift_n = 140
491
+
492
+ racc_token_table = {
493
+ false => 0,
494
+ :error => 1,
495
+ :EM_OPEN => 2,
496
+ :EM_CLOSE => 3,
497
+ :ITALIC_OPEN => 4,
498
+ :ITALIC_CLOSE => 5,
499
+ :STRIKE_OPEN => 6,
500
+ :STRIKE_CLOSE => 7,
501
+ :LABEL_OPEN => 8,
502
+ :LABEL_CLOSE => 9,
503
+ :REFERENCE_OPEN => 10,
504
+ :REFERENCE_CLOSE => 11,
505
+ :VERB_OPEN => 12,
506
+ :VERB_CLOSE => 13,
507
+ :ERB_OPEN => 14,
508
+ :ERB_CLOSE => 15,
509
+ :HERB_OPEN => 16,
510
+ :FOOTNOTE_OPEN => 17,
511
+ :FOOTNOTE_CLOSE => 18,
512
+ :RUBY_OPEN => 19,
513
+ :RUBY_CLOSE => 20,
514
+ :IMAGE_OPEN => 21,
515
+ :IMAGE_CLOSE => 22,
516
+ :MANUEDO_OPEN => 23,
517
+ :MANUEDO_CLOSE => 24,
518
+ :OTHER => 25 }
519
+
520
+ racc_nt_base = 26
521
+
522
+ racc_use_result_var = false
523
+
524
+ Racc_arg = [
525
+ racc_action_table,
526
+ racc_action_check,
527
+ racc_action_default,
528
+ racc_action_pointer,
529
+ racc_goto_table,
530
+ racc_goto_check,
531
+ racc_goto_default,
532
+ racc_goto_pointer,
533
+ racc_nt_base,
534
+ racc_reduce_table,
535
+ racc_token_table,
536
+ racc_shift_n,
537
+ racc_reduce_n,
538
+ racc_use_result_var ]
539
+
540
+ Racc_token_to_s_table = [
541
+ "$end",
542
+ "error",
543
+ "EM_OPEN",
544
+ "EM_CLOSE",
545
+ "ITALIC_OPEN",
546
+ "ITALIC_CLOSE",
547
+ "STRIKE_OPEN",
548
+ "STRIKE_CLOSE",
549
+ "LABEL_OPEN",
550
+ "LABEL_CLOSE",
551
+ "REFERENCE_OPEN",
552
+ "REFERENCE_CLOSE",
553
+ "VERB_OPEN",
554
+ "VERB_CLOSE",
555
+ "ERB_OPEN",
556
+ "ERB_CLOSE",
557
+ "HERB_OPEN",
558
+ "FOOTNOTE_OPEN",
559
+ "FOOTNOTE_CLOSE",
560
+ "RUBY_OPEN",
561
+ "RUBY_CLOSE",
562
+ "IMAGE_OPEN",
563
+ "IMAGE_CLOSE",
564
+ "MANUEDO_OPEN",
565
+ "MANUEDO_CLOSE",
566
+ "OTHER",
567
+ "$start",
568
+ "content",
569
+ "elements",
570
+ "element",
571
+ "emphasis",
572
+ "italic",
573
+ "strike",
574
+ "label",
575
+ "reference",
576
+ "ruby",
577
+ "footnote",
578
+ "image",
579
+ "verb",
580
+ "erb",
581
+ "herb",
582
+ "manuedo",
583
+ "normal_strings",
584
+ "image_string",
585
+ "image_strings",
586
+ "ruby_string",
587
+ "ruby_strings",
588
+ "verb_string",
589
+ "label_string",
590
+ "label_strings",
591
+ "reference_string",
592
+ "reference_strings",
593
+ "verb_strings",
594
+ "normal_string" ]
595
+
596
+ Racc_debug_parser = false
597
+
598
+ ##### State transition tables end #####
599
+
600
+ # reduce 0 omitted
601
+
602
+ # reduce 1 omitted
603
+
604
+ # reduce 2 omitted
605
+
606
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 9)
607
+ def _reduce_3(val, _values)
608
+ val[0].push(val[1])
609
+ end
610
+ .,.,
611
+
612
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 10)
613
+ def _reduce_4(val, _values)
614
+ val
615
+ end
616
+ .,.,
617
+
618
+ # reduce 5 omitted
619
+
620
+ # reduce 6 omitted
621
+
622
+ # reduce 7 omitted
623
+
624
+ # reduce 8 omitted
625
+
626
+ # reduce 9 omitted
627
+
628
+ # reduce 10 omitted
629
+
630
+ # reduce 11 omitted
631
+
632
+ # reduce 12 omitted
633
+
634
+ # reduce 13 omitted
635
+
636
+ # reduce 14 omitted
637
+
638
+ # reduce 15 omitted
639
+
640
+ # reduce 16 omitted
641
+
642
+ # reduce 17 omitted
643
+
644
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 27)
645
+ def _reduce_18(val, _values)
646
+ Emphasis.new(val[1])
647
+ end
648
+ .,.,
649
+
650
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 28)
651
+ def _reduce_19(val, _values)
652
+ Italic.new(val[1])
653
+ end
654
+ .,.,
655
+
656
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 29)
657
+ def _reduce_20(val, _values)
658
+ Strike.new(val[1])
659
+ end
660
+ .,.,
661
+
662
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 31)
663
+ def _reduce_21(val, _values)
664
+ @index[:footnote] ||= []
665
+ @index[:footnote] << {:content => val[1] }
666
+ Footnote.new([val[1], @index[:footnote].size])
667
+
668
+ end
669
+ .,.,
670
+
671
+ # reduce 22 omitted
672
+
673
+ # reduce 23 omitted
674
+
675
+ # reduce 24 omitted
676
+
677
+ # reduce 25 omitted
678
+
679
+ # reduce 26 omitted
680
+
681
+ # reduce 27 omitted
682
+
683
+ # reduce 28 omitted
684
+
685
+ # reduce 29 omitted
686
+
687
+ # reduce 30 omitted
688
+
689
+ # reduce 31 omitted
690
+
691
+ # reduce 32 omitted
692
+
693
+ # reduce 33 omitted
694
+
695
+ # reduce 34 omitted
696
+
697
+ # reduce 35 omitted
698
+
699
+ # reduce 36 omitted
700
+
701
+ # reduce 37 omitted
702
+
703
+ # reduce 38 omitted
704
+
705
+ # reduce 39 omitted
706
+
707
+ # reduce 40 omitted
708
+
709
+ # reduce 41 omitted
710
+
711
+ # reduce 42 omitted
712
+
713
+ # reduce 43 omitted
714
+
715
+ # reduce 44 omitted
716
+
717
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 63)
718
+ def _reduce_45(val, _values)
719
+ val.join
720
+ end
721
+ .,.,
722
+
723
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 64)
724
+ def _reduce_46(val, _values)
725
+ val[0]
726
+ end
727
+ .,.,
728
+
729
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 65)
730
+ def _reduce_47(val, _values)
731
+ Image.new(val[1])
732
+ end
733
+ .,.,
734
+
735
+ # reduce 48 omitted
736
+
737
+ # reduce 49 omitted
738
+
739
+ # reduce 50 omitted
740
+
741
+ # reduce 51 omitted
742
+
743
+ # reduce 52 omitted
744
+
745
+ # reduce 53 omitted
746
+
747
+ # reduce 54 omitted
748
+
749
+ # reduce 55 omitted
750
+
751
+ # reduce 56 omitted
752
+
753
+ # reduce 57 omitted
754
+
755
+ # reduce 58 omitted
756
+
757
+ # reduce 59 omitted
758
+
759
+ # reduce 60 omitted
760
+
761
+ # reduce 61 omitted
762
+
763
+ # reduce 62 omitted
764
+
765
+ # reduce 63 omitted
766
+
767
+ # reduce 64 omitted
768
+
769
+ # reduce 65 omitted
770
+
771
+ # reduce 66 omitted
772
+
773
+ # reduce 67 omitted
774
+
775
+ # reduce 68 omitted
776
+
777
+ # reduce 69 omitted
778
+
779
+ # reduce 70 omitted
780
+
781
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 93)
782
+ def _reduce_71(val, _values)
783
+ val.join
784
+ end
785
+ .,.,
786
+
787
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 94)
788
+ def _reduce_72(val, _values)
789
+ val[0]
790
+ end
791
+ .,.,
792
+
793
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 97)
794
+ def _reduce_73(val, _values)
795
+ base, text = val[1].split("|",2)
796
+ text ||= base
797
+ Ruby.new([base, text])
798
+
799
+ end
800
+ .,.,
801
+
802
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 105)
803
+ def _reduce_74(val, _values)
804
+ e = ERB.new("<%= #{val[1]} %>")
805
+ Plain.new(e.result)
806
+ end
807
+ .,.,
808
+
809
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 108)
810
+ def _reduce_75(val, _values)
811
+ e = ERB.new("<% #{val[1]} %>")
812
+ Plain.new(e.result)
813
+ end
814
+ .,.,
815
+
816
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 112)
817
+ def _reduce_76(val, _values)
818
+ Manuedo.new(val[1])
819
+ end
820
+ .,.,
821
+
822
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 117)
823
+ def _reduce_77(val, _values)
824
+ val[0]
825
+ end
826
+ .,.,
827
+
828
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 120)
829
+ def _reduce_78(val, _values)
830
+ val.join
831
+ end
832
+ .,.,
833
+
834
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 121)
835
+ def _reduce_79(val, _values)
836
+ val[0]
837
+ end
838
+ .,.,
839
+
840
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 124)
841
+ def _reduce_80(val, _values)
842
+ label, title = val[1].split("|",2)
843
+ title ||= label
844
+ @index[:label] ||= []
845
+ @index[:label] << {:title => title }
846
+ Label.new([label.to_code, title, @index[:label].size])
847
+
848
+ end
849
+ .,.,
850
+
851
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 133)
852
+ def _reduce_81(val, _values)
853
+ val[0]
854
+ end
855
+ .,.,
856
+
857
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 135)
858
+ def _reduce_82(val, _values)
859
+ val.join
860
+ end
861
+ .,.,
862
+
863
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 136)
864
+ def _reduce_83(val, _values)
865
+ val[0]
866
+ end
867
+ .,.,
868
+
869
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 139)
870
+ def _reduce_84(val, _values)
871
+ title, uri = val[1].split("|",2)
872
+ uri ||= title
873
+ uri = "#" + uri.to_code if uri.gsub(/^\s*https*:\/\//,"") == uri
874
+ Reference.new([title, uri])
875
+
876
+ end
877
+ .,.,
878
+
879
+ # reduce 85 omitted
880
+
881
+ # reduce 86 omitted
882
+
883
+ # reduce 87 omitted
884
+
885
+ # reduce 88 omitted
886
+
887
+ # reduce 89 omitted
888
+
889
+ # reduce 90 omitted
890
+
891
+ # reduce 91 omitted
892
+
893
+ # reduce 92 omitted
894
+
895
+ # reduce 93 omitted
896
+
897
+ # reduce 94 omitted
898
+
899
+ # reduce 95 omitted
900
+
901
+ # reduce 96 omitted
902
+
903
+ # reduce 97 omitted
904
+
905
+ # reduce 98 omitted
906
+
907
+ # reduce 99 omitted
908
+
909
+ # reduce 100 omitted
910
+
911
+ # reduce 101 omitted
912
+
913
+ # reduce 102 omitted
914
+
915
+ # reduce 103 omitted
916
+
917
+ # reduce 104 omitted
918
+
919
+ # reduce 105 omitted
920
+
921
+ # reduce 106 omitted
922
+
923
+ # reduce 107 omitted
924
+
925
+ # reduce 108 omitted
926
+
927
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 171)
928
+ def _reduce_109(val, _values)
929
+ val
930
+ end
931
+ .,.,
932
+
933
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 173)
934
+ def _reduce_110(val, _values)
935
+ Verb.new(val[1])
936
+ end
937
+ .,.,
938
+
939
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 177)
940
+ def _reduce_111(val, _values)
941
+ Plain.new(val[0])
942
+ end
943
+ .,.,
944
+
945
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 178)
946
+ def _reduce_112(val, _values)
947
+ Plain.new([val[0].contents, val[1]])
948
+ end
949
+ .,.,
950
+
951
+ module_eval(<<'.,.,', 'rafinlineparser.ry', 180)
952
+ def _reduce_113(val, _values)
953
+ val[0]
954
+ end
955
+ .,.,
956
+
957
+ def _reduce_none(val, _values)
958
+ val[0]
959
+ end
960
+
961
+ end # class InlineParser
962
+
963
+ if __FILE__ == $0
964
+ raf = InlineParser.new
965
+ src = $stdin.readline
966
+ nodes = raf.parse(src)
967
+ puts "----- output -----"
968
+ nodes.each do |n|
969
+ puts n.apply
970
+ end
971
+ end
972
+ end # end of module Raf