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.
39
40
41
|
# File 'lib/review/compiler.rb', line 39
def initialize(strategy)
@strategy = strategy
end
|
Instance Attribute Details
Returns the value of attribute strategy.
43
44
45
|
# File 'lib/review/compiler.rb', line 43
def strategy
@strategy
end
|
Class Method Details
.defblock(name, argc, optional = false, &block) ⇒ Object
86
87
88
|
# File 'lib/review/compiler.rb', line 86
def self.defblock(name, argc, optional = false, &block)
defsyntax name, (optional ? :optional : :block), argc, &block
end
|
.defsingle(name, argc, &block) ⇒ Object
90
91
92
|
# File 'lib/review/compiler.rb', line 90
def self.defsingle(name, argc, &block)
defsyntax name, :line, argc, &block
end
|
.defsyntax(name, type, argc, &block) ⇒ Object
94
95
96
|
# File 'lib/review/compiler.rb', line 94
def self.defsyntax(name, type, argc, &block)
SYNTAX[name] = SyntaxElement.new(name, type, argc, &block)
end
|
Instance Method Details
#compile(chap) ⇒ Object
45
46
47
48
49
|
# File 'lib/review/compiler.rb', line 45
def compile(chap)
@chapter = chap
do_compile
@strategy.result
end
|
#inline_defined?(name) ⇒ Boolean
120
121
122
|
# File 'lib/review/compiler.rb', line 120
def inline_defined?(name)
INLINE.key?(name.to_sym)
end
|
#syntax_defined?(name) ⇒ Boolean
102
103
104
|
# File 'lib/review/compiler.rb', line 102
def syntax_defined?(name)
SYNTAX.key?(name.to_sym)
end
|
#syntax_descriptor(name) ⇒ Object
106
107
108
|
# File 'lib/review/compiler.rb', line 106
def syntax_descriptor(name)
SYNTAX[name.to_sym]
end
|
#text(str) ⇒ Object
516
517
518
519
520
521
522
523
524
525
526
527
528
|
# File 'lib/review/compiler.rb', line 516
def text(str)
return '' if str.empty?
words = replace_fence(str).split(/(@<\w+>\{(?:[^\}\\]|\\.)*?\})/, -1)
words.each { |w| error "`@<xxx>' seen but is not valid inline op: #{w}" if w.scan(/@<\w+>/).size > 1 && !/\A@<raw>/.match(w) }
result = @strategy.nofunc_text(words.shift)
until words.empty?
result << compile_inline(words.shift.gsub(/\\\}/, '}').gsub(/\\\\/, '\\'))
result << @strategy.nofunc_text(words.shift)
end
result.gsub("\x01", '@')
rescue => err
error err.message
end
|