Module: ElasticityGrammar
- Includes:
- Treetop::Runtime
- Included in:
- ElasticityGrammarParser
- Defined in:
- lib/opennebula/flow/grammar.rb
Overview
Copyright 2002-2024, OpenNebula Project, OpenNebula Systems #
#
Licensed under the Apache License, Version 2.0 (the “License”); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at #
#
www.apache.org/licenses/LICENSE-2.0 #
#
Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an “AS IS” BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ————————————————————————— #
Defined Under Namespace
Modules: BooleanExp0, BooleanExp1, BooleanExp2, BooleanExp3, CompOp0, CompOp1, CompOp2, CompOp3, CompOp4, CompOp5, Expression0, Expression1, LogicCond0, LogicCond1, LogicCond2, LogicCond3, LogicCond4, LogicCond5, Number0, Number1, Number2, Number3, Operand0, Operand1, Variable0, Variable1, Variable2, Variable3
Instance Method Summary collapse
- #_nt_boolean_exp ⇒ Object
- #_nt_comp_op ⇒ Object
- #_nt_expression ⇒ Object
- #_nt_logic_cond ⇒ Object
- #_nt_number ⇒ Object
- #_nt_operand ⇒ Object
- #_nt_space ⇒ Object
- #_nt_variable ⇒ Object
- #root ⇒ Object
Instance Method Details
#_nt_boolean_exp ⇒ Object
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 |
# File 'lib/opennebula/flow/grammar.rb', line 165 def _nt_boolean_exp start_index = index if node_cache[:boolean_exp].has_key?(index) cached = node_cache[:boolean_exp][index] if cached node_cache[:boolean_exp][index] = 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_logic_cond s1 << r2 if r2 r3 = _nt_space s1 << r3 if r3 i4 = index if (match_len = has_terminal?('&&', false, index)) r5 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('\'&&\'') r5 = nil end if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r4 = r5 else if (match_len = has_terminal?('&', false, index)) r6 = true @index += match_len else terminal_parse_failure('\'&\'') r6 = nil end if r6 r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true r4 = r6 else @index = i4 r4 = nil end end s1 << r4 if r4 r7 = _nt_space s1 << r7 if r7 r8 = _nt_expression s1 << r8 end end end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(BooleanExp0) r1.extend(BooleanExp1) else @index = i1 r1 = nil end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else i9, s9 = index, [] r10 = _nt_logic_cond s9 << r10 if r10 r11 = _nt_space s9 << r11 if r11 i12 = index if (match_len = has_terminal?('||', false, index)) r13 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('\'||\'') r13 = nil end if r13 r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true r12 = r13 else if (match_len = has_terminal?('|', false, index)) r14 = true @index += match_len else terminal_parse_failure('\'|\'') r14 = nil end if r14 r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true r12 = r14 else @index = i12 r12 = nil end end s9 << r12 if r12 r15 = _nt_space s9 << r15 if r15 r16 = _nt_expression s9 << r16 end end end end if s9.last r9 = instantiate_node(SyntaxNode,input, i9...index, s9) r9.extend(BooleanExp2) r9.extend(BooleanExp3) else @index = i9 r9 = nil end if r9 r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true r0 = r9 else @index = i0 r0 = nil end end node_cache[:boolean_exp][start_index] = r0 r0 end |
#_nt_comp_op ⇒ Object
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 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 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 |
# File 'lib/opennebula/flow/grammar.rb', line 551 def _nt_comp_op start_index = index if node_cache[:comp_op].has_key?(index) cached = node_cache[:comp_op][index] if cached node_cache[:comp_op][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index i1 = index if (match_len = has_terminal?('==', false, index)) r2 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('\'==\'') r2 = nil end if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r1 = r2 r1.extend(CompOp0) else if (match_len = has_terminal?('=', false, index)) r3 = true @index += match_len else terminal_parse_failure('\'=\'') r3 = nil end if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r1 = r3 r1.extend(CompOp0) else @index = i1 r1 = nil end end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else i4 = index if (match_len = has_terminal?('!=', false, index)) r5 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('\'!=\'') r5 = nil end if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r4 = r5 r4.extend(CompOp1) else if (match_len = has_terminal?('<>', false, index)) r6 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('\'<>\'') r6 = nil end if r6 r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true r4 = r6 r4.extend(CompOp1) else @index = i4 r4 = nil end end if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r0 = r4 else if (match_len = has_terminal?('>=', false, index)) r7 = instantiate_node(SyntaxNode,input, index...(index + match_len)) r7.extend(CompOp2) @index += match_len else terminal_parse_failure('\'>=\'') r7 = nil end if r7 r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true r0 = r7 else if (match_len = has_terminal?('>', false, index)) r8 = instantiate_node(SyntaxNode,input, index...(index + match_len)) r8.extend(CompOp3) @index += match_len else terminal_parse_failure('\'>\'') r8 = nil end if r8 r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true r0 = r8 else if (match_len = has_terminal?('<=', false, index)) r9 = instantiate_node(SyntaxNode,input, index...(index + match_len)) r9.extend(CompOp4) @index += match_len else terminal_parse_failure('\'<=\'') r9 = nil end if r9 r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true r0 = r9 else if (match_len = has_terminal?('<', false, index)) r10 = instantiate_node(SyntaxNode,input, index...(index + match_len)) r10.extend(CompOp5) @index += match_len else terminal_parse_failure('\'<\'') r10 = nil end if r10 r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true r0 = r10 else @index = i0 r0 = nil end end end end end end node_cache[:comp_op][start_index] = r0 r0 end |
#_nt_expression ⇒ Object
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 |
# File 'lib/opennebula/flow/grammar.rb', line 47 def _nt_expression start_index = index if node_cache[:expression].has_key?(index) cached = node_cache[:expression][index] if cached node_cache[:expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_space s0 << r1 if r1 i2 = index r3 = _nt_boolean_exp if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r2 = r3 else r4 = _nt_logic_cond if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r2 = r4 else @index = i2 r2 = nil end end s0 << r2 if r2 r5 = _nt_space s0 << r5 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Expression0) r0.extend(Expression1) else @index = i0 r0 = nil end node_cache[:expression][start_index] = r0 r0 end |
#_nt_logic_cond ⇒ Object
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 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 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 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
# File 'lib/opennebula/flow/grammar.rb', line 389 def _nt_logic_cond start_index = index if node_cache[:logic_cond].has_key?(index) cached = node_cache[:logic_cond][index] if cached node_cache[:logic_cond][index] = 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_operand s1 << r2 if r2 r3 = _nt_space s1 << r3 if r3 r4 = _nt_comp_op s1 << r4 if r4 r5 = _nt_space s1 << r5 if r5 r6 = _nt_operand s1 << r6 end end end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(LogicCond0) r1.extend(LogicCond1) else @index = i1 r1 = nil end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else i7, s7 = index, [] if (match_len = has_terminal?('!', false, index)) r8 = true @index += match_len else terminal_parse_failure('\'!\'') r8 = nil end s7 << r8 if r8 r9 = _nt_space s7 << r9 if r9 r10 = _nt_expression s7 << r10 end end if s7.last r7 = instantiate_node(SyntaxNode,input, i7...index, s7) r7.extend(LogicCond2) r7.extend(LogicCond3) else @index = i7 r7 = nil end if r7 r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true r0 = r7 else i11, s11 = index, [] if (match_len = has_terminal?('(', false, index)) r12 = true @index += match_len else terminal_parse_failure('\'(\'') r12 = nil end s11 << r12 if r12 r13 = _nt_space s11 << r13 if r13 r14 = _nt_expression s11 << r14 if r14 r15 = _nt_space s11 << r15 if r15 if (match_len = has_terminal?(')', false, index)) r16 = true @index += match_len else terminal_parse_failure('\')\'') r16 = nil end s11 << r16 end end end end if s11.last r11 = instantiate_node(SyntaxNode,input, i11...index, s11) r11.extend(LogicCond4) r11.extend(LogicCond5) else @index = i11 r11 = nil end if r11 r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true r0 = r11 else @index = i0 r0 = nil end end end node_cache[:logic_cond][start_index] = r0 r0 end |
#_nt_number ⇒ Object
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 |
# File 'lib/opennebula/flow/grammar.rb', line 759 def _nt_number start_index = index if node_cache[:number].has_key?(index) cached = node_cache[:number][index] if cached node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index i1, s1 = index, [] if (match_len = has_terminal?('-', false, index)) r3 = true @index += match_len else terminal_parse_failure('\'-\'') r3 = nil end if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s1 << r2 if r2 s4, i4 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index) r5 = true @index += 1 else terminal_parse_failure('[0-9]') r5 = nil end if r5 s4 << r5 else break end end if s4.empty? @index = i4 r4 = nil else r4 = instantiate_node(SyntaxNode,input, i4...index, s4) end s1 << r4 if r4 if (match_len = has_terminal?('.', false, index)) r6 = true @index += match_len else terminal_parse_failure('\'.\'') r6 = nil end s1 << r6 if r6 s7, i7 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index) r8 = true @index += 1 else terminal_parse_failure('[0-9]') r8 = nil end if r8 s7 << r8 else break end end if s7.empty? @index = i7 r7 = nil else r7 = instantiate_node(SyntaxNode,input, i7...index, s7) end s1 << r7 end end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(Number0) r1.extend(Number1) else @index = i1 r1 = nil end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else i9, s9 = index, [] if (match_len = has_terminal?('-', false, index)) r11 = true @index += match_len else terminal_parse_failure('\'-\'') r11 = nil end if r11 r10 = r11 else r10 = instantiate_node(SyntaxNode,input, index...index) end s9 << r10 if r10 s12, i12 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index) r13 = true @index += 1 else terminal_parse_failure('[0-9]') r13 = nil end if r13 s12 << r13 else break end end if s12.empty? @index = i12 r12 = nil else r12 = instantiate_node(SyntaxNode,input, i12...index, s12) end s9 << r12 end if s9.last r9 = instantiate_node(SyntaxNode,input, i9...index, s9) r9.extend(Number2) r9.extend(Number3) else @index = i9 r9 = nil end if r9 r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true r0 = r9 else @index = i0 r0 = nil end end node_cache[:number][start_index] = r0 r0 end |
#_nt_operand ⇒ Object
703 704 705 706 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 |
# File 'lib/opennebula/flow/grammar.rb', line 703 def _nt_operand start_index = index if node_cache[:operand].has_key?(index) cached = node_cache[:operand][index] if cached node_cache[:operand][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_number if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_variable if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else @index = i0 r0 = nil end end node_cache[:operand][start_index] = r0 r0 end |
#_nt_space ⇒ Object
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
# File 'lib/opennebula/flow/grammar.rb', line 1158 def _nt_space start_index = index if node_cache[:space].has_key?(index) cached = node_cache[:space][index] if cached node_cache[:space][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 (match_len = has_terminal?(' ', false, index)) r1 = true @index += match_len else terminal_parse_failure('\' \'') r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:space][start_index] = r0 r0 end |
#_nt_variable ⇒ Object
975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 |
# File 'lib/opennebula/flow/grammar.rb', line 975 def _nt_variable start_index = index if node_cache[:variable].has_key?(index) cached = node_cache[:variable][index] if cached node_cache[:variable][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index i1, s1 = index, [] if (match_len = has_terminal?('"', false, index)) r2 = true @index += match_len else terminal_parse_failure('\'"\'') r2 = nil end s1 << r2 if r2 if has_terminal?(@regexps[gr = '\A[a-zA-Z]'] ||= Regexp.new(gr), :regexp, index) r3 = true @index += 1 else terminal_parse_failure('[a-zA-Z]') r3 = nil end s1 << r3 if r3 s4, i4 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9a-zA-Z_]'] ||= Regexp.new(gr), :regexp, index) r5 = true @index += 1 else terminal_parse_failure('[0-9a-zA-Z_]') r5 = nil end if r5 s4 << r5 else break end end r4 = instantiate_node(SyntaxNode,input, i4...index, s4) s1 << r4 if r4 if (match_len = has_terminal?('"', false, index)) r6 = true @index += match_len else terminal_parse_failure('\'"\'') r6 = nil end s1 << r6 end end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(Variable0) else @index = i1 r1 = nil end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 r0.extend(Variable3) else i7, s7 = index, [] if (match_len = has_terminal?('\'', false, index)) r8 = true @index += match_len else terminal_parse_failure('\'\\\'\'') r8 = nil end s7 << r8 if r8 if has_terminal?(@regexps[gr = '\A[a-zA-Z]'] ||= Regexp.new(gr), :regexp, index) r9 = true @index += 1 else terminal_parse_failure('[a-zA-Z]') r9 = nil end s7 << r9 if r9 s10, i10 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9a-zA-Z_]'] ||= Regexp.new(gr), :regexp, index) r11 = true @index += 1 else terminal_parse_failure('[0-9a-zA-Z_]') r11 = nil end if r11 s10 << r11 else break end end r10 = instantiate_node(SyntaxNode,input, i10...index, s10) s7 << r10 if r10 if (match_len = has_terminal?('\'', false, index)) r12 = true @index += match_len else terminal_parse_failure('\'\\\'\'') r12 = nil end s7 << r12 end end end if s7.last r7 = instantiate_node(SyntaxNode,input, i7...index, s7) r7.extend(Variable1) else @index = i7 r7 = nil end if r7 r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true r0 = r7 r0.extend(Variable3) else i13, s13 = index, [] if has_terminal?(@regexps[gr = '\A[a-zA-Z]'] ||= Regexp.new(gr), :regexp, index) r14 = true @index += 1 else terminal_parse_failure('[a-zA-Z]') r14 = nil end s13 << r14 if r14 s15, i15 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9a-zA-Z_]'] ||= Regexp.new(gr), :regexp, index) r16 = true @index += 1 else terminal_parse_failure('[0-9a-zA-Z_]') r16 = nil end if r16 s15 << r16 else break end end r15 = instantiate_node(SyntaxNode,input, i15...index, s15) s13 << r15 end if s13.last r13 = instantiate_node(SyntaxNode,input, i13...index, s13) r13.extend(Variable2) else @index = i13 r13 = nil end if r13 r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true r0 = r13 r0.extend(Variable3) else @index = i0 r0 = nil end end end node_cache[:variable][start_index] = r0 r0 end |
#root ⇒ Object
23 24 25 |
# File 'lib/opennebula/flow/grammar.rb', line 23 def root @root ||= :expression end |