def process_text
      regex_string = '((\[ (\/)? ( \* | (\w+)) ((=[^\[\]]+) | (\s\w+=\w+)* | ([^\]]*))? \]) | ([^\[]+))'
      @text.scan(/#{regex_string}/ix) do |tag_info|
        @ti = TagInfo.new(tag_info, @dictionary)

        # if the tag isn't in the @dictionary list, then treat it as text
        @ti.handle_tag_as_text if @ti.element_is_tag? and !@ti.tag_in_dictionary?

        validate_element

        case @ti.type
        when :opening_tag
          element = {:is_tag => true, :tag => @ti[:tag], :definition => @ti.definition, :errors => @ti[:errors], :nodes => TagCollection.new }
          element[:invalid_quick_param] = true if @ti.invalid_quick_param?
          element[:params] = get_formatted_element_params

          @bbtree.retrogress_bbtree if self_closing_tag_reached_a_closer?

          @bbtree.build_up_new_tag(element)

          @bbtree.escalate_bbtree(element)
        when :text
          tag_def = @bbtree.current_node.definition
          if tag_def and tag_def[:multi_tag] == true
            set_multi_tag_to_actual_tag
            tag_def = @bbtree.current_node.definition
          end

          if within_open_tag? and tag_def[:require_between]
            between = get_formatted_between
            @bbtree.current_node[:between] = between
            if use_text_as_parameter?
              value_array = tag_def[:quick_param_format].nil? ? true : between.scan(tag_def[:quick_param_format])[0]
              if value_array.nil?
                if @ti[:invalid_quick_param].nil?
                  # Add text element (with error(s))
                  add_element = true

                  # ...and clear between, as this would result in two 'between' texts
                  @bbtree.current_node[:between] = ""
                end
              else
                # Between text can be used as (first) parameter
                @bbtree.current_node[:params][tag_def[:param_tokens][0][:token]] = between
              end
            end
            # Don't add this text node, as it is used as between (and might be used as first param)
            next unless add_element
          end

          create_text_element
        when :closing_tag
          if @ti[:wrong_closing]
            # Convert into text, so it
            @ti.handle_tag_as_text
            create_text_element
          else
            @bbtree.retrogress_bbtree if parent_of_self_closing_tag? and within_open_tag?
            @bbtree.retrogress_bbtree
          end
        end
      end # end of scan loop

      validate_all_tags_closed_off
      validate_stack_level_too_deep_potential
    end
def process_text
      regex_string = '((\[ (\/)? ( \* | (\w+)) ((=[^\[\]]+) | (\s\w+=\w+)* | ([^\]]*))? \]) | ([^\[]+))'
      @text.scan(/#{regex_string}/ix) do |tag_info|
        @ti = TagInfo.new(tag_info, @dictionary)

        # if the tag isn't in the @dictionary list, then treat it as text
        @ti.handle_tag_as_text if @ti.element_is_tag? and !@ti.tag_in_dictionary?

        validate_element

        case @ti.type
        when :opening_tag
          element = {:is_tag => true, :tag => @ti[:tag], :definition => @ti.definition, :errors => @ti[:errors], :nodes => TagCollection.new }
          element[:invalid_quick_param] = true if @ti.invalid_quick_param?
          element[:params] = get_formatted_element_params

          @bbtree.retrogress_bbtree if self_closing_tag_reached_a_closer?

          @bbtree.build_up_new_tag(element)

          @bbtree.escalate_bbtree(element)
        when :text
          tag_def = @bbtree.current_node.definition
          if tag_def and tag_def[:multi_tag] == true
            set_multi_tag_to_actual_tag
            tag_def = @bbtree.current_node.definition
          end

          if within_open_tag? and tag_def[:require_between]
            between = get_formatted_between
            @bbtree.current_node[:between] = between
            if use_text_as_parameter?
              value_array = tag_def[:quick_param_format].nil? ? true : between.scan(tag_def[:quick_param_format])[0]
              if value_array.nil?
                if @ti[:invalid_quick_param].nil?
                  # Add text element (with error(s))
                  add_element = true

                  # ...and clear between, as this would result in two 'between' texts
                  @bbtree.current_node[:between] = ""
                end
              else
                # Between text can be used as (first) parameter
                @bbtree.current_node[:params][tag_def[:param_tokens][0][:token]] = between
              end
            end
            # Don't add this text node, as it is used as between (and might be used as first param)
            next unless add_element
          end

          create_text_element
        when :closing_tag
          if @ti[:wrong_closing]
            # Convert into text, so it
            @ti.handle_tag_as_text
            create_text_element
          else
            @bbtree.retrogress_bbtree if parent_of_self_closing_tag? and within_open_tag?
            @bbtree.retrogress_bbtree
          end
        end
      end # end of scan loop

      validate_all_tags_closed_off
      validate_stack_level_too_deep_potential
    end
BBTree#process_text is responsible for parsing the actual BBCode text and converting it
 into a 'syntax tree' of nodes, each node represeting either a tag type or content for a tag
 once this tree is built, the to_html method can be invoked where the tree is finally
 converted into HTML syntax.