Module: Hemingway::Block
- Included in:
- BlockParser, Latex
- Defined in:
- lib/hemingway/block/block.rb,
lib/hemingway/block/list/list.rb,
lib/hemingway/block/quote/quote.rb,
lib/hemingway/block/center/center.rb,
lib/hemingway/block/verbatim/verbatim.rb
Defined Under Namespace
Modules: Block0, Block1, Block2, Block3, Center, List, Quote, Verbatim Classes: CenterParser, ListParser, QuoteParser, VerbatimParser
Instance Method Summary collapse
Methods included from Center
Methods included from Quote
#_nt_quote_entry, #_nt_quote_last_paragraph, #_nt_quote_paragraph, #_nt_quote_type
Methods included from Verbatim
#_nt_verbatim, #_nt_verbatim_text, #_nt_verbatim_type
Methods included from List
#_nt_item, #_nt_label, #_nt_label_content, #_nt_label_end, #_nt_label_start, #_nt_label_text, #_nt_list, #_nt_list_type
Instance Method Details
#_nt_block ⇒ Object
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 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 186 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/hemingway/block/block.rb', line 118 def _nt_block start_index = index if node_cache[:block].has_key?(index) cached = node_cache[:block][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_block_start s1 << r2 if r2 r3 = _nt_list_type s1 << r3 if r3 if has_terminal?("}", false, index) r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r4 = nil end s1 << r4 if r4 r6 = _nt_whitespace if r6 r5 = r6 else r5 = instantiate_node(SyntaxNode,input, index...index) end s1 << r5 if r5 r7 = _nt_list s1 << r7 if r7 r9 = _nt_whitespace if r9 r8 = r9 else r8 = instantiate_node(SyntaxNode,input, index...index) end s1 << r8 if r8 r10 = _nt_block_end s1 << r10 if r10 r11 = _nt_list_type s1 << r11 if r11 if has_terminal?("}", false, index) r12 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r12 = nil end s1 << r12 if r12 i13 = index r14 = lambda { |seq| seq[1].text_value == seq[7].text_value }.call(s1) if r14 @index = i13 r13 = instantiate_node(SyntaxNode,input, index...index) else r13 = nil end s1 << r13 end end end end end end end end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(Block0) else @index = i1 r1 = nil end if r1 r0 = r1 r0.extend(BlockNode) else i15, s15 = index, [] r16 = _nt_block_start s15 << r16 if r16 r17 = _nt_verbatim_type s15 << r17 if r17 if has_terminal?("}", false, index) r18 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r18 = nil end s15 << r18 if r18 r20 = _nt_whitespace if r20 r19 = r20 else r19 = instantiate_node(SyntaxNode,input, index...index) end s15 << r19 if r19 r21 = _nt_verbatim s15 << r21 if r21 r23 = _nt_whitespace if r23 r22 = r23 else r22 = instantiate_node(SyntaxNode,input, index...index) end s15 << r22 if r22 r24 = _nt_block_end s15 << r24 if r24 r25 = _nt_verbatim_type s15 << r25 if r25 if has_terminal?("}", false, index) r26 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r26 = nil end s15 << r26 end end end end end end end end if s15.last r15 = instantiate_node(SyntaxNode,input, i15...index, s15) r15.extend(Block1) else @index = i15 r15 = nil end if r15 r0 = r15 r0.extend(BlockNode) else i27, s27 = index, [] r28 = _nt_block_start s27 << r28 if r28 r29 = _nt_quote_type s27 << r29 if r29 if has_terminal?("}", false, index) r30 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r30 = nil end s27 << r30 if r30 r32 = _nt_whitespace if r32 r31 = r32 else r31 = instantiate_node(SyntaxNode,input, index...index) end s27 << r31 if r31 r33 = _nt_quote_entry s27 << r33 if r33 r35 = _nt_whitespace if r35 r34 = r35 else r34 = instantiate_node(SyntaxNode,input, index...index) end s27 << r34 if r34 r36 = _nt_block_end s27 << r36 if r36 r37 = _nt_quote_type s27 << r37 if r37 if has_terminal?("}", false, index) r38 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r38 = nil end s27 << r38 end end end end end end end end if s27.last r27 = instantiate_node(SyntaxNode,input, i27...index, s27) r27.extend(Block2) else @index = i27 r27 = nil end if r27 r0 = r27 r0.extend(BlockNode) else i39, s39 = index, [] r40 = _nt_block_start s39 << r40 if r40 r41 = _nt_center_type s39 << r41 if r41 if has_terminal?("}", false, index) r42 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r42 = nil end s39 << r42 if r42 r44 = _nt_whitespace if r44 r43 = r44 else r43 = instantiate_node(SyntaxNode,input, index...index) end s39 << r43 if r43 r45 = _nt_center s39 << r45 if r45 r47 = _nt_whitespace if r47 r46 = r47 else r46 = instantiate_node(SyntaxNode,input, index...index) end s39 << r46 if r46 r48 = _nt_block_end s39 << r48 if r48 r49 = _nt_center_type s39 << r49 if r49 if has_terminal?("}", false, index) r50 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r50 = nil end s39 << r50 end end end end end end end end if s39.last r39 = instantiate_node(SyntaxNode,input, i39...index, s39) r39.extend(Block3) else @index = i39 r39 = nil end if r39 r0 = r39 r0.extend(BlockNode) else @index = i0 r0 = nil end end end end node_cache[:block][start_index] = r0 r0 end |
#_nt_block_end ⇒ Object
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
# File 'lib/hemingway/block/block.rb', line 449 def _nt_block_end start_index = index if node_cache[:block_end].has_key?(index) cached = node_cache[:block_end][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end if has_terminal?("\\end{", false, index) r0 = instantiate_node(SyntaxNode,input, index...(index + 5)) @index += 5 else terminal_parse_failure("\\end{") r0 = nil end node_cache[:block_end][start_index] = r0 r0 end |
#_nt_block_start ⇒ Object
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'lib/hemingway/block/block.rb', line 425 def _nt_block_start start_index = index if node_cache[:block_start].has_key?(index) cached = node_cache[:block_start][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end if has_terminal?("\\begin{", false, index) r0 = instantiate_node(SyntaxNode,input, index...(index + 7)) @index += 7 else terminal_parse_failure("\\begin{") r0 = nil end node_cache[:block_start][start_index] = r0 r0 end |
#root ⇒ Object
14 15 16 |
# File 'lib/hemingway/block/block.rb', line 14 def root @root ||= :block end |