# # DO NOT MODIFY!!!! # This file is automatically generated by Racc 1.4.6 # from Racc grammer file "". # require 'racc/parser.rb' # # generated by racc # require File.dirname(__FILE__) + '/lexer' module OFX module OFX102 class Parser < Racc::Parser module_eval(<<'...end ofx_102.racc/module_eval...', 'ofx_102.racc', 48) attr :documents attr :ofx_hashes def initialize @documents = [] @ofx_hashes = [] @tags_stack = [] end private def start_tag(tag_name) # push an empty aggregate/value tag @tags_stack.push({ tag_name => {} }) end def data_value(value) # pop the most recent tag, and use it's name as the key in the next higher tag's hash tag = @tags_stack.pop @tags_stack.last[@tags_stack.last.keys[0]][tag.keys[0]] = CGI::unescapeHTML(value) end def end_tag(tag_name) # pop the most recent tag, stop and recognize this as a full document if this is the last tag; otherwise, # use this tag's naem as the key in the next higher tag's hash tag = @tags_stack.pop if (@tags_stack.empty?) @ofx_hashes << tag @documents << OFX::Document.from_ofx_102_hash(tag) else previous = @tags_stack.last[@tags_stack.last.keys[0]][tag.keys[0]] if previous == nil @tags_stack.last[@tags_stack.last.keys[0]][tag.keys[0]] = tag[tag.keys[0]] elsif previous.kind_of?(Array) previous << tag[tag.keys[0]] else @tags_stack.last[@tags_stack.last.keys[0]][tag.keys[0]] = [previous, tag[tag.keys[0]]] end end end ...end ofx_102.racc/module_eval... ##### State transition tables begin ### racc_action_table = [ 1, 6, 1, 14, 15, 14, 15, 8, 9, 5, 17, 19, 20, 1 ] racc_action_check = [ 18, 2, 7, 18, 18, 7, 7, 5, 6, 1, 14, 16, 17, 0 ] racc_action_pointer = [ 11, 6, 1, nil, nil, 3, 8, 0, nil, nil, nil, nil, nil, nil, 7, nil, 5, 8, -2, nil, nil, nil ] racc_action_default = [ -1, -13, -13, -2, -6, -13, -13, -13, -4, 22, -3, -7, -9, -10, -13, -8, -6, -13, -13, -12, -5, -11 ] racc_goto_table = [ 7, 4, 10, 3, 2, nil, nil, nil, nil, nil, nil, nil, 18, 21 ] racc_goto_check = [ 4, 3, 5, 2, 1, nil, nil, nil, nil, nil, nil, nil, 4, 5 ] racc_goto_pointer = [ nil, 4, 3, 1, -4, -5, nil, nil, nil ] racc_goto_default = [ nil, nil, nil, 16, nil, nil, 11, 12, 13 ] racc_reduce_table = [ 0, 0, :racc_error, 0, 8, :_reduce_none, 1, 8, :_reduce_none, 3, 9, :_reduce_none, 3, 10, :_reduce_4, 3, 12, :_reduce_5, 0, 11, :_reduce_none, 2, 11, :_reduce_none, 1, 13, :_reduce_none, 1, 13, :_reduce_none, 1, 13, :_reduce_none, 3, 14, :_reduce_none, 2, 15, :_reduce_12 ] racc_reduce_n = 13 racc_shift_n = 22 racc_token_table = { false => 0, :error => 1, :tag_in => 2, :element => 3, :tag_out => 4, :etag_in => 5, :text => 6 } racc_nt_base = 7 racc_use_result_var = true Racc_arg = [ racc_action_table, racc_action_check, racc_action_default, racc_action_pointer, racc_goto_table, racc_goto_check, racc_goto_default, racc_goto_pointer, racc_nt_base, racc_reduce_table, racc_token_table, racc_shift_n, racc_reduce_n, racc_use_result_var ] Racc_token_to_s_table = [ "$end", "error", "tag_in", "element", "tag_out", "etag_in", "text", "$start", "target", "ofx_body", "tag_from", "contents", "tag_to", "content", "aggregate", "value" ] Racc_debug_parser = false ##### State transition tables end ##### # reduce 0 omitted # reduce 1 omitted # reduce 2 omitted # reduce 3 omitted module_eval(<<'.,.,', 'ofx_102.racc', 25) def _reduce_4(val, _values, result) start_tag(val[1]) result end .,., module_eval(<<'.,.,', 'ofx_102.racc', 26) def _reduce_5(val, _values, result) end_tag(val[1]) result end .,., # reduce 6 omitted # reduce 7 omitted # reduce 8 omitted # reduce 9 omitted # reduce 10 omitted # reduce 11 omitted module_eval(<<'.,.,', 'ofx_102.racc', 36) def _reduce_12(val, _values, result) data_value(val[1]) result end .,., def _reduce_none(val, _values, result) val[0] end end # class Parser end # module OFX102 end # module OFX