Module: Laser::Parsers::Overload

Includes:
GeneralPurpose, Treetop::Runtime
Included in:
Annotation, OverloadParser
Defined in:
lib/laser/annotation_parser/overload_parser.rb

Defined Under Namespace

Modules: FunctionType0, FunctionType1, FunctionType2, FunctionType3

Instance Method Summary collapse

Methods included from GeneralPurpose

#_nt_annotation_name, #_nt_method_name, #_nt_operator, #_nt_parenthesized_type_list, #_nt_space, #_nt_type_list

Instance Method Details

#_nt_function_typeObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/laser/annotation_parser/overload_parser.rb', line 52

def _nt_function_type
  start_index = index
  if node_cache[:function_type].has_key?(index)
    cached = node_cache[:function_type][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  i1, s1 = index, []
  r2 = _nt_parenthesized_type_list
  s1 << r2
  if r2
    s3, i3 = [], index
    loop do
      r4 = _nt_space
      if r4
        s3 << r4
      else
        break
      end
    end
    r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
    s1 << r3
    if r3
      if has_terminal?('->', false, index)
        r5 = instantiate_node(SyntaxNode,input, index...(index + 2))
        @index += 2
      else
        terminal_parse_failure('->')
        r5 = nil
      end
      s1 << r5
      if r5
        s6, i6 = [], index
        loop do
          r7 = _nt_space
          if r7
            s6 << r7
          else
            break
          end
        end
        r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
        s1 << r6
        if r6
          r8 = _nt_type
          s1 << r8
        end
      end
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(FunctionType0)
    r1.extend(FunctionType1)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r0 = r1
  else
    i9, s9 = index, []
    r10 = _nt_parenthesized_type_list
    s9 << r10
    if r10
      s11, i11 = [], index
      loop do
        r12 = _nt_space
        if r12
          s11 << r12
        else
          break
        end
      end
      r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
      s9 << r11
      if r11
        r13 = _nt_type
        s9 << r13
      end
    end
    if s9.last
      r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
      r9.extend(FunctionType2)
      r9.extend(FunctionType3)
    else
      @index = i9
      r9 = nil
    end
    if r9
      r0 = r9
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:function_type][start_index] = r0

  r0
end

#rootObject



10
11
12
# File 'lib/laser/annotation_parser/overload_parser.rb', line 10

def root
  @root ||= :function_type
end