Module: Brevity::File

Includes:
Command, Comment, Treetop::Runtime
Included in:
FileParser
Defined in:
lib/brevity/parsing/file/file.rb

Defined Under Namespace

Modules: File0, File1

Instance Method Summary collapse

Methods included from Command

#_nt_braced_arg, #_nt_cmd_name, #_nt_command

Methods included from Comment

#_nt_comment, #_nt_newline, #_nt_unix_newline, #_nt_windows_newline

Instance Method Details

#_nt_fileObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
# File 'lib/brevity/parsing/file/file.rb', line 30

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

  i0, s0 = index, []
  s1, i1 = [], index
  loop do
    i2, s2 = index, []
    s3, i3 = [], index
    loop do
      if has_terminal?(@regexps[gr = '\A[\\s]'] ||= Regexp.new(gr), :regexp, index)
        r4 = true
        @index += 1
      else
        terminal_parse_failure('[\\s]')
        r4 = nil
      end
      if r4
        s3 << r4
      else
        break
      end
    end
    r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
    s2 << r3
    if r3
      r5 = _nt_node
      s2 << r5
    end
    if s2.last
      r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
      r2.extend(File0)
    else
      @index = i2
      r2 = nil
    end
    if r2
      s1 << r2
    else
      break
    end
  end
  r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
  s0 << r1
  if r1
    s6, i6 = [], index
    loop do
      if has_terminal?(@regexps[gr = '\A[\\s]'] ||= Regexp.new(gr), :regexp, index)
        r7 = true
        @index += 1
      else
        terminal_parse_failure('[\\s]')
        r7 = nil
      end
      if r7
        s6 << r7
      else
        break
      end
    end
    r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
    s0 << r6
  end
  if s0.last
    r0 = instantiate_node(FileNode,input, i0...index, s0)
    r0.extend(File1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:file][start_index] = r0

  r0
end

#_nt_nodeObject



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
# File 'lib/brevity/parsing/file/file.rb', line 113

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

  i0 = index
  r1 = _nt_comment
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    r2 = _nt_command
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:node][start_index] = r0

  r0
end

#rootObject



9
10
11
# File 'lib/brevity/parsing/file/file.rb', line 9

def root
  @root ||= :file
end