code-ruby-parser 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/code-ruby-parser.gemspec +3 -1
- data/lib/code-ruby-parser.rb +1 -7
- data/lib/template-ruby-parser.rb +1 -7
- data/template-ruby-parser.gemspec +3 -1
- metadata +18 -137
- data/.overcommit.yml +0 -4
- data/CHANGELOG.md +0 -35
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -32
- data/bin/code-parser +0 -27
- data/bin/deploy +0 -16
- data/bin/format +0 -3
- data/bin/parse-docs +0 -6
- data/bin/template-parser +0 -27
- data/docs/class.code +0 -9
- data/docs/meetup.code +0 -14
- data/docs/precedence.code +0 -1
- data/docs/precedence.template +0 -35
- data/docs/rain.code +0 -23
- data/docs/slack.code +0 -17
- data/docs/stripe.code +0 -7
- data/docs/twitter.code +0 -7
- data/lib/code/parser/addition.rb +0 -13
- data/lib/code/parser/and_operator.rb +0 -13
- data/lib/code/parser/bitwise_and.rb +0 -13
- data/lib/code/parser/bitwise_or.rb +0 -13
- data/lib/code/parser/boolean.rb +0 -13
- data/lib/code/parser/call.rb +0 -183
- data/lib/code/parser/chained_call.rb +0 -41
- data/lib/code/parser/class.rb +0 -55
- data/lib/code/parser/code.rb +0 -20
- data/lib/code/parser/comments.rb +0 -46
- data/lib/code/parser/dictionnary.rb +0 -52
- data/lib/code/parser/equal.rb +0 -68
- data/lib/code/parser/equality.rb +0 -20
- data/lib/code/parser/error/syntax_error.rb +0 -36
- data/lib/code/parser/error.rb +0 -6
- data/lib/code/parser/function.rb +0 -118
- data/lib/code/parser/greater_than.rb +0 -13
- data/lib/code/parser/group.rb +0 -15
- data/lib/code/parser/if.rb +0 -81
- data/lib/code/parser/if_modifier.rb +0 -39
- data/lib/code/parser/list.rb +0 -20
- data/lib/code/parser/multiplication.rb +0 -13
- data/lib/code/parser/name.rb +0 -14
- data/lib/code/parser/negation.rb +0 -18
- data/lib/code/parser/not_keyword.rb +0 -26
- data/lib/code/parser/nothing.rb +0 -13
- data/lib/code/parser/number.rb +0 -57
- data/lib/code/parser/operation.rb +0 -65
- data/lib/code/parser/or_keyword.rb +0 -13
- data/lib/code/parser/or_operator.rb +0 -13
- data/lib/code/parser/power.rb +0 -33
- data/lib/code/parser/range.rb +0 -13
- data/lib/code/parser/rescue.rb +0 -38
- data/lib/code/parser/shift.rb +0 -13
- data/lib/code/parser/splat.rb +0 -35
- data/lib/code/parser/statement.rb +0 -9
- data/lib/code/parser/string.rb +0 -62
- data/lib/code/parser/ternary.rb +0 -73
- data/lib/code/parser/unary_minus.rb +0 -23
- data/lib/code/parser/while.rb +0 -36
- data/lib/code/parser.rb +0 -238
- data/lib/code.rb +0 -2
- data/lib/template/parser.rb +0 -32
- data/lib/template.rb +0 -2
- data/spec/code/parser/addition_spec.rb +0 -26
- data/spec/code/parser/and_operator_spec.rb +0 -26
- data/spec/code/parser/bitwise_and_spec.rb +0 -26
- data/spec/code/parser/bitwise_or_spec.rb +0 -26
- data/spec/code/parser/boolean_spec.rb +0 -13
- data/spec/code/parser/call_spec.rb +0 -52
- data/spec/code/parser/chained_call_spec.rb +0 -33
- data/spec/code/parser/class_spec.rb +0 -32
- data/spec/code/parser/code_spec.rb +0 -13
- data/spec/code/parser/dictionnary_spec.rb +0 -40
- data/spec/code/parser/equal_spec.rb +0 -42
- data/spec/code/parser/equality_spec.rb +0 -26
- data/spec/code/parser/function_spec.rb +0 -43
- data/spec/code/parser/greater_than_spec.rb +0 -26
- data/spec/code/parser/group_spec.rb +0 -13
- data/spec/code/parser/if_modifier_spec.rb +0 -26
- data/spec/code/parser/if_spec.rb +0 -39
- data/spec/code/parser/list_spec.rb +0 -27
- data/spec/code/parser/multiplication_spec.rb +0 -26
- data/spec/code/parser/negation_spec.rb +0 -13
- data/spec/code/parser/not_keyword_spec.rb +0 -21
- data/spec/code/parser/nothing_spec.rb +0 -20
- data/spec/code/parser/number_spec.rb +0 -24
- data/spec/code/parser/or_keyword_spec.rb +0 -26
- data/spec/code/parser/or_operator_spec.rb +0 -26
- data/spec/code/parser/power_spec.rb +0 -21
- data/spec/code/parser/range_spec.rb +0 -21
- data/spec/code/parser/rescue_spec.rb +0 -26
- data/spec/code/parser/shift_spec.rb +0 -26
- data/spec/code/parser/string_spec.rb +0 -28
- data/spec/code/parser/ternary_spec.rb +0 -26
- data/spec/code/parser/unary_minus_spec.rb +0 -21
- data/spec/code/parser/while_spec.rb +0 -32
- data/spec/code/parser_spec.rb +0 -13
- data/spec/spec_helper.rb +0 -6
- data/spec/template/parser_spec.rb +0 -13
    
        data/lib/code/parser/call.rb
    DELETED
    
    | @@ -1,183 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Call < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    name = parse_subclass(::Code::Parser::Name)
         | 
| 6 | 
            -
                    return unless name
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                    if match(OPENING_PARENTHESIS)
         | 
| 9 | 
            -
                      arguments = []
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                      arguments << (parse_keyword_argument || parse_regular_argument)
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                      while match(COMMA) && !end_of_input?
         | 
| 14 | 
            -
                        arguments << (parse_keyword_argument || parse_regular_argument)
         | 
| 15 | 
            -
                      end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                      arguments.compact!
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                      match(CLOSING_PARENTHESIS)
         | 
| 20 | 
            -
                    else
         | 
| 21 | 
            -
                      arguments = nil
         | 
| 22 | 
            -
                    end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                    previous_cursor = cursor
         | 
| 25 | 
            -
                    comments = parse_comments
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                    if match(DO_KEYWORD)
         | 
| 28 | 
            -
                      block = parse_block
         | 
| 29 | 
            -
                      match(END_KEYWORD)
         | 
| 30 | 
            -
                    elsif match(OPENING_CURLY_BRACKET)
         | 
| 31 | 
            -
                      block = parse_block
         | 
| 32 | 
            -
                      match(CLOSING_CURLY_BRACKET)
         | 
| 33 | 
            -
                    else
         | 
| 34 | 
            -
                      @cursor = previous_cursor
         | 
| 35 | 
            -
                      buffer!
         | 
| 36 | 
            -
                      block = nil
         | 
| 37 | 
            -
                    end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                    {
         | 
| 40 | 
            -
                      call: {
         | 
| 41 | 
            -
                        name: name,
         | 
| 42 | 
            -
                        arguments: arguments,
         | 
| 43 | 
            -
                        block: block,
         | 
| 44 | 
            -
                        comments: comments
         | 
| 45 | 
            -
                      }.compact
         | 
| 46 | 
            -
                    }
         | 
| 47 | 
            -
                  end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                  private
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                  def parse_block
         | 
| 52 | 
            -
                    comments = parse_comments
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                    if match(PIPE)
         | 
| 55 | 
            -
                      parameters = []
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                      parameters << (parse_keyword_parameter || parse_regular_parameter)
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                      while match(COMMA) && !end_of_input?
         | 
| 60 | 
            -
                        parameters << (parse_keyword_parameter || parse_regular_parameter)
         | 
| 61 | 
            -
                      end
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                      match(PIPE)
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                      {
         | 
| 66 | 
            -
                        comments: comments,
         | 
| 67 | 
            -
                        parameters: parameters.compact,
         | 
| 68 | 
            -
                        body: parse_code
         | 
| 69 | 
            -
                      }.compact
         | 
| 70 | 
            -
                    else
         | 
| 71 | 
            -
                      { comments: comments, body: parse_code }.compact
         | 
| 72 | 
            -
                    end
         | 
| 73 | 
            -
                  end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                  def parse_keyword_argument
         | 
| 76 | 
            -
                    previous_cursor = cursor
         | 
| 77 | 
            -
             | 
| 78 | 
            -
                    comments_before = parse_comments
         | 
| 79 | 
            -
                    key = parse_subclass(::Code::Parser::Statement)
         | 
| 80 | 
            -
                    comments_after = parse_comments
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                    if key && match(COLON) || match(EQUAL + GREATER)
         | 
| 83 | 
            -
                      default = parse_code
         | 
| 84 | 
            -
                      default = nil if default.empty?
         | 
| 85 | 
            -
                      {
         | 
| 86 | 
            -
                        comments_before: comments_before,
         | 
| 87 | 
            -
                        comments_after: comments_after,
         | 
| 88 | 
            -
                        default: default,
         | 
| 89 | 
            -
                        keyword: true,
         | 
| 90 | 
            -
                        statement: key
         | 
| 91 | 
            -
                      }.compact
         | 
| 92 | 
            -
                    else
         | 
| 93 | 
            -
                      @cursor = previous_cursor
         | 
| 94 | 
            -
                      buffer!
         | 
| 95 | 
            -
                      return
         | 
| 96 | 
            -
                    end
         | 
| 97 | 
            -
                  end
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                  def parse_regular_argument
         | 
| 100 | 
            -
                    code = parse_code
         | 
| 101 | 
            -
                    return if code.empty?
         | 
| 102 | 
            -
                    code
         | 
| 103 | 
            -
                  end
         | 
| 104 | 
            -
             | 
| 105 | 
            -
                  def parse_keyword_parameter
         | 
| 106 | 
            -
                    previous_cursor = cursor
         | 
| 107 | 
            -
             | 
| 108 | 
            -
                    comments_before = parse_comments
         | 
| 109 | 
            -
                    name = parse_subclass(::Code::Parser::Name)
         | 
| 110 | 
            -
                    comments_after = parse_comments
         | 
| 111 | 
            -
             | 
| 112 | 
            -
                    if name && match(COLON) || match(EQUAL + GREATER)
         | 
| 113 | 
            -
                      default = parse_default
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                      {
         | 
| 116 | 
            -
                        kind: :keyword,
         | 
| 117 | 
            -
                        name: name,
         | 
| 118 | 
            -
                        default: default,
         | 
| 119 | 
            -
                        comments_before: comments_before,
         | 
| 120 | 
            -
                        comments_after: comments_after
         | 
| 121 | 
            -
                      }.compact
         | 
| 122 | 
            -
                    else
         | 
| 123 | 
            -
                      @cursor = previous_cursor
         | 
| 124 | 
            -
                      buffer!
         | 
| 125 | 
            -
                      return
         | 
| 126 | 
            -
                    end
         | 
| 127 | 
            -
                  end
         | 
| 128 | 
            -
             | 
| 129 | 
            -
                  def parse_regular_parameter
         | 
| 130 | 
            -
                    previous_cursor = cursor
         | 
| 131 | 
            -
                    comments_before = parse_comments
         | 
| 132 | 
            -
             | 
| 133 | 
            -
                    if match(AMPERSAND)
         | 
| 134 | 
            -
                      kind = :block
         | 
| 135 | 
            -
                    elsif match(ASTERISK + ASTERISK)
         | 
| 136 | 
            -
                      kind = :keyword_splat
         | 
| 137 | 
            -
                    elsif match(ASTERISK)
         | 
| 138 | 
            -
                      kind = :regular_splat
         | 
| 139 | 
            -
                    else
         | 
| 140 | 
            -
                      kind = nil
         | 
| 141 | 
            -
                    end
         | 
| 142 | 
            -
             | 
| 143 | 
            -
                    name = parse_subclass(::Code::Parser::Name)
         | 
| 144 | 
            -
             | 
| 145 | 
            -
                    if name
         | 
| 146 | 
            -
                      comments_after = parse_comments
         | 
| 147 | 
            -
             | 
| 148 | 
            -
                      if match(EQUAL)
         | 
| 149 | 
            -
                        default = parse_default
         | 
| 150 | 
            -
                      else
         | 
| 151 | 
            -
                        default = nil
         | 
| 152 | 
            -
                      end
         | 
| 153 | 
            -
             | 
| 154 | 
            -
                      {
         | 
| 155 | 
            -
                        comments_before: comments_before,
         | 
| 156 | 
            -
                        comments_after: comments_after,
         | 
| 157 | 
            -
                        default: default,
         | 
| 158 | 
            -
                        name: name,
         | 
| 159 | 
            -
                        kind: kind
         | 
| 160 | 
            -
                      }.compact
         | 
| 161 | 
            -
                    else
         | 
| 162 | 
            -
                      @cursor = previous_cursor
         | 
| 163 | 
            -
                      buffer!
         | 
| 164 | 
            -
                      return
         | 
| 165 | 
            -
                    end
         | 
| 166 | 
            -
                  end
         | 
| 167 | 
            -
             | 
| 168 | 
            -
                  def parse_default
         | 
| 169 | 
            -
                    comments_before = parse_comments
         | 
| 170 | 
            -
                    statement = parse_subclass(::Code::Parser::BitwiseAnd)
         | 
| 171 | 
            -
                    comments_after = parse_comments
         | 
| 172 | 
            -
             | 
| 173 | 
            -
                    default = {
         | 
| 174 | 
            -
                      statement: statement,
         | 
| 175 | 
            -
                      comments_before: comments_before,
         | 
| 176 | 
            -
                      comments_after: comments_after
         | 
| 177 | 
            -
                    }.compact
         | 
| 178 | 
            -
             | 
| 179 | 
            -
                    default.empty? ? nil : default
         | 
| 180 | 
            -
                  end
         | 
| 181 | 
            -
                end
         | 
| 182 | 
            -
              end
         | 
| 183 | 
            -
            end
         | 
| @@ -1,41 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class ChainedCall < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    left = parse_dictionnary
         | 
| 6 | 
            -
                    previous_cursor = cursor
         | 
| 7 | 
            -
                    comments_before = parse_comments
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                    if left && match([DOT, COLON + COLON])
         | 
| 10 | 
            -
                      comments_after = parse_comments
         | 
| 11 | 
            -
                      right = parse_dictionnary
         | 
| 12 | 
            -
                      if right
         | 
| 13 | 
            -
                        chained_call = [{ left: left, right: right }]
         | 
| 14 | 
            -
                        while match([DOT, COLON + COLON]) && other_right = parse_dictionnary
         | 
| 15 | 
            -
                          chained_call << { right: other_right }
         | 
| 16 | 
            -
                        end
         | 
| 17 | 
            -
                        {
         | 
| 18 | 
            -
                          chained_call: {
         | 
| 19 | 
            -
                            calls: chained_call,
         | 
| 20 | 
            -
                            comments_before: comments_before,
         | 
| 21 | 
            -
                            comments_after: comments_after
         | 
| 22 | 
            -
                          }.compact
         | 
| 23 | 
            -
                        }
         | 
| 24 | 
            -
                      else
         | 
| 25 | 
            -
                        @cursor = previous_cursor
         | 
| 26 | 
            -
                        buffer!
         | 
| 27 | 
            -
                        left
         | 
| 28 | 
            -
                      end
         | 
| 29 | 
            -
                    else
         | 
| 30 | 
            -
                      @cursor = previous_cursor
         | 
| 31 | 
            -
                      buffer!
         | 
| 32 | 
            -
                      left
         | 
| 33 | 
            -
                    end
         | 
| 34 | 
            -
                  end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                  def parse_dictionnary
         | 
| 37 | 
            -
                    parse_subclass(::Code::Parser::Dictionnary)
         | 
| 38 | 
            -
                  end
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
              end
         | 
| 41 | 
            -
            end
         | 
    
        data/lib/code/parser/class.rb
    DELETED
    
    | @@ -1,55 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Class < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    previous_cursor = cursor
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                    if match(CLASS_KEYWORD)
         | 
| 8 | 
            -
                      first_comments = parse_comments
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                      name = parse_subclass(::Code::Parser::Name)
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                      if name
         | 
| 13 | 
            -
                        second_comments = parse_comments
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                        if match(LESSER)
         | 
| 16 | 
            -
                          previous_cursor = cursor
         | 
| 17 | 
            -
                          third_comments = parse_comments
         | 
| 18 | 
            -
                          superclass = parse_subclass(::Code::Parser::Name)
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                          if !superclass
         | 
| 21 | 
            -
                            @cursor = previous_cursor
         | 
| 22 | 
            -
                            buffer!
         | 
| 23 | 
            -
                            third_comments = nil
         | 
| 24 | 
            -
                          end
         | 
| 25 | 
            -
                        else
         | 
| 26 | 
            -
                          third_comments = nil
         | 
| 27 | 
            -
                          superclass = nil
         | 
| 28 | 
            -
                        end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                        body = parse_code
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                        match(END_KEYWORD)
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                        {
         | 
| 35 | 
            -
                          class: {
         | 
| 36 | 
            -
                            name: name,
         | 
| 37 | 
            -
                            superclass: superclass,
         | 
| 38 | 
            -
                            first_comments: first_comments,
         | 
| 39 | 
            -
                            second_comments: second_comments,
         | 
| 40 | 
            -
                            third_comments: third_comments,
         | 
| 41 | 
            -
                            body: body
         | 
| 42 | 
            -
                          }.compact
         | 
| 43 | 
            -
                        }
         | 
| 44 | 
            -
                      else
         | 
| 45 | 
            -
                        @cursor = previous_cursor
         | 
| 46 | 
            -
                        buffer!
         | 
| 47 | 
            -
                        parse_subclass(::Code::Parser::While)
         | 
| 48 | 
            -
                      end
         | 
| 49 | 
            -
                    else
         | 
| 50 | 
            -
                      parse_subclass(::Code::Parser::While)
         | 
| 51 | 
            -
                    end
         | 
| 52 | 
            -
                  end
         | 
| 53 | 
            -
                end
         | 
| 54 | 
            -
              end
         | 
| 55 | 
            -
            end
         | 
    
        data/lib/code/parser/code.rb
    DELETED
    
    | @@ -1,20 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Code < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    output = []
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                    comments = parse_comments
         | 
| 8 | 
            -
                    output << { comments: comments } if comments
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                    while code = parse_subclass(::Code::Parser::Statement)
         | 
| 11 | 
            -
                      output << code
         | 
| 12 | 
            -
                      comments = parse_comments
         | 
| 13 | 
            -
                      output << { comments: comments } if comments
         | 
| 14 | 
            -
                    end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                    output
         | 
| 17 | 
            -
                  end
         | 
| 18 | 
            -
                end
         | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
            end
         | 
    
        data/lib/code/parser/comments.rb
    DELETED
    
    | @@ -1,46 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Comments < ::Code::Parser
         | 
| 4 | 
            -
                  def initialize(input, whitespace: WHITESPACE, **kargs)
         | 
| 5 | 
            -
                    super(input, **kargs)
         | 
| 6 | 
            -
                    @whitespace = whitespace
         | 
| 7 | 
            -
                    @has_line_comments = whitespace.include?(NEWLINE)
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                  def parse
         | 
| 11 | 
            -
                    comments = []
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                    while next?(whitespace) || next?(SLASH + ASTERISK) ||
         | 
| 14 | 
            -
                            (line_comments? && (next?(SLASH + SLASH) || next?(HASH)))
         | 
| 15 | 
            -
                      consume while next?(whitespace)
         | 
| 16 | 
            -
                      buffer!
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                      if match(SLASH + SLASH) || match(HASH)
         | 
| 19 | 
            -
                        consume while !next?(NEWLINE) && !end_of_input?
         | 
| 20 | 
            -
                        match(NEWLINE)
         | 
| 21 | 
            -
                        comments << buffer
         | 
| 22 | 
            -
                      end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                      consume while next?(whitespace)
         | 
| 25 | 
            -
                      buffer!
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                      if match(SLASH + ASTERISK)
         | 
| 28 | 
            -
                        consume while !next?(ASTERISK + SLASH) && !end_of_input?
         | 
| 29 | 
            -
                        match(ASTERISK + SLASH)
         | 
| 30 | 
            -
                        comments << buffer
         | 
| 31 | 
            -
                      end
         | 
| 32 | 
            -
                    end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                    comments.empty? ? nil : comments
         | 
| 35 | 
            -
                  end
         | 
| 36 | 
            -
                end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                private
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                attr_reader :whitespace, :has_line_comments
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                def line_comments?
         | 
| 43 | 
            -
                  !!has_line_comments
         | 
| 44 | 
            -
                end
         | 
| 45 | 
            -
              end
         | 
| 46 | 
            -
            end
         | 
| @@ -1,52 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Dictionnary < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    if match(OPENING_CURLY_BRACKET)
         | 
| 6 | 
            -
                      dictionnary = []
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                      comments = parse_comments
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                      dictionnary << parse_key_value
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                      dictionnary << parse_key_value while match(COMMA) && !end_of_input?
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                      match(CLOSING_CURLY_BRACKET)
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                      { dictionnary: dictionnary.compact, comments: comments }.compact
         | 
| 17 | 
            -
                    else
         | 
| 18 | 
            -
                      parse_subclass(::Code::Parser::List)
         | 
| 19 | 
            -
                    end
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                  def parse_key_value
         | 
| 23 | 
            -
                    previous_cursor = cursor
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                    comments_before = parse_comments
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                    key = parse_subclass(::Code::Parser::Statement)
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                    comments_after = parse_comments
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                    if key
         | 
| 32 | 
            -
                      if match(COLON) || match(EQUAL + GREATER)
         | 
| 33 | 
            -
                        value = parse_code
         | 
| 34 | 
            -
                      else
         | 
| 35 | 
            -
                        value = nil
         | 
| 36 | 
            -
                      end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                      {
         | 
| 39 | 
            -
                        key: key,
         | 
| 40 | 
            -
                        value: value,
         | 
| 41 | 
            -
                        comments_before: comments_before,
         | 
| 42 | 
            -
                        comments_after: comments_after
         | 
| 43 | 
            -
                      }.compact
         | 
| 44 | 
            -
                    else
         | 
| 45 | 
            -
                      @cursor = previous_cursor
         | 
| 46 | 
            -
                      buffer!
         | 
| 47 | 
            -
                      return
         | 
| 48 | 
            -
                    end
         | 
| 49 | 
            -
                  end
         | 
| 50 | 
            -
                end
         | 
| 51 | 
            -
              end
         | 
| 52 | 
            -
            end
         | 
    
        data/lib/code/parser/equal.rb
    DELETED
    
    | @@ -1,68 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Equal < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    previous_cursor = cursor
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                    left = parse_left
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                    comments_before = parse_comments
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                    if left && operator = match(EQUALS)
         | 
| 12 | 
            -
                      comments_after = parse_comments
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                      right = parse_subclass(::Code::Parser::Equal)
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                      if right
         | 
| 17 | 
            -
                        {
         | 
| 18 | 
            -
                          equal: {
         | 
| 19 | 
            -
                            operator: operator,
         | 
| 20 | 
            -
                            left: left,
         | 
| 21 | 
            -
                            right: right,
         | 
| 22 | 
            -
                            comments_before: comments_before,
         | 
| 23 | 
            -
                            comments_after: comments_after
         | 
| 24 | 
            -
                          }.compact
         | 
| 25 | 
            -
                        }
         | 
| 26 | 
            -
                      else
         | 
| 27 | 
            -
                        @cursor = previous_cursor
         | 
| 28 | 
            -
                        buffer!
         | 
| 29 | 
            -
                        parse_next
         | 
| 30 | 
            -
                      end
         | 
| 31 | 
            -
                    else
         | 
| 32 | 
            -
                      @cursor = previous_cursor
         | 
| 33 | 
            -
                      buffer!
         | 
| 34 | 
            -
                      parse_next
         | 
| 35 | 
            -
                    end
         | 
| 36 | 
            -
                  end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                  private
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                  def parse_next
         | 
| 41 | 
            -
                    parse_subclass(::Code::Parser::Rescue)
         | 
| 42 | 
            -
                  end
         | 
| 43 | 
            -
             | 
| 44 | 
            -
                  def parse_left
         | 
| 45 | 
            -
                    left = parse_subclass(::Code::Parser::Name)
         | 
| 46 | 
            -
                    return unless left
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                    previous_cursor = cursor
         | 
| 49 | 
            -
                    comments_before = parse_comments
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                    if match(DOT) || match(COLON + COLON)
         | 
| 52 | 
            -
                      right = parse_subclass(::Code::Parser::Name)
         | 
| 53 | 
            -
                      if right
         | 
| 54 | 
            -
                        { left: left, right: right }
         | 
| 55 | 
            -
                      else
         | 
| 56 | 
            -
                        @cursor = previous_cursor
         | 
| 57 | 
            -
                        buffer!
         | 
| 58 | 
            -
                        return
         | 
| 59 | 
            -
                      end
         | 
| 60 | 
            -
                    else
         | 
| 61 | 
            -
                      @cursor = previous_cursor
         | 
| 62 | 
            -
                      buffer!
         | 
| 63 | 
            -
                      left
         | 
| 64 | 
            -
                    end
         | 
| 65 | 
            -
                  end
         | 
| 66 | 
            -
                end
         | 
| 67 | 
            -
              end
         | 
| 68 | 
            -
            end
         | 
    
        data/lib/code/parser/equality.rb
    DELETED
    
    | @@ -1,20 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Equality < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    parse_subclass(
         | 
| 6 | 
            -
                      ::Code::Parser::Operation,
         | 
| 7 | 
            -
                      operators: [
         | 
| 8 | 
            -
                        EQUAL + EQUAL + EQUAL,
         | 
| 9 | 
            -
                        LESSER + EQUAL + GREATER,
         | 
| 10 | 
            -
                        EQUAL + TILDE,
         | 
| 11 | 
            -
                        EXCLAMATION_POINT + TILDE,
         | 
| 12 | 
            -
                        EQUAL + EQUAL,
         | 
| 13 | 
            -
                        EXCLAMATION_POINT + EQUAL
         | 
| 14 | 
            -
                      ],
         | 
| 15 | 
            -
                      subclass: ::Code::Parser::GreaterThan
         | 
| 16 | 
            -
                    )
         | 
| 17 | 
            -
                  end
         | 
| 18 | 
            -
                end
         | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
            end
         | 
| @@ -1,36 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Error
         | 
| 4 | 
            -
                  class SyntaxError < ::Code::Parser::Error
         | 
| 5 | 
            -
                    def initialize(
         | 
| 6 | 
            -
                      message,
         | 
| 7 | 
            -
                      input:,
         | 
| 8 | 
            -
                      line:,
         | 
| 9 | 
            -
                      column:,
         | 
| 10 | 
            -
                      offset_lines:,
         | 
| 11 | 
            -
                      offset_columns:
         | 
| 12 | 
            -
                    )
         | 
| 13 | 
            -
                      @message = message
         | 
| 14 | 
            -
                      @input = input
         | 
| 15 | 
            -
                      @line = line
         | 
| 16 | 
            -
                      @column = column
         | 
| 17 | 
            -
                      @offset_lines = offset_lines
         | 
| 18 | 
            -
                      @offset_columns = offset_columns
         | 
| 19 | 
            -
                    end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                    def message
         | 
| 22 | 
            -
                      @message + "\n\n" + line_message + "\n" + " " * column +
         | 
| 23 | 
            -
                        "^" * offset_columns
         | 
| 24 | 
            -
                    end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                    private
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                    def line_message
         | 
| 29 | 
            -
                      input.lines[line..(line + offset_lines)].join
         | 
| 30 | 
            -
                    end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                    attr_reader :input, :line, :column, :offset_lines, :offset_columns
         | 
| 33 | 
            -
                  end
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
              end
         | 
| 36 | 
            -
            end
         | 
    
        data/lib/code/parser/error.rb
    DELETED
    
    
    
        data/lib/code/parser/function.rb
    DELETED
    
    | @@ -1,118 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Function < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    return parse_next unless next?(OPENING_PARENTHESIS)
         | 
| 6 | 
            -
                    previous_cursor = cursor
         | 
| 7 | 
            -
                    match(OPENING_PARENTHESIS)
         | 
| 8 | 
            -
                    parameters_comments = parse_comments
         | 
| 9 | 
            -
                    parameters = parse_parameters
         | 
| 10 | 
            -
                    match(CLOSING_PARENTHESIS)
         | 
| 11 | 
            -
                    comments_before = parse_comments
         | 
| 12 | 
            -
                    if match(EQUAL + GREATER)
         | 
| 13 | 
            -
                      comments_after = parse_comments
         | 
| 14 | 
            -
                      if match(OPENING_CURLY_BRACKET)
         | 
| 15 | 
            -
                        body = parse_code
         | 
| 16 | 
            -
                        match(CLOSING_CURLY_BRACKET)
         | 
| 17 | 
            -
                        {
         | 
| 18 | 
            -
                          function: {
         | 
| 19 | 
            -
                            parameters: parameters,
         | 
| 20 | 
            -
                            body: body,
         | 
| 21 | 
            -
                            parameters_comments: parameters_comments,
         | 
| 22 | 
            -
                            comments_before: comments_before,
         | 
| 23 | 
            -
                            comments_after: comments_after
         | 
| 24 | 
            -
                          }.compact
         | 
| 25 | 
            -
                        }
         | 
| 26 | 
            -
                      else
         | 
| 27 | 
            -
                        buffer!
         | 
| 28 | 
            -
                        @cursor = previous_cursor
         | 
| 29 | 
            -
                        parse_next
         | 
| 30 | 
            -
                      end
         | 
| 31 | 
            -
                    else
         | 
| 32 | 
            -
                      buffer!
         | 
| 33 | 
            -
                      @cursor = previous_cursor
         | 
| 34 | 
            -
                      parse_next
         | 
| 35 | 
            -
                    end
         | 
| 36 | 
            -
                  end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                  def parse_next
         | 
| 39 | 
            -
                    parse_subclass(::Code::Parser::ChainedCall)
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  def parse_parameters
         | 
| 43 | 
            -
                    parameters = []
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                    parameters << (parse_keyword_parameter || parse_regular_parameter)
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                    while match(COMMA) && !end_of_input?
         | 
| 48 | 
            -
                      parameters << (parse_keyword_parameter || parse_regular_parameter)
         | 
| 49 | 
            -
                    end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                    parameters.compact.empty? ? nil : parameters.compact
         | 
| 52 | 
            -
                  end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                  def parse_keyword_parameter
         | 
| 55 | 
            -
                    previous_cursor = cursor
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                    comments_before = parse_comments
         | 
| 58 | 
            -
                    name = parse_subclass(::Code::Parser::Name)
         | 
| 59 | 
            -
                    comments_after = parse_comments
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                    if name && (match(COLON) || match(EQUAL + GREATER))
         | 
| 62 | 
            -
                      default = parse_code
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                      {
         | 
| 65 | 
            -
                        kind: :keyword,
         | 
| 66 | 
            -
                        name: name,
         | 
| 67 | 
            -
                        default: default,
         | 
| 68 | 
            -
                        comments_before: comments_before,
         | 
| 69 | 
            -
                        comments_after: comments_after
         | 
| 70 | 
            -
                      }.compact
         | 
| 71 | 
            -
                    else
         | 
| 72 | 
            -
                      @cursor = previous_cursor
         | 
| 73 | 
            -
                      buffer!
         | 
| 74 | 
            -
                      return
         | 
| 75 | 
            -
                    end
         | 
| 76 | 
            -
                  end
         | 
| 77 | 
            -
             | 
| 78 | 
            -
                  def parse_regular_parameter
         | 
| 79 | 
            -
                    previous_cursor = cursor
         | 
| 80 | 
            -
             | 
| 81 | 
            -
                    comments_before = parse_comments
         | 
| 82 | 
            -
             | 
| 83 | 
            -
                    if match(AMPERSAND)
         | 
| 84 | 
            -
                      kind = :block
         | 
| 85 | 
            -
                    elsif match(ASTERISK + ASTERISK)
         | 
| 86 | 
            -
                      kind = :keyword_splat
         | 
| 87 | 
            -
                    elsif match(ASTERISK)
         | 
| 88 | 
            -
                      kind = :regular_splat
         | 
| 89 | 
            -
                    else
         | 
| 90 | 
            -
                      kind = nil
         | 
| 91 | 
            -
                    end
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                    name = parse_subclass(::Code::Parser::Name)
         | 
| 94 | 
            -
                    comments_after = parse_comments
         | 
| 95 | 
            -
             | 
| 96 | 
            -
                    if name
         | 
| 97 | 
            -
                      if match(EQUAL)
         | 
| 98 | 
            -
                        default = parse_code
         | 
| 99 | 
            -
                      else
         | 
| 100 | 
            -
                        default = nil
         | 
| 101 | 
            -
                      end
         | 
| 102 | 
            -
             | 
| 103 | 
            -
                      {
         | 
| 104 | 
            -
                        kind: kind,
         | 
| 105 | 
            -
                        name: name,
         | 
| 106 | 
            -
                        default: default,
         | 
| 107 | 
            -
                        comments_before: comments_before,
         | 
| 108 | 
            -
                        comments_after: comments_after
         | 
| 109 | 
            -
                      }.compact
         | 
| 110 | 
            -
                    else
         | 
| 111 | 
            -
                      @cursor = previous_cursor
         | 
| 112 | 
            -
                      buffer!
         | 
| 113 | 
            -
                      return
         | 
| 114 | 
            -
                    end
         | 
| 115 | 
            -
                  end
         | 
| 116 | 
            -
                end
         | 
| 117 | 
            -
              end
         | 
| 118 | 
            -
            end
         | 
| @@ -1,13 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class GreaterThan < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    parse_subclass(
         | 
| 6 | 
            -
                      ::Code::Parser::Operation,
         | 
| 7 | 
            -
                      operators: [GREATER + EQUAL, LESSER + EQUAL, GREATER, LESSER],
         | 
| 8 | 
            -
                      subclass: ::Code::Parser::BitwiseOr
         | 
| 9 | 
            -
                    )
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
            end
         | 
    
        data/lib/code/parser/group.rb
    DELETED
    
    | @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            class Code
         | 
| 2 | 
            -
              class Parser
         | 
| 3 | 
            -
                class Group < ::Code::Parser
         | 
| 4 | 
            -
                  def parse
         | 
| 5 | 
            -
                    if match(OPENING_PARENTHESIS)
         | 
| 6 | 
            -
                      code = parse_subclass(::Code::Parser::Code)
         | 
| 7 | 
            -
                      match(CLOSING_PARENTHESIS)
         | 
| 8 | 
            -
                      { group: code }
         | 
| 9 | 
            -
                    else
         | 
| 10 | 
            -
                      parse_subclass(::Code::Parser::Call)
         | 
| 11 | 
            -
                    end
         | 
| 12 | 
            -
                  end
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         |