Method: Formatting#_nt_format_string

Defined in:
lib/ntail/formatting.rb

#_nt_format_stringObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ntail/formatting.rb', line 11

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

  s0, i0 = [], index
  loop do
    i1 = index
    r2 = _nt_token
    if r2
      r1 = r2
    else
      r3 = _nt_literal
      if r3
        r1 = r3
      else
        @index = i1
        r1 = nil
      end
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  if s0.empty?
    @index = i0
    r0 = nil
  else
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
  end

  node_cache[:format_string][start_index] = r0

  r0
end