class NMEAPlus::Decoder
Attributes
Public Instance Methods
Source
# File lib/nmea_plus/generated_parser/tokenizer.rb, line 55 def _next_token text = @ss.peek(1) @lineno += 1 if text == "\n" token = case @state when nil case when (text = @ss.scan(/\*[0-9A-F]{2}[\w\n\r]*/i)) action { [:CSUM, text[1..2]] } when (text = @ss.scan(/\$/i)) action { [:CASH, text] } when (text = @ss.scan(/!/i)) action { [:BANG, text] } when (text = @ss.scan(/[^\*]+/i)) action { [:DATA, text] } else text = @ss.string[@ss.pos .. -1] raise ScanError, "can not match: '" + text + "'" end # if else raise ScanError, "undefined state: '" + state.to_s + "'" end # case state token end
Source
# File lib/nmea_plus/generated_parser/tokenizer.rb, line 24 def action yield end
Source
# File lib/nmea_plus/generated_parser/tokenizer.rb, line 34 def load_file( filename ) @filename = filename File.open(filename, "r") do |f| scan_setup(f.read) end end
Source
# File lib/nmea_plus/generated_parser/tokenizer.rb, line 47 def next_token return if @ss.eos? # skips empty actions until token = _next_token or @ss.eos?; end token end
Source
# File lib/nmea_plus/generated_parser/tokenizer.rb, line 85 def parse(input) @yydebug = true if ENV['DEBUG_RACC'] scan_str(input) end
Source
# File lib/nmea_plus/generated_parser/tokenizer.rb, line 41 def scan_file( filename ) load_file(filename) do_parse end
Source
# File lib/nmea_plus/generated_parser/tokenizer.rb, line 18 def scan_setup(str) @ss = StringScanner.new(str) @lineno = 1 @state = nil end
Source
# File lib/nmea_plus/generated_parser/tokenizer.rb, line 28 def scan_str(str) scan_setup(str) do_parse end
Also aliased as: scan
Source
# File lib/nmea_plus/generated_parser/tokenizer.rb, line 89 def tokenize(input) scan_setup(input) ret = [] last_token = nil loop do last_token = next_token break if last_token.nil? ret << last_token end ret end