class MathML::LaTeX::Scanner
Public Instance Methods
check(re)
click to toggle source
# File lib/math_ml/latex.rb, line 59 def check(re) skip_space_and(true){_check(re)} end
Also aliased as: _check
check_any(remain_space=false)
click to toggle source
# File lib/math_ml/latex.rb, line 110 def check_any(remain_space=false) skip_space_and(true){scan_any(remain_space)} end
check_block()
click to toggle source
# File lib/math_ml/latex.rb, line 83 def check_block skip_space_and(true){scan_block} end
check_command()
click to toggle source
# File lib/math_ml/latex.rb, line 71 def check_command check(RE::COMMANDS) end
check_option()
click to toggle source
# File lib/math_ml/latex.rb, line 147 def check_option skip_space_and(true){scan_option} end
done()
click to toggle source
# File lib/math_ml/latex.rb, line 37 def done self.string[0, pos] end
eos?()
click to toggle source
# File lib/math_ml/latex.rb, line 67 def eos? _eos? || _check(/#{RE::SPACE}+\z/) end
Also aliased as: _eos?
peek_command()
click to toggle source
# File lib/math_ml/latex.rb, line 79 def peek_command check_command ? self[1] : nil end
scan(re)
click to toggle source
# File lib/math_ml/latex.rb, line 63 def scan(re) skip_space_and(false){_scan(re)} end
Also aliased as: _scan
scan_any(remain_space=false)
click to toggle source
# File lib/math_ml/latex.rb, line 114 def scan_any(remain_space=false) p = pos scan_space r = remain_space ? matched.to_s : "" case when s = scan_block when s = scan_command else unless _scan(/./) || remain_space self.pos = p return nil end s = matched.to_s end r << s end
scan_block()
click to toggle source
# File lib/math_ml/latex.rb, line 87 def scan_block return nil unless scan(/\{/) block = "{" bpos = pos-1 nest = 1 while _scan(/(#{MBEC}*?)([\{\}])/) block << matched case self[2] when "{" nest+=1 when "}" nest-=1 break if nest==0 end end if nest>0 self.pos = bpos raise BlockNotClosed end self.pos = bpos _scan(/\A\{(#{Regexp.escape(block[RE::BLOCK, 1].to_s)})\}/) end
scan_command()
click to toggle source
# File lib/math_ml/latex.rb, line 75 def scan_command scan(RE::COMMANDS) end
scan_option()
click to toggle source
# File lib/math_ml/latex.rb, line 131 def scan_option return nil unless scan(/\[/) opt = "[" p = pos-1 until (s=scan_any(true)) =~ /\A#{RE::SPACE}*\]\z/ opt << s if eos? self.pos = p raise OptionNotClosed end end opt << s self.pos = p _scan(/\A\[(#{Regexp.escape(opt[RE::OPTION, 1].to_s)})\]/) end
scan_space()
click to toggle source
# File lib/math_ml/latex.rb, line 41 def scan_space _scan(/#{RE::SPACE}+/) end
skip_space_and(check_mode) { || ... }
click to toggle source
# File lib/math_ml/latex.rb, line 45 def skip_space_and(check_mode) opos = pos scan_space r = yield self.pos = opos if check_mode || !r r end