Module: Fig::Grammar::Base
- Includes:
- Treetop::Runtime
- Included in:
- BaseParser, V0, V1, V2, VersionIdentification
- Defined in:
- lib/fig/grammar/base.rb
Defined Under Namespace
Modules: Comment0
Instance Method Summary collapse
- #_nt_comment ⇒ Object
- #_nt_optional_ws ⇒ Object
- #_nt_optional_ws_or_comment ⇒ Object
- #_nt_ws ⇒ Object
- #_nt_ws_or_comment ⇒ Object
- #root ⇒ Object
Instance Method Details
#_nt_comment ⇒ Object
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 |
# File 'lib/fig/grammar/base.rb', line 93 def _nt_comment start_index = index if node_cache[:comment].has_key?(index) cached = node_cache[:comment][index] if cached node_cache[:comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?('#', false, index)) r1 = true @index += match_len else terminal_parse_failure('#') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do if has_terminal?(@regexps[gr = '\A[^\\n]'] ||= Regexp.new(gr), :regexp, index) r3 = true @index += 1 else terminal_parse_failure('[^\\n]') r3 = nil end if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 if r2 if (match_len = has_terminal?("\n", false, index)) r4 = true @index += match_len else terminal_parse_failure("\n") r4 = nil end s0 << r4 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Comment0) else @index = i0 r0 = nil end node_cache[:comment][start_index] = r0 r0 end |
#_nt_optional_ws ⇒ Object
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 |
# File 'lib/fig/grammar/base.rb', line 57 def _nt_optional_ws start_index = index if node_cache[:optional_ws].has_key?(index) cached = node_cache[:optional_ws][index] if cached node_cache[:optional_ws][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do if has_terminal?(@regexps[gr = '\A[ \\n\\r\\t]'] ||= Regexp.new(gr), :regexp, index) r1 = true @index += 1 else terminal_parse_failure('[ \\n\\r\\t]') r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:optional_ws][start_index] = r0 r0 end |
#_nt_optional_ws_or_comment ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/fig/grammar/base.rb', line 187 def _nt_optional_ws_or_comment start_index = index if node_cache[:optional_ws_or_comment].has_key?(index) cached = node_cache[:optional_ws_or_comment][index] if cached node_cache[:optional_ws_or_comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do r1 = _nt_ws_or_comment if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:optional_ws_or_comment][start_index] = r0 r0 end |
#_nt_ws ⇒ Object
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 54 55 |
# File 'lib/fig/grammar/base.rb', line 19 def _nt_ws start_index = index if node_cache[:ws].has_key?(index) cached = node_cache[:ws][index] if cached node_cache[:ws][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do if has_terminal?(@regexps[gr = '\A[ \\n\\r\\t]'] ||= Regexp.new(gr), :regexp, index) r1 = true @index += 1 else terminal_parse_failure('[ \\n\\r\\t]') r1 = nil 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[:ws][start_index] = r0 r0 end |
#_nt_ws_or_comment ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/fig/grammar/base.rb', line 155 def _nt_ws_or_comment start_index = index if node_cache[:ws_or_comment].has_key?(index) cached = node_cache[:ws_or_comment][index] if cached node_cache[:ws_or_comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_ws if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_comment if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else @index = i0 r0 = nil end end node_cache[:ws_or_comment][start_index] = r0 r0 end |
#root ⇒ Object
15 16 17 |
# File 'lib/fig/grammar/base.rb', line 15 def root @root ||= :ws end |