Class: ReVIEW::Compiler
Defined Under Namespace
Classes: InlineSyntaxElement, SyntaxElement
Constant Summary
collapse
- SYNTAX =
{}
- INLINE =
{}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(strategy) ⇒ Compiler
Returns a new instance of Compiler.
17
18
19
|
# File 'lib/review/compiler.rb', line 17
def initialize(strategy)
@strategy = strategy
end
|
Instance Attribute Details
Returns the value of attribute strategy.
21
22
23
|
# File 'lib/review/compiler.rb', line 21
def strategy
@strategy
end
|
Class Method Details
.defblock(name, argc, optional = false, &block) ⇒ Object
68
69
70
|
# File 'lib/review/compiler.rb', line 68
def self.defblock(name, argc, optional = false, &block)
defsyntax name, (optional ? :optional : :block), argc, &block
end
|
.defsingle(name, argc, &block) ⇒ Object
72
73
74
|
# File 'lib/review/compiler.rb', line 72
def self.defsingle(name, argc, &block)
defsyntax name, :line, argc, &block
end
|
.defsyntax(name, type, argc, &block) ⇒ Object
76
77
78
|
# File 'lib/review/compiler.rb', line 76
def self.defsyntax(name, type, argc, &block)
SYNTAX[name] = SyntaxElement.new(name, type, argc, &block)
end
|
Instance Method Details
#compile(chap) ⇒ Object
23
24
25
26
27
|
# File 'lib/review/compiler.rb', line 23
def compile(chap)
@chapter = chap
do_compile
@strategy.result
end
|
#inline_defined?(name) ⇒ Boolean
102
103
104
|
# File 'lib/review/compiler.rb', line 102
def inline_defined?(name)
INLINE.key?(name.to_sym)
end
|
#syntax_defined?(name) ⇒ Boolean
84
85
86
|
# File 'lib/review/compiler.rb', line 84
def syntax_defined?(name)
SYNTAX.key?(name.to_sym)
end
|
#syntax_descriptor(name) ⇒ Object
88
89
90
|
# File 'lib/review/compiler.rb', line 88
def syntax_descriptor(name)
SYNTAX[name.to_sym]
end
|
#text(str) ⇒ Object
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
|
# File 'lib/review/compiler.rb', line 530
def text(str)
return '' if str.empty?
words = replace_fence(str).split(/(@<\w+>\{(?:[^\}\\]|\\.)*?\})/, -1)
words.each do |w|
if w.scan(/@<\w+>/).size > 1 && !/\A@<raw>/.match(w)
error "`@<xxx>' seen but is not valid inline op: #{w}"
end
end
result = @strategy.nofunc_text(revert_replace_fence(words.shift))
until words.empty?
result << compile_inline(revert_replace_fence(words.shift.gsub(/\\\}/, '}').gsub(/\\\\/, '\\')))
result << @strategy.nofunc_text(revert_replace_fence(words.shift))
end
result
rescue => e
error e.message
end
|