Module: InputGrammar
Defined Under Namespace
Modules: AmPmTime0, AmPmTime1, Hours0, Hours1, Minutes0, Minutes1, Minutes2, Root0, TimeFrom0, TimeFrom1, TimeInDigits0, TimeInDigits1, TimeInDigits2, TimeInWords0, TimeInWords1, TimeInWords2, TimeRange0, TimeRange1
Instance Method Summary collapse
- #_nt_activity ⇒ Object
- #_nt_am_pm_time ⇒ Object
- #_nt_hours ⇒ Object
- #_nt_integer ⇒ Object
- #_nt_minutes ⇒ Object
- #_nt_root ⇒ Object
- #_nt_time ⇒ Object
- #_nt_time_from ⇒ Object
- #_nt_time_in_digits ⇒ Object
- #_nt_time_in_words ⇒ Object
- #_nt_time_range ⇒ Object
- #root ⇒ Object
Instance Method Details
#_nt_activity ⇒ 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 |
# File 'lib/worked/inputgrammar.rb', line 57 def _nt_activity start_index = index if node_cache[:activity].has_key?(index) cached = node_cache[:activity][index] @index = cached.interval.end if cached return cached end s0, i0 = [], index loop do if index < input_length r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("any character") r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:activity][start_index] = r0 return r0 end |
#_nt_am_pm_time ⇒ Object
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 |
# File 'lib/worked/inputgrammar.rb', line 251 def _nt_am_pm_time start_index = index if node_cache[:am_pm_time].has_key?(index) cached = node_cache[:am_pm_time][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_time_in_digits s0 << r1 if r1 i3 = index if input.index(" am", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 3)) @index += 3 else terminal_parse_failure(" am") r4 = nil end if r4 r3 = r4 else if input.index(" pm", index) == index r5 = instantiate_node(SyntaxNode,input, index...(index + 3)) @index += 3 else terminal_parse_failure(" pm") r5 = nil end if r5 r3 = r5 else if input.index("am", index) == index r6 = instantiate_node(SyntaxNode,input, index...(index + 2)) @index += 2 else terminal_parse_failure("am") r6 = nil end if r6 r3 = r6 else if input.index("pm", index) == index r7 = instantiate_node(SyntaxNode,input, index...(index + 2)) @index += 2 else terminal_parse_failure("pm") r7 = nil end if r7 r3 = r7 else self.index = i3 r3 = nil end end end end if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(AmPmTime0) r0.extend(AmPmTime1) else self.index = i0 r0 = nil end node_cache[:am_pm_time][start_index] = r0 return r0 end |
#_nt_hours ⇒ Object
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
# File 'lib/worked/inputgrammar.rb', line 508 def _nt_hours start_index = index if node_cache[:hours].has_key?(index) cached = node_cache[:hours][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_integer s0 << r1 if r1 if input.index(" ", index) == index r3 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(" ") r3 = nil end if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 if r2 i4 = index i5, s5 = index, [] if input.index("hour", index) == index r6 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure("hour") r6 = nil end s5 << r6 if r6 if input.index("s", index) == index r8 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("s") r8 = nil end if r8 r7 = r8 else r7 = instantiate_node(SyntaxNode,input, index...index) end s5 << r7 end if s5.last r5 = instantiate_node(SyntaxNode,input, i5...index, s5) r5.extend(Hours0) else self.index = i5 r5 = nil end if r5 r4 = r5 else if input.index("h", index) == index r9 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("h") r9 = nil end if r9 r4 = r9 else self.index = i4 r4 = nil end end s0 << r4 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Hours1) else self.index = i0 r0 = nil end node_cache[:hours][start_index] = r0 return r0 end |
#_nt_integer ⇒ Object
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
# File 'lib/worked/inputgrammar.rb', line 707 def _nt_integer start_index = index if node_cache[:integer].has_key?(index) cached = node_cache[:integer][index] @index = cached.interval.end if cached return cached end s0, i0 = [], index loop do if input.index(Regexp.new('[0-9]'), index) == index r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:integer][start_index] = r0 return r0 end |
#_nt_minutes ⇒ Object
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 |
# File 'lib/worked/inputgrammar.rb', line 615 def _nt_minutes start_index = index if node_cache[:minutes].has_key?(index) cached = node_cache[:minutes][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_integer s0 << r1 if r1 if input.index(" ", index) == index r3 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(" ") r3 = nil end if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 if r2 i4 = index i5, s5 = index, [] if input.index("minute", index) == index r6 = instantiate_node(SyntaxNode,input, index...(index + 6)) @index += 6 else terminal_parse_failure("minute") r6 = nil end s5 << r6 if r6 if input.index("s", index) == index r8 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("s") r8 = nil end if r8 r7 = r8 else r7 = instantiate_node(SyntaxNode,input, index...index) end s5 << r7 end if s5.last r5 = instantiate_node(SyntaxNode,input, i5...index, s5) r5.extend(Minutes0) else self.index = i5 r5 = nil end if r5 r4 = r5 else if input.index("m", index) == index r9 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("m") r9 = nil end if r9 r4 = r9 else self.index = i4 r4 = nil end end s0 << r4 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Minutes1) r0.extend(Minutes2) else self.index = i0 r0 = nil end node_cache[:minutes][start_index] = r0 return r0 end |
#_nt_root ⇒ 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/worked/inputgrammar.rb', line 19 def _nt_root start_index = index if node_cache[:root].has_key?(index) cached = node_cache[:root][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_time s0 << r1 if r1 if input.index(" on ", index) == index r2 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure(" on ") r2 = nil end s0 << r2 if r2 r3 = _nt_activity s0 << r3 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Root0) else self.index = i0 r0 = nil end node_cache[:root][start_index] = r0 return r0 end |
#_nt_time ⇒ Object
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 |
# File 'lib/worked/inputgrammar.rb', line 87 def _nt_time start_index = index if node_cache[:time].has_key?(index) cached = node_cache[:time][index] @index = cached.interval.end if cached return cached end i0 = index r1 = _nt_time_from if r1 r0 = r1 else r2 = _nt_time_in_words if r2 r0 = r2 else r3 = _nt_time_range if r3 r0 = r3 else r4 = _nt_time_in_digits if r4 r0 = r4 else self.index = i0 r0 = nil end end end end node_cache[:time][start_index] = r0 return r0 end |
#_nt_time_from ⇒ Object
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 |
# File 'lib/worked/inputgrammar.rb', line 136 def _nt_time_from start_index = index if node_cache[:time_from].has_key?(index) cached = node_cache[:time_from][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] if input.index("from ", index) == index r1 = instantiate_node(SyntaxNode,input, index...(index + 5)) @index += 5 else terminal_parse_failure("from ") r1 = nil end s0 << r1 if r1 r2 = _nt_am_pm_time s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TimeFrom0) r0.extend(TimeFrom1) else self.index = i0 r0 = nil end node_cache[:time_from][start_index] = r0 return r0 end |
#_nt_time_in_digits ⇒ Object
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/worked/inputgrammar.rb', line 445 def _nt_time_in_digits start_index = index if node_cache[:time_in_digits].has_key?(index) cached = node_cache[:time_in_digits][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_integer s0 << r1 if r1 i3, s3 = index, [] if input.index(":", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(":") r4 = nil end s3 << r4 if r4 r5 = _nt_integer s3 << r5 end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(TimeInDigits0) else self.index = i3 r3 = nil end if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TimeInDigits1) r0.extend(TimeInDigits2) else self.index = i0 r0 = nil end node_cache[:time_in_digits][start_index] = r0 return r0 end |
#_nt_time_in_words ⇒ Object
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 |
# File 'lib/worked/inputgrammar.rb', line 353 def _nt_time_in_words start_index = index if node_cache[:time_in_words].has_key?(index) cached = node_cache[:time_in_words][index] @index = cached.interval.end if cached return cached end i0 = index r1 = _nt_minutes if r1 r0 = r1 else i2, s2 = index, [] r3 = _nt_hours s2 << r3 if r3 i5, s5 = index, [] if input.index(" ", index) == index r7 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(" ") r7 = nil end if r7 r6 = r7 else r6 = instantiate_node(SyntaxNode,input, index...index) end s5 << r6 if r6 r8 = _nt_minutes s5 << r8 end if s5.last r5 = instantiate_node(SyntaxNode,input, i5...index, s5) r5.extend(TimeInWords0) else self.index = i5 r5 = nil end if r5 r4 = r5 else r4 = instantiate_node(SyntaxNode,input, index...index) end s2 << r4 end if s2.last r2 = instantiate_node(SyntaxNode,input, i2...index, s2) r2.extend(TimeInWords1) r2.extend(TimeInWords2) else self.index = i2 r2 = nil end if r2 r0 = r2 else self.index = i0 r0 = nil end end node_cache[:time_in_words][start_index] = r0 return r0 end |
#_nt_time_range ⇒ Object
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 |
# File 'lib/worked/inputgrammar.rb', line 191 def _nt_time_range start_index = index if node_cache[:time_range].has_key?(index) cached = node_cache[:time_range][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_am_pm_time s0 << r1 if r1 if input.index(" to ", index) == index r2 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure(" to ") r2 = nil end s0 << r2 if r2 r3 = _nt_am_pm_time s0 << r3 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TimeRange0) r0.extend(TimeRange1) else self.index = i0 r0 = nil end node_cache[:time_range][start_index] = r0 return r0 end |
#root ⇒ Object
5 6 7 |
# File 'lib/worked/inputgrammar.rb', line 5 def root @root || :root end |