side

in lib/twitter_cldr/transforms/conversions/parser.rb [39:73]


        def side
          prev_cluster = next_token_cluster
          before_context = nil
          after_context = nil
          key = nil
          cursor_offset = 0

          until current_token.type == :direction || current_token.type == :semicolon
            case current_token.type
              when :before_context
                before_context = prev_cluster
                next_token(:before_context)
                prev_cluster = next_token_cluster
              when :cursor
                next_token(:cursor)
                cur_cluster = next_token_cluster
                key = prev_cluster + cur_cluster
                prev_cluster = cur_cluster
                cursor_offset = -cur_cluster.size
              when :after_context
                next_token(:after_context)
                after_context = next_token_cluster
            end
          end

          key ||= prev_cluster

          Side.new(
            join_values(before_context),
            key,
            join_values(after_context),
            cursor_offset
          )
        end