# line 1 "lib/gorgyrella/parser.rl" module Gorgyrella class Parser # line 105 "lib/gorgyrella/parser.rl" # line 11 "lib/gorgyrella/parser.rb" class << self attr_accessor :_gorgyrella_parser_actions private :_gorgyrella_parser_actions, :_gorgyrella_parser_actions= end self._gorgyrella_parser_actions = [ 0, 1, 0, 1, 1, 1, 2, 1, 5, 1, 7, 1, 8, 2, 1, 2, 2, 2, 8, 2, 2, 9, 2, 6, 17, 2, 11, 3, 2, 16, 4, 3, 6, 17, 5, 3, 8, 12, 4, 3, 8, 14, 4, 3, 13, 3, 15, 4, 2, 8, 12, 4, 4, 2, 8, 14, 4, 4, 2, 9, 12, 4, 4, 2, 10, 12, 4, 4, 2, 10, 14, 4 ] class << self attr_accessor :_gorgyrella_parser_key_offsets private :_gorgyrella_parser_key_offsets, :_gorgyrella_parser_key_offsets= end self._gorgyrella_parser_key_offsets = [ 0, 0, 1, 7, 10, 13, 14, 17, 20, 22, 25, 28, 30, 34, 36, 38, 40, 42, 45, 55, 57, 59, 63, 70, 79, 85, 96, 98, 100, 102, 104, 106, 108, 111, 115, 117, 119, 122, 132, 134, 136, 140, 147, 158, 165, 174, 180, 191, 194, 197, 200, 202, 204, 208, 209, 210, 212, 214, 215, 219, 220, 221, 222, 223, 224, 226, 235, 237, 239, 243, 249, 258, 264, 275, 276, 277, 278, 279, 280, 281, 283, 286, 288, 290, 292, 301, 303, 305, 309, 315, 326, 332, 341, 347, 358, 360, 362, 366, 368, 370, 374, 380, 386 ] class << self attr_accessor :_gorgyrella_parser_trans_keys private :_gorgyrella_parser_trans_keys, :_gorgyrella_parser_trans_keys= end self._gorgyrella_parser_trans_keys = [ 10, 9, 10, 32, 35, 37, 47, 10, 13, 35, 10, 13, 37, 10, 10, 13, 37, 10, 13, 32, 10, 64, 10, 101, 105, 10, 110, 120, 10, 100, 9, 10, 13, 32, 10, 112, 10, 111, 10, 114, 10, 116, 9, 10, 32, 9, 10, 32, 34, 48, 57, 65, 90, 97, 122, 10, 34, 10, 34, 9, 10, 13, 32, 9, 10, 32, 65, 90, 97, 122, 10, 13, 95, 45, 46, 65, 90, 97, 122, 9, 10, 13, 32, 48, 57, 9, 10, 13, 32, 95, 45, 46, 65, 90, 97, 122, 10, 110, 10, 99, 10, 108, 10, 117, 10, 100, 10, 101, 9, 10, 32, 9, 10, 32, 34, 10, 34, 10, 34, 9, 10, 32, 9, 10, 32, 34, 48, 57, 65, 90, 97, 122, 10, 34, 10, 34, 9, 10, 13, 32, 9, 10, 32, 65, 90, 97, 122, 9, 10, 13, 32, 95, 45, 46, 65, 90, 97, 122, 9, 10, 32, 65, 90, 97, 122, 10, 13, 95, 45, 46, 65, 90, 97, 122, 9, 10, 13, 32, 48, 57, 9, 10, 13, 32, 95, 45, 46, 65, 90, 97, 122, 10, 13, 47, 10, 13, 47, 10, 13, 35, 13, 35, 13, 35, 10, 13, 32, 35, 10, 64, 101, 105, 110, 120, 100, 9, 10, 13, 32, 10, 112, 111, 114, 116, 9, 32, 9, 32, 34, 48, 57, 65, 90, 97, 122, 10, 34, 10, 34, 9, 10, 13, 32, 9, 32, 65, 90, 97, 122, 10, 13, 95, 45, 46, 65, 90, 97, 122, 9, 10, 13, 32, 48, 57, 9, 10, 13, 32, 95, 45, 46, 65, 90, 97, 122, 110, 99, 108, 117, 100, 101, 9, 32, 9, 32, 34, 10, 34, 10, 34, 9, 32, 9, 32, 34, 48, 57, 65, 90, 97, 122, 10, 34, 10, 34, 9, 10, 13, 32, 9, 32, 65, 90, 97, 122, 9, 10, 13, 32, 95, 45, 46, 65, 90, 97, 122, 9, 32, 65, 90, 97, 122, 10, 13, 95, 45, 46, 65, 90, 97, 122, 9, 10, 13, 32, 48, 57, 9, 10, 13, 32, 95, 45, 46, 65, 90, 97, 122, 13, 37, 13, 37, 10, 13, 32, 37, 13, 47, 13, 47, 10, 13, 32, 47, 9, 10, 32, 35, 37, 47, 9, 10, 32, 35, 37, 47, 9, 10, 32, 35, 37, 47, 0 ] class << self attr_accessor :_gorgyrella_parser_single_lengths private :_gorgyrella_parser_single_lengths, :_gorgyrella_parser_single_lengths= end self._gorgyrella_parser_single_lengths = [ 0, 1, 6, 3, 3, 1, 3, 3, 2, 3, 3, 2, 4, 2, 2, 2, 2, 3, 4, 2, 2, 4, 3, 3, 4, 5, 2, 2, 2, 2, 2, 2, 3, 4, 2, 2, 3, 4, 2, 2, 4, 3, 5, 3, 3, 4, 5, 3, 3, 3, 2, 2, 4, 1, 1, 2, 2, 1, 4, 1, 1, 1, 1, 1, 2, 3, 2, 2, 4, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 2, 3, 2, 2, 4, 2, 5, 2, 3, 4, 5, 2, 2, 4, 2, 2, 4, 6, 6, 6 ] class << self attr_accessor :_gorgyrella_parser_range_lengths private :_gorgyrella_parser_range_lengths, :_gorgyrella_parser_range_lengths= end self._gorgyrella_parser_range_lengths = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 3, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 3, 2, 3, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 3, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 3, 2, 3, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] class << self attr_accessor :_gorgyrella_parser_index_offsets private :_gorgyrella_parser_index_offsets, :_gorgyrella_parser_index_offsets= end self._gorgyrella_parser_index_offsets = [ 0, 0, 2, 9, 13, 17, 19, 23, 27, 30, 34, 38, 41, 46, 49, 52, 55, 58, 62, 70, 73, 76, 81, 87, 94, 100, 109, 112, 115, 118, 121, 124, 127, 131, 136, 139, 142, 146, 154, 157, 160, 165, 171, 180, 186, 193, 199, 208, 212, 216, 220, 223, 226, 231, 233, 235, 238, 241, 243, 248, 250, 252, 254, 256, 258, 261, 268, 271, 274, 279, 284, 291, 297, 306, 308, 310, 312, 314, 316, 318, 321, 325, 328, 331, 334, 341, 344, 347, 352, 357, 366, 371, 378, 384, 393, 396, 399, 404, 407, 410, 415, 422, 429 ] class << self attr_accessor :_gorgyrella_parser_trans_targs private :_gorgyrella_parser_trans_targs, :_gorgyrella_parser_trans_targs= end self._gorgyrella_parser_trans_targs = [ 101, 1, 2, 101, 2, 3, 4, 47, 1, 102, 5, 49, 1, 102, 5, 6, 1, 102, 1, 102, 5, 7, 1, 102, 5, 8, 1, 102, 9, 1, 101, 10, 26, 1, 101, 11, 13, 1, 101, 12, 1, 12, 101, 1, 12, 1, 101, 14, 1, 101, 15, 1, 101, 16, 1, 101, 17, 1, 18, 101, 18, 1, 18, 101, 18, 19, 24, 25, 25, 1, 101, 21, 20, 101, 21, 20, 22, 101, 1, 22, 1, 22, 101, 22, 23, 23, 1, 101, 1, 23, 23, 23, 23, 1, 22, 101, 1, 22, 24, 1, 22, 101, 1, 22, 25, 25, 25, 25, 1, 101, 27, 1, 101, 28, 1, 101, 29, 1, 101, 30, 1, 101, 31, 1, 101, 32, 1, 33, 101, 33, 1, 33, 101, 33, 34, 1, 101, 36, 35, 101, 36, 35, 37, 101, 37, 1, 37, 101, 37, 38, 45, 46, 46, 1, 101, 40, 39, 101, 40, 39, 41, 101, 1, 41, 1, 41, 101, 41, 42, 42, 1, 43, 101, 1, 43, 42, 42, 42, 42, 1, 43, 101, 43, 44, 44, 1, 101, 1, 44, 44, 44, 44, 1, 41, 101, 1, 41, 45, 1, 41, 101, 1, 41, 46, 46, 46, 46, 1, 102, 5, 48, 1, 102, 5, 7, 1, 102, 5, 7, 1, 5, 51, 1, 5, 52, 1, 1, 53, 54, 1, 0, 1, 0, 55, 1, 56, 73, 0, 57, 60, 0, 58, 0, 58, 101, 59, 58, 0, 101, 0, 61, 0, 62, 0, 63, 0, 64, 0, 65, 65, 0, 65, 65, 66, 71, 72, 72, 0, 0, 68, 67, 0, 68, 67, 69, 101, 59, 69, 0, 69, 69, 70, 70, 0, 101, 59, 70, 70, 70, 70, 0, 69, 101, 59, 69, 71, 0, 69, 101, 59, 69, 72, 72, 72, 72, 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, 0, 79, 0, 80, 80, 0, 80, 80, 81, 0, 0, 83, 82, 0, 83, 82, 84, 84, 0, 84, 84, 85, 92, 93, 93, 0, 0, 87, 86, 0, 87, 86, 88, 101, 59, 88, 0, 88, 88, 89, 89, 0, 90, 101, 59, 90, 89, 89, 89, 89, 0, 90, 90, 91, 91, 0, 101, 59, 91, 91, 91, 91, 0, 88, 101, 59, 88, 92, 0, 88, 101, 59, 88, 93, 93, 93, 93, 0, 5, 95, 1, 5, 96, 1, 1, 53, 54, 1, 0, 5, 98, 1, 5, 99, 1, 1, 53, 54, 1, 0, 2, 101, 2, 50, 94, 97, 1, 2, 101, 2, 50, 94, 97, 1, 2, 101, 2, 3, 4, 47, 1, 0 ] class << self attr_accessor :_gorgyrella_parser_trans_actions private :_gorgyrella_parser_trans_actions, :_gorgyrella_parser_trans_actions= end self._gorgyrella_parser_trans_actions = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 13, 3, 0, 5, 0, 11, 39, 39, 11, 0, 0, 0, 0, 3, 3, 0, 67, 67, 0, 0, 0, 0, 0, 16, 52, 52, 16, 0, 0, 16, 52, 52, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 3, 0, 5, 0, 9, 0, 9, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 13, 3, 0, 5, 0, 11, 35, 35, 11, 0, 0, 0, 0, 3, 3, 0, 19, 57, 57, 19, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 62, 62, 0, 0, 0, 0, 0, 16, 47, 47, 16, 0, 0, 16, 47, 47, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 43, 25, 1, 0, 0, 1, 0, 1, 0, 28, 28, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 3, 3, 3, 1, 1, 13, 3, 1, 5, 0, 11, 39, 39, 11, 1, 0, 0, 3, 3, 1, 67, 67, 0, 0, 0, 0, 1, 16, 52, 52, 16, 0, 1, 16, 52, 52, 16, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 13, 3, 1, 5, 0, 9, 9, 1, 0, 0, 0, 3, 3, 3, 1, 1, 13, 3, 1, 5, 0, 11, 35, 35, 11, 1, 0, 0, 3, 3, 1, 19, 57, 57, 19, 0, 0, 0, 0, 1, 0, 0, 3, 3, 1, 62, 62, 0, 0, 0, 0, 1, 16, 47, 47, 16, 0, 1, 16, 47, 47, 16, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 7, 7, 7, 7, 7, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0 ] class << self attr_accessor :_gorgyrella_parser_eof_actions private :_gorgyrella_parser_eof_actions, :_gorgyrella_parser_eof_actions= end self._gorgyrella_parser_eof_actions = [ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 22, 22 ] class << self attr_accessor :gorgyrella_parser_start end self.gorgyrella_parser_start = 100; class << self attr_accessor :gorgyrella_parser_first_final end self.gorgyrella_parser_first_final = 100; class << self attr_accessor :gorgyrella_parser_error end self.gorgyrella_parser_error = 0; class << self attr_accessor :gorgyrella_parser_en_document end self.gorgyrella_parser_en_document = 100; # line 108 "lib/gorgyrella/parser.rl" ### @export "run-machine" def self.run_machine(data, test_mode = false) # puts "Running the state machine with input #{data}..." data += "\n\n" data = data.unpack("c*") if data.is_a?(String) line_counter = 0 line_data = [] builder = Builder.new eof = -1 # line 344 "lib/gorgyrella/parser.rb" begin p ||= 0 pe ||= data.length cs = gorgyrella_parser_start end # line 123 "lib/gorgyrella/parser.rl" # line 353 "lib/gorgyrella/parser.rb" begin _klen, _trans, _keys, _acts, _nacts = nil _goto_level = 0 _resume = 10 _eof_trans = 15 _again = 20 _test_eof = 30 _out = 40 while true _trigger_goto = false if _goto_level <= 0 if p == pe _goto_level = _test_eof next end if cs == 0 _goto_level = _out next end end if _goto_level <= _resume _keys = _gorgyrella_parser_key_offsets[cs] _trans = _gorgyrella_parser_index_offsets[cs] _klen = _gorgyrella_parser_single_lengths[cs] _break_match = false begin if _klen > 0 _lower = _keys _upper = _keys + _klen - 1 loop do break if _upper < _lower _mid = _lower + ( (_upper - _lower) >> 1 ) if data[p] < _gorgyrella_parser_trans_keys[_mid] _upper = _mid - 1 elsif data[p] > _gorgyrella_parser_trans_keys[_mid] _lower = _mid + 1 else _trans += (_mid - _keys) _break_match = true break end end # loop break if _break_match _keys += _klen _trans += _klen end _klen = _gorgyrella_parser_range_lengths[cs] if _klen > 0 _lower = _keys _upper = _keys + (_klen << 1) - 2 loop do break if _upper < _lower _mid = _lower + (((_upper-_lower) >> 1) & ~1) if data[p] < _gorgyrella_parser_trans_keys[_mid] _upper = _mid - 2 elsif data[p] > _gorgyrella_parser_trans_keys[_mid+1] _lower = _mid + 2 else _trans += ((_mid - _keys) >> 1) _break_match = true break end end # loop break if _break_match _trans += _klen end end while false cs = _gorgyrella_parser_trans_targs[_trans] if _gorgyrella_parser_trans_actions[_trans] != 0 _acts = _gorgyrella_parser_trans_actions[_trans] _nacts = _gorgyrella_parser_actions[_acts] _acts += 1 while _nacts > 0 _nacts -= 1 _acts += 1 case _gorgyrella_parser_actions[_acts - 1] when 0 then # line 6 "lib/gorgyrella/parser.rl" begin context = data[p - 30, 60].pack("c*") rescue context ||= data[p - 10, 20].pack("c*") rescue context ||= data[p-10, 10].pack("c*") context ||= "not available" raise "an error occurred parsing character " + p.to_s + " code: " + data[p].to_s + " chr: ->" + data[p, 1].pack("c*") + "<- \ncontext: " + context end # line 6 "lib/gorgyrella/parser.rl" when 1 then # line 14 "lib/gorgyrella/parser.rl" begin start = p end # line 14 "lib/gorgyrella/parser.rl" when 2 then # line 18 "lib/gorgyrella/parser.rl" begin text = data[start, p - start].pack("c*").strip end # line 18 "lib/gorgyrella/parser.rl" when 3 then # line 22 "lib/gorgyrella/parser.rl" begin filename = nil section = nil format = nil language = nil command = nil end # line 22 "lib/gorgyrella/parser.rl" when 4 then # line 30 "lib/gorgyrella/parser.rl" begin case command when :include builder.append_section( :command => 'include', :file => filename, :section => section, :format => format, :language => language ) when :export builder.append_section(:section => section, :language => language) when :end builder.append_section else raise command end end # line 30 "lib/gorgyrella/parser.rl" when 5 then # line 49 "lib/gorgyrella/parser.rl" begin location = "start" line_start_pos = p end # line 49 "lib/gorgyrella/parser.rl" when 6 then # line 54 "lib/gorgyrella/parser.rl" begin current_line_text = data[line_start_pos, p - line_start_pos].pack("c*") line_data << [p, cs, current_line_text] end # line 54 "lib/gorgyrella/parser.rl" when 7 then # line 70 "lib/gorgyrella/parser.rl" begin filename = text end # line 70 "lib/gorgyrella/parser.rl" when 8 then # line 71 "lib/gorgyrella/parser.rl" begin section = text end # line 71 "lib/gorgyrella/parser.rl" when 9 then # line 72 "lib/gorgyrella/parser.rl" begin format = text end # line 72 "lib/gorgyrella/parser.rl" when 10 then # line 73 "lib/gorgyrella/parser.rl" begin language = text end # line 73 "lib/gorgyrella/parser.rl" when 11 then # line 82 "lib/gorgyrella/parser.rl" begin location = 'include command' end # line 82 "lib/gorgyrella/parser.rl" when 12 then # line 82 "lib/gorgyrella/parser.rl" begin command = :include end # line 82 "lib/gorgyrella/parser.rl" when 13 then # line 83 "lib/gorgyrella/parser.rl" begin location = 'export command' end # line 83 "lib/gorgyrella/parser.rl" when 14 then # line 83 "lib/gorgyrella/parser.rl" begin command = :export end # line 83 "lib/gorgyrella/parser.rl" when 15 then # line 84 "lib/gorgyrella/parser.rl" begin location = 'end command' end # line 84 "lib/gorgyrella/parser.rl" when 16 then # line 84 "lib/gorgyrella/parser.rl" begin command = :end end # line 84 "lib/gorgyrella/parser.rl" when 17 then # line 102 "lib/gorgyrella/parser.rl" begin builder.append_line(current_line_text.chomp) unless location =~ /command/ end # line 102 "lib/gorgyrella/parser.rl" # line 562 "lib/gorgyrella/parser.rb" end # action switch end end if _trigger_goto next end end if _goto_level <= _again if cs == 0 _goto_level = _out next end p += 1 if p != pe _goto_level = _resume next end end if _goto_level <= _test_eof if p == eof __acts = _gorgyrella_parser_eof_actions[cs] __nacts = _gorgyrella_parser_actions[__acts] __acts += 1 while __nacts > 0 __nacts -= 1 __acts += 1 case _gorgyrella_parser_actions[__acts - 1] when 0 then # line 6 "lib/gorgyrella/parser.rl" begin context = data[p - 30, 60].pack("c*") rescue context ||= data[p - 10, 20].pack("c*") rescue context ||= data[p-10, 10].pack("c*") context ||= "not available" raise "an error occurred parsing character " + p.to_s + " code: " + data[p].to_s + " chr: ->" + data[p, 1].pack("c*") + "<- \ncontext: " + context end # line 6 "lib/gorgyrella/parser.rl" when 6 then # line 54 "lib/gorgyrella/parser.rl" begin current_line_text = data[line_start_pos, p - line_start_pos].pack("c*") line_data << [p, cs, current_line_text] end # line 54 "lib/gorgyrella/parser.rl" when 17 then # line 102 "lib/gorgyrella/parser.rl" begin builder.append_line(current_line_text.chomp) unless location =~ /command/ end # line 102 "lib/gorgyrella/parser.rl" # line 614 "lib/gorgyrella/parser.rb" end # eof action switch end if _trigger_goto next end end end if _goto_level <= _out break end end end # line 124 "lib/gorgyrella/parser.rl" if test_mode [builder, line_data] else builder end end ### @end end end