class ReVIEW::Compiler

Constants

INLINE
SYNTAX

Attributes

strategy[R]

Public Class Methods

defblock(name, argc, optional = false, &block) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 92
def Compiler.defblock(name, argc, optional = false, &block)
  defsyntax name, (optional ? :optional : :block), argc, &block
end
definline(name) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 122
def Compiler.definline(name)
  INLINE[name] = InlineSyntaxElement.new(name)
end
defsingle(name, argc, &block) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 96
def Compiler.defsingle(name, argc, &block)
  defsyntax name, :line, argc, &block
end
defsyntax(name, type, argc, &block) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 100
def Compiler.defsyntax(name, type, argc, &block)
  SYNTAX[name] = SyntaxElement.new(name, type, argc, &block)
end
new(strategy) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 43
def initialize(strategy)
  @strategy = strategy
end

Public Instance Methods

compile(chap) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 49
def compile(chap)
  @chapter = chap
  do_compile
  @strategy.result
end
inline_defined?(name) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 126
def inline_defined?(name)
  INLINE.key?(name.to_sym)
end
syntax_defined?(name) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 104
def syntax_defined?(name)
  SYNTAX.key?(name.to_sym)
end
syntax_descriptor(name) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 108
def syntax_descriptor(name)
  SYNTAX[name.to_sym]
end
text(str) click to toggle source
# File ../../../../../lib/review/compiler.rb, line 517
def text(str)
  return '' if str.empty?
  words = str.split(/(@<\w+>\{(?:[^\}\]|\.)*?\})/, -1)
  words.each do |w|
    error "`@<xxx>' seen but is not valid inline op: #{w}" if w.scan(/@<\w+>/).size > 1 && !/\A@<raw>/.match(w)
  end
  result = @strategy.nofunc_text(words.shift)
  until words.empty?
    result << compile_inline(words.shift.gsub(/\\}/, '}'))
    result << @strategy.nofunc_text(words.shift)
  end
  result
rescue => err
  error err.message
end