Path: blob/trunk/rake_tasks/crazy_fun/build_grammar.rb
2867 views
# line 1 "rake-tasks/crazy_fun/build_grammar.rl"12class BuildFile3# line 73 "rake-tasks/crazy_fun/build_grammar.rl"4def parse(data)5# line 12 "rake-tasks/crazy_fun/build_grammar.rb"6class << self7attr_accessor :_build_grammar_trans_keys8private :_build_grammar_trans_keys, :_build_grammar_trans_keys=9end1011self._build_grammar_trans_keys = [120, 0, 9, 122, 10, 13,1340, 122, 9, 122, 9,14122, 9, 122, 9, 61,159, 91, 34, 34, 9, 44,1610, 13, 9, 123, 34,1734, 9, 93, 9, 123,189, 44, 9, 34, 34, 34,199, 58, 9, 34, 34,2034, 9, 125, 9, 125,219, 93, 9, 122, 9, 122,22023]2425class << self26attr_accessor :_build_grammar_key_spans27private :_build_grammar_key_spans, :_build_grammar_key_spans=28end2930self._build_grammar_key_spans = [310, 114, 4, 83, 114, 114, 114, 53,3283, 1, 36, 4, 115, 1, 85, 115,3336, 26, 1, 50, 26, 1, 117, 117,3485, 114, 11435]3637class << self38attr_accessor :_build_grammar_index_offsets39private :_build_grammar_index_offsets, :_build_grammar_index_offsets=40end4142self._build_grammar_index_offsets = [430, 0, 115, 120, 204, 319, 434, 549,44603, 687, 689, 726, 731, 847, 849, 935,451051, 1088, 1115, 1117, 1168, 1195, 1197, 1315,461433, 1519, 163447]4849class << self50attr_accessor :_build_grammar_indicies51private :_build_grammar_indicies, :_build_grammar_indicies=52end5354self._build_grammar_indicies = [550, 0, 0, 0, 0, 1, 1, 1,561, 1, 1, 1, 1, 1, 1, 1,571, 1, 1, 1, 1, 1, 1, 0,581, 1, 2, 1, 1, 1, 1, 1,591, 1, 1, 1, 1, 1, 1, 1,601, 1, 1, 1, 1, 1, 1, 1,611, 1, 1, 1, 1, 1, 1, 1,621, 1, 1, 1, 1, 1, 1, 1,631, 1, 1, 1, 1, 1, 1, 1,641, 1, 1, 1, 1, 1, 1, 1,651, 1, 1, 1, 1, 1, 1, 1,663, 3, 3, 3, 3, 3,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1, 1,1111, 1, 1, 1, 1, 1, 1, 1,1121, 10, 1, 1, 1, 1, 1, 1,1131, 1, 1, 1, 1, 1, 1, 1,1141, 11, 11, 11, 11, 11, 11, 11,11511, 11, 11, 1, 1, 1, 12, 1,1161, 1, 1, 1, 1, 1, 1, 1,1171, 1, 1, 1, 1, 1, 1, 1,1181, 1, 1, 1, 1, 1, 1, 1,1191, 1, 1, 1, 1, 1, 1, 1,12011, 1, 11, 11, 11, 11, 11, 11,12111, 11, 11, 11, 11, 11, 11, 11,12211, 11, 11, 11, 11, 11, 11, 11,12311, 11, 11, 11, 1, 13, 13, 13,12413, 13, 1, 1, 1, 1, 1, 1,1251, 1, 1, 1, 1, 1, 1, 1,1261, 1, 1, 1, 13, 1, 1, 1,1271, 1, 1, 1, 1, 1, 1, 1,1281, 1, 1, 1, 1, 1, 1, 1,1291, 1, 1, 1, 1, 1, 1, 1,1301, 14, 1, 14, 14, 14, 14, 14,1311, 1, 1, 1, 1, 1, 1, 1,1321, 1, 1, 1, 1, 1, 1, 1,1331, 1, 14, 1, 15, 1, 1, 1,1341, 1, 1, 1, 1, 1, 1, 1,1351, 1, 1, 1, 1, 1, 1, 1,1361, 1, 1, 1, 1, 1, 1, 1,1371, 1, 1, 1, 1, 1, 1, 1,1381, 1, 1, 1, 1, 1, 1, 1,1391, 1, 1, 1, 1, 1, 1, 1,1401, 1, 1, 1, 1, 16, 1, 18,14117, 19, 19, 19, 19, 19, 1, 1,1421, 1, 1, 1, 1, 1, 1, 1,1431, 1, 1, 1, 1, 1, 1, 1,14419, 1, 1, 1, 1, 1, 1, 1,1451, 20, 1, 1, 4, 1, 22, 21,14621, 22, 21, 23, 23, 23, 23, 23,1471, 1, 1, 1, 1, 1, 1, 1,1481, 1, 1, 1, 1, 1, 1, 1,1491, 1, 23, 1, 24, 1, 1, 1,1501, 1, 1, 1, 1, 1, 1, 1,1511, 1, 1, 1, 1, 1, 1, 1,1521, 1, 1, 1, 1, 1, 1, 1,1531, 1, 1, 1, 1, 1, 1, 1,1541, 1, 1, 1, 1, 1, 1, 1,1551, 1, 1, 1, 1, 1, 1, 1,1561, 1, 1, 1, 1, 1, 1, 1,1571, 1, 1, 1, 1, 1, 1, 1,1581, 1, 1, 1, 1, 1, 1, 1,1591, 1, 1, 1, 1, 1, 1, 1,1601, 1, 1, 1, 1, 25, 1, 27,16126, 28, 28, 28, 28, 28, 1, 1,1621, 1, 1, 1, 1, 1, 1, 1,1631, 1, 1, 1, 1, 1, 1, 1,16428, 1, 1, 1, 1, 1, 1, 1,1651, 1, 1, 1, 29, 1, 1, 1,1661, 1, 1, 1, 1, 1, 1, 1,1671, 1, 1, 1, 1, 1, 1, 1,1681, 1, 1, 1, 1, 1, 1, 1,1691, 1, 1, 1, 1, 1, 1, 1,1701, 1, 1, 1, 1, 1, 1, 1,1711, 1, 1, 1, 1, 30, 1, 29,17229, 29, 29, 29, 1, 1, 1, 1,1731, 1, 1, 1, 1, 1, 1, 1,1741, 1, 1, 1, 1, 1, 29, 1,17524, 1, 1, 1, 1, 1, 1, 1,1761, 1, 1, 1, 1, 1, 1, 1,1771, 1, 1, 1, 1, 1, 1, 1,1781, 1, 1, 1, 1, 1, 1, 1,1791, 1, 1, 1, 1, 1, 1, 1,1801, 1, 1, 1, 1, 1, 1, 1,1811, 1, 1, 1, 1, 1, 1, 1,1821, 1, 1, 30, 1, 1, 1, 1,1831, 1, 1, 1, 1, 1, 1, 1,1841, 1, 1, 1, 1, 1, 1, 1,1851, 1, 1, 1, 1, 1, 1, 1,1861, 25, 1, 18, 18, 18, 18, 18,1871, 1, 1, 1, 1, 1, 1, 1,1881, 1, 1, 1, 1, 1, 1, 1,1891, 1, 18, 1, 1, 1, 1, 1,1901, 1, 1, 20, 1, 1, 4, 1,19131, 31, 31, 31, 31, 1, 1, 1,1921, 1, 1, 1, 1, 1, 1, 1,1931, 1, 1, 1, 1, 1, 1, 31,1941, 32, 1, 34, 33, 35, 35, 35,19535, 35, 1, 1, 1, 1, 1, 1,1961, 1, 1, 1, 1, 1, 1, 1,1971, 1, 1, 1, 35, 1, 1, 1,1981, 1, 1, 1, 1, 1, 1, 1,1991, 1, 1, 1, 1, 1, 1, 1,2001, 1, 1, 1, 1, 1, 36, 1,20136, 36, 36, 36, 36, 1, 1, 1,2021, 1, 1, 1, 1, 1, 1, 1,2031, 1, 1, 1, 1, 1, 1, 36,2041, 37, 1, 39, 38, 40, 40, 40,20540, 40, 1, 1, 1, 1, 1, 1,2061, 1, 1, 1, 1, 1, 1, 1,2071, 1, 1, 1, 40, 1, 1, 1,2081, 1, 1, 1, 1, 1, 1, 1,20941, 1, 1, 1, 1, 1, 1, 1,2101, 1, 1, 1, 1, 1, 1, 1,2111, 1, 1, 1, 1, 1, 1, 1,2121, 1, 1, 1, 1, 1, 1, 1,2131, 1, 1, 1, 1, 1, 1, 1,2141, 1, 1, 1, 1, 1, 1, 1,2151, 1, 1, 1, 1, 1, 1, 1,2161, 1, 1, 1, 1, 1, 1, 1,2171, 1, 1, 1, 1, 1, 1, 1,2181, 1, 1, 1, 1, 1, 1, 1,2191, 42, 1, 43, 43, 43, 43, 43,2201, 1, 1, 1, 1, 1, 1, 1,2211, 1, 1, 1, 1, 1, 1, 1,2221, 1, 43, 1, 1, 1, 1, 1,2231, 1, 1, 1, 1, 1, 31, 1,2241, 1, 1, 1, 1, 1, 1, 1,2251, 1, 1, 1, 1, 1, 1, 1,2261, 1, 1, 1, 1, 1, 1, 1,2271, 1, 1, 1, 1, 1, 1, 1,2281, 1, 1, 1, 1, 1, 1, 1,2291, 1, 1, 1, 1, 1, 1, 1,2301, 1, 1, 1, 1, 1, 1, 1,2311, 1, 1, 1, 1, 1, 1, 1,2321, 1, 1, 1, 1, 1, 1, 1,2331, 1, 1, 1, 1, 1, 1, 44,2341, 27, 27, 27, 27, 27, 1, 1,2351, 1, 1, 1, 1, 1, 1, 1,2361, 1, 1, 1, 1, 1, 1, 1,23727, 1, 1, 1, 1, 1, 1, 1,2381, 1, 1, 1, 45, 1, 1, 1,2391, 1, 1, 1, 1, 1, 1, 1,2401, 1, 1, 1, 1, 1, 1, 1,2411, 1, 1, 1, 1, 1, 1, 1,2421, 1, 1, 1, 1, 1, 1, 1,2431, 1, 1, 1, 1, 1, 1, 1,2441, 1, 1, 1, 1, 46, 1, 47,24547, 47, 47, 47, 1, 1, 1, 1,2461, 1, 1, 1, 1, 1, 1, 1,2471, 1, 1, 1, 1, 1, 47, 1,2481, 48, 1, 1, 1, 1, 1, 1,2491, 1, 1, 1, 1, 1, 1, 1,2501, 1, 1, 1, 1, 1, 1, 1,2511, 1, 1, 1, 1, 1, 1, 1,2521, 1, 1, 1, 1, 1, 1, 1,2531, 1, 1, 1, 1, 1, 1, 1,2541, 1, 1, 1, 1, 1, 1, 1,2551, 1, 1, 1, 1, 1, 1, 49,25649, 49, 49, 49, 49, 49, 49, 49,25749, 49, 49, 49, 49, 49, 49, 49,25849, 49, 49, 49, 49, 49, 49, 49,25949, 1, 22, 22, 22, 22, 22, 1,2601, 1, 1, 1, 1, 1, 1, 1,2611, 1, 1, 1, 1, 1, 1, 1,2621, 22, 1, 1, 21, 1, 1, 1,2631, 1, 1, 1, 1, 1, 1, 1,2641, 1, 1, 1, 1, 1, 1, 1,2651, 1, 1, 1, 1, 1, 1, 1,2661, 1, 1, 1, 1, 1, 1, 1,2671, 1, 1, 1, 1, 1, 1, 1,2681, 1, 1, 1, 1, 1, 1, 1,2691, 1, 1, 1, 1, 1, 1, 1,2701, 1, 3, 3, 3, 3, 3, 3,2713, 3, 3, 3, 3, 3, 3, 3,2723, 3, 3, 3, 3, 3, 3, 3,2733, 3, 3, 3, 1, 0274]275276class << self277attr_accessor :_build_grammar_trans_targs278private :_build_grammar_trans_targs, :_build_grammar_trans_targs=279end280281self._build_grammar_trans_targs = [2821, 0, 2, 3, 4, 3, 5, 6,2835, 6, 7, 6, 8, 7, 8, 9,28412, 9, 10, 10, 25, 11, 26, 12,28513, 17, 13, 14, 14, 15, 16, 17,28618, 18, 19, 19, 20, 21, 21, 22,28723, 17, 24, 23, 24, 15, 16, 26,28811, 3289]290291class << self292attr_accessor :_build_grammar_trans_actions293private :_build_grammar_trans_actions, :_build_grammar_trans_actions=294end295296self._build_grammar_trans_actions = [2970, 0, 0, 1, 2, 3, 4, 5,2980, 6, 2, 3, 2, 0, 0, 7,2998, 3, 2, 0, 9, 0, 10, 0,3007, 11, 3, 2, 0, 0, 0, 0,30112, 3, 2, 0, 0, 7, 3, 2,3022, 2, 2, 0, 0, 2, 2, 9,3032, 13304]305306class << self307attr_accessor :_build_grammar_eof_actions308private :_build_grammar_eof_actions, :_build_grammar_eof_actions=309end310311self._build_grammar_eof_actions = [3120, 0, 0, 0, 0, 0, 0, 0,3130, 0, 0, 0, 0, 0, 0, 0,3140, 0, 0, 0, 0, 0, 0, 0,3150, 2, 0316]317318class << self319attr_accessor :build_grammar_start320end321322self.build_grammar_start = 1323324class << self325attr_accessor :build_grammar_first_final326end327328self.build_grammar_first_final = 25329330class << self331attr_accessor :build_grammar_error332end333334self.build_grammar_error = 0335336class << self337attr_accessor :build_grammar_en_main338end339340self.build_grammar_en_main = 1341342# line 77 "rake-tasks/crazy_fun/build_grammar.rl"343@data = data344@data = @data.unpack("c*") if @data.is_a?(String)345# line 343 "rake-tasks/crazy_fun/build_grammar.rb"346begin347@p ||= 0348pe ||= @data.length349cs = build_grammar_start350end351352# line 82 "rake-tasks/crazy_fun/build_grammar.rl"353354begin355# line 354 "rake-tasks/crazy_fun/build_grammar.rb"356begin357testEof = false358_slen, _trans, _keys, _inds, _acts, _nacts = nil359_goto_level = 0360_resume = 10361_eof_trans = 15362_again = 20363_test_eof = 30364_out = 40365while true366if _goto_level <= 0367if @p == pe368_goto_level = _test_eof369next370end371372if cs == 0373_goto_level = _out374next375end376end377378if _goto_level <= _resume379_keys = cs << 1380_inds = _build_grammar_index_offsets[cs]381_slen = _build_grammar_key_spans[cs]382_trans =383if (_slen > 0 && _build_grammar_trans_keys[_keys] <= @data[ @p] && @data[ @p] <= _build_grammar_trans_keys[_keys + 1])384_build_grammar_indicies[ _inds + @data[ @p] - _build_grammar_trans_keys[_keys] ]385else386_build_grammar_indicies[ _inds + _slen ]387end388cs = _build_grammar_trans_targs[_trans]389if _build_grammar_trans_actions[_trans] != 0390case _build_grammar_trans_actions[_trans]391when 4392# line 10 "rake-tasks/crazy_fun/build_grammar.rl"393begin394# clear the stack395while !@lhs[-1].is_a? OutputType396leave397end398399puts "Starting arg" if @debug400@lhs.push ArgType.new401end402# line 10 "rake-tasks/crazy_fun/build_grammar.rl"403when 8404# line 23 "rake-tasks/crazy_fun/build_grammar.rl"405begin406puts "Starting array" if @debug407@lhs.push ArrayType.new408end409# line 23 "rake-tasks/crazy_fun/build_grammar.rl"410when 11411# line 27 "rake-tasks/crazy_fun/build_grammar.rl"412begin413414puts "Starting map" if @debug415@lhs.push MapType.new416end417# line 27 "rake-tasks/crazy_fun/build_grammar.rl"418when 7419# line 35 "rake-tasks/crazy_fun/build_grammar.rl"420begin421if @data[@p + 1].chr == ':'422puts "Starting symbol" if @debug423@lhs.push SymbolType.new424@p = @p + 1425else426puts "Starting string" if @debug427@lhs.push StringType.new428end429end430# line 35 "rake-tasks/crazy_fun/build_grammar.rl"431when 10432# line 56 "rake-tasks/crazy_fun/build_grammar.rl"433begin434while (!@lhs.empty?)435leave436end437end438# line 56 "rake-tasks/crazy_fun/build_grammar.rl"439when 3440# line 67 "rake-tasks/crazy_fun/build_grammar.rl"441begin442@lhs[-1] << @data[@p].chr443end444# line 67 "rake-tasks/crazy_fun/build_grammar.rl"445when 2446# line 68 "rake-tasks/crazy_fun/build_grammar.rl"447begin448leave449end450# line 68 "rake-tasks/crazy_fun/build_grammar.rl"451when 6452# line 19 "rake-tasks/crazy_fun/build_grammar.rl"453begin454puts "Starting arg name" if @debug455@lhs.push SymbolType.new456end457# line 19 "rake-tasks/crazy_fun/build_grammar.rl"458# line 67 "rake-tasks/crazy_fun/build_grammar.rl"459begin460@lhs[-1] << @data[@p].chr461end462# line 67 "rake-tasks/crazy_fun/build_grammar.rl"463when 12464# line 31 "rake-tasks/crazy_fun/build_grammar.rl"465begin466puts "Starting map entry" if @debug467@lhs.push MapEntry.new468end469# line 31 "rake-tasks/crazy_fun/build_grammar.rl"470# line 35 "rake-tasks/crazy_fun/build_grammar.rl"471begin472if @data[@p + 1].chr == ':'473puts "Starting symbol" if @debug474@lhs.push SymbolType.new475@p = @p + 1476else477puts "Starting string" if @debug478@lhs.push StringType.new479end480end481# line 35 "rake-tasks/crazy_fun/build_grammar.rl"482when 9483# line 68 "rake-tasks/crazy_fun/build_grammar.rl"484begin485leave486end487# line 68 "rake-tasks/crazy_fun/build_grammar.rl"488# line 56 "rake-tasks/crazy_fun/build_grammar.rl"489begin490while (!@lhs.empty?)491leave492end493end494# line 56 "rake-tasks/crazy_fun/build_grammar.rl"495when 5496# line 10 "rake-tasks/crazy_fun/build_grammar.rl"497begin498# clear the stack499while !@lhs[-1].is_a? OutputType500leave501end502503puts "Starting arg" if @debug504@lhs.push ArgType.new505end506# line 10 "rake-tasks/crazy_fun/build_grammar.rl"507# line 19 "rake-tasks/crazy_fun/build_grammar.rl"508begin509puts "Starting arg name" if @debug510@lhs.push SymbolType.new511end512# line 19 "rake-tasks/crazy_fun/build_grammar.rl"513# line 67 "rake-tasks/crazy_fun/build_grammar.rl"514begin515@lhs[-1] << @data[@p].chr516end517# line 67 "rake-tasks/crazy_fun/build_grammar.rl"518when 1519# line 45 "rake-tasks/crazy_fun/build_grammar.rl"520begin521puts "Starting type" if @debug522# Unwind the stack until the top is another OutputType (or it's empty)523while (!@lhs.empty?)524puts "Unwinding [#{@lhs}]" + @lhs.length.to_s525leave526end527528@lhs.push OutputType.new529end530# line 45 "rake-tasks/crazy_fun/build_grammar.rl"531# line 62 "rake-tasks/crazy_fun/build_grammar.rl"532begin533puts "Starting type name" if @debug534@lhs.push NameType.new535end536# line 62 "rake-tasks/crazy_fun/build_grammar.rl"537# line 67 "rake-tasks/crazy_fun/build_grammar.rl"538begin539@lhs[-1] << @data[@p].chr540end541# line 67 "rake-tasks/crazy_fun/build_grammar.rl"542when 13543# line 68 "rake-tasks/crazy_fun/build_grammar.rl"544begin545leave546end547# line 68 "rake-tasks/crazy_fun/build_grammar.rl"548# line 45 "rake-tasks/crazy_fun/build_grammar.rl"549begin550puts "Starting type" if @debug551# Unwind the stack until the top is another OutputType (or it's empty)552while (!@lhs.empty?)553puts "Unwinding [#{@lhs}]" + @lhs.length.to_s554leave555end556557@lhs.push OutputType.new558end559# line 45 "rake-tasks/crazy_fun/build_grammar.rl"560# line 62 "rake-tasks/crazy_fun/build_grammar.rl"561begin562puts "Starting type name" if @debug563@lhs.push NameType.new564end565# line 62 "rake-tasks/crazy_fun/build_grammar.rl"566# line 67 "rake-tasks/crazy_fun/build_grammar.rl"567begin568@lhs[-1] << @data[@p].chr569end570# line 67 "rake-tasks/crazy_fun/build_grammar.rl"571# line 582 "rake-tasks/crazy_fun/build_grammar.rb"572end573574# THIS IS THE END OF THE HUMONGOUS CASE STATEMENT - Luke - Sep 2019575end576end577578if _goto_level <= _again579if cs == 0580_goto_level = _out581next582end583584@p += 1585586if @p != pe587_goto_level = _resume588next589end590end591592if _goto_level <= _test_eof593if @p == @eof594case _build_grammar_eof_actions[cs]595when 2596# line 68 "rake-tasks/crazy_fun/build_grammar.rl"597begin598leave599end600# line 68 "rake-tasks/crazy_fun/build_grammar.rl"601# line 607 "rake-tasks/crazy_fun/build_grammar.rb"602end603end604end605606if _goto_level <= _out607break608end609end610end611# line 85 "rake-tasks/crazy_fun/build_grammar.rl"612rescue613puts show_bad_line614throw $!615end616617if cs == build_grammar_error618throw show_bad_line619end620621@types622end623end624625626