class MathML::LaTeX::Scanner
Public Instance Methods
check(re)
click to toggle source
# File lib/math_ml/latex.rb 59 def check(re) 60 skip_space_and(true){_check(re)} 61 end
Also aliased as: _check
check_any(remain_space=false)
click to toggle source
# File lib/math_ml/latex.rb 110 def check_any(remain_space=false) 111 skip_space_and(true){scan_any(remain_space)} 112 end
check_block()
click to toggle source
# File lib/math_ml/latex.rb 83 def check_block 84 skip_space_and(true){scan_block} 85 end
check_command()
click to toggle source
# File lib/math_ml/latex.rb 71 def check_command 72 check(RE::COMMANDS) 73 end
check_option()
click to toggle source
# File lib/math_ml/latex.rb 147 def check_option 148 skip_space_and(true){scan_option} 149 end
done()
click to toggle source
# File lib/math_ml/latex.rb 37 def done 38 self.string[0, pos] 39 end
eos?()
click to toggle source
# File lib/math_ml/latex.rb 67 def eos? 68 _eos? || _check(/#{RE::SPACE}+\z/) 69 end
Also aliased as: _eos?
peek_command()
click to toggle source
# File lib/math_ml/latex.rb 79 def peek_command 80 check_command ? self[1] : nil 81 end
scan(re)
click to toggle source
# File lib/math_ml/latex.rb 63 def scan(re) 64 skip_space_and(false){_scan(re)} 65 end
Also aliased as: _scan
scan_any(remain_space=false)
click to toggle source
# File lib/math_ml/latex.rb 114 def scan_any(remain_space=false) 115 p = pos 116 scan_space 117 r = remain_space ? matched.to_s : "" 118 case 119 when s = scan_block 120 when s = scan_command 121 else 122 unless _scan(/./) || remain_space 123 self.pos = p 124 return nil 125 end 126 s = matched.to_s 127 end 128 r+s 129 end
scan_block()
click to toggle source
# File lib/math_ml/latex.rb 87 def scan_block 88 return nil unless scan(/\{/) 89 block = "{" 90 bpos = pos-1 91 nest = 1 92 while _scan(/(#{MBEC}*?)([\{\}])/) 93 block << matched 94 case self[2] 95 when "{" 96 nest+=1 97 when "}" 98 nest-=1 99 break if nest==0 100 end 101 end 102 if nest>0 103 self.pos = bpos 104 raise BlockNotClosed 105 end 106 self.pos = bpos 107 _scan(/\A\{(#{Regexp.escape(block[RE::BLOCK, 1].to_s)})\}/) 108 end
scan_command()
click to toggle source
# File lib/math_ml/latex.rb 75 def scan_command 76 scan(RE::COMMANDS) 77 end
scan_option()
click to toggle source
# File lib/math_ml/latex.rb 131 def scan_option 132 return nil unless scan(/\[/) 133 opt = "[" 134 p = pos-1 135 until (s=scan_any(true)) =~ /\A#{RE::SPACE}*\]\z/ 136 opt << s 137 if eos? 138 self.pos = p 139 raise OptionNotClosed 140 end 141 end 142 opt << s 143 self.pos = p 144 _scan(/\A\[(#{Regexp.escape(opt[RE::OPTION, 1].to_s)})\]/) 145 end
scan_space()
click to toggle source
# File lib/math_ml/latex.rb 41 def scan_space 42 _scan(/#{RE::SPACE}+/) 43 end
skip_space_and(check_mode) { || ... }
click to toggle source
# File lib/math_ml/latex.rb 45 def skip_space_and(check_mode) 46 opos = pos 47 scan_space 48 r = yield 49 self.pos = opos if check_mode || !r 50 r 51 end