Module: Cldr::Export::Data::Plurals::Grammar
- Includes:
- Treetop::Runtime
- Defined in:
- lib/cldr/export/data/plurals/grammar.rb
Defined Under Namespace
Modules: AndCondition0, AndCondition1, Expr0, Expr1, InRelation0, IsRelation0, OrCondition0, OrCondition1, Range0, WithinRelation0
Instance Method Summary collapse
- #_nt_and_condition ⇒ Object
- #_nt_expr ⇒ Object
- #_nt_in_relation ⇒ Object
- #_nt_is_relation ⇒ Object
- #_nt_or_condition ⇒ Object
- #_nt_range ⇒ Object
- #_nt_relation ⇒ Object
- #_nt_value ⇒ Object
- #_nt_within_relation ⇒ Object
- #root ⇒ Object
Instance Method Details
#_nt_and_condition ⇒ Object
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/cldr/export/data/plurals/grammar.rb', line 103 def _nt_and_condition start_index = index if node_cache[:and_condition].has_key?(index) cached = node_cache[:and_condition][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_relation s0 << r1 if r1 i3, s3 = index, [] if input.index(" and ", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 5)) @index += 5 else terminal_parse_failure(" and ") r4 = nil end s3 << r4 if r4 r5 = _nt_relation s3 << r5 end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(AndCondition0) 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(AndCondition1) else self.index = i0 r0 = nil end node_cache[:and_condition][start_index] = r0 return r0 end |
#_nt_expr ⇒ Object
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 |
# File 'lib/cldr/export/data/plurals/grammar.rb', line 396 def _nt_expr start_index = index if node_cache[:expr].has_key?(index) cached = node_cache[:expr][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] if input.index("n", index) == index r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("n") r1 = nil end s0 << r1 if r1 i3, s3 = index, [] if input.index(" mod ", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 5)) @index += 5 else terminal_parse_failure(" mod ") r4 = nil end s3 << r4 if r4 r5 = _nt_value s3 << r5 end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(Expr0) 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(Expr1) else self.index = i0 r0 = nil end node_cache[:expr][start_index] = r0 return r0 end |
#_nt_in_relation ⇒ Object
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 |
# File 'lib/cldr/export/data/plurals/grammar.rb', line 271 def _nt_in_relation start_index = index if node_cache[:in_relation].has_key?(index) cached = node_cache[:in_relation][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_expr s0 << r1 if r1 if input.index(" not", index) == index r3 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure(" not") r3 = nil end if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 if r2 if input.index(" in ", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure(" in ") r4 = nil end s0 << r4 if r4 r5 = _nt_range s0 << r5 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(InRelation0) else self.index = i0 r0 = nil end node_cache[:in_relation][start_index] = r0 return r0 end |
#_nt_is_relation ⇒ Object
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 |
# File 'lib/cldr/export/data/plurals/grammar.rb', line 208 def _nt_is_relation start_index = index if node_cache[:is_relation].has_key?(index) cached = node_cache[:is_relation][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_expr s0 << r1 if r1 if input.index(" is ", index) == index r2 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure(" is ") r2 = nil end s0 << r2 if r2 if input.index("not ", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure("not ") r4 = nil end if r4 r3 = r4 else r3 = instantiate_node(SyntaxNode,input, index...index) end s0 << r3 if r3 r5 = _nt_value s0 << r5 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(IsRelation0) else self.index = i0 r0 = nil end node_cache[:is_relation][start_index] = r0 return r0 end |
#_nt_or_condition ⇒ Object
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 |
# File 'lib/cldr/export/data/plurals/grammar.rb', line 38 def _nt_or_condition start_index = index if node_cache[:or_condition].has_key?(index) cached = node_cache[:or_condition][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_and_condition s0 << r1 if r1 i3, s3 = index, [] if input.index(" or ", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure(" or ") r4 = nil end s3 << r4 if r4 r5 = _nt_and_condition s3 << r5 end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(OrCondition0) 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(OrCondition1) else self.index = i0 r0 = nil end node_cache[:or_condition][start_index] = r0 return r0 end |
#_nt_range ⇒ Object
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 |
# File 'lib/cldr/export/data/plurals/grammar.rb', line 464 def _nt_range start_index = index if node_cache[:range].has_key?(index) cached = node_cache[:range][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_value s0 << r1 if r1 if input.index("..", index) == index r2 = instantiate_node(SyntaxNode,input, index...(index + 2)) @index += 2 else terminal_parse_failure("..") r2 = nil end s0 << r2 if r2 r3 = _nt_value s0 << r3 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Range0) else self.index = i0 r0 = nil end node_cache[:range][start_index] = r0 return r0 end |
#_nt_relation ⇒ 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 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/cldr/export/data/plurals/grammar.rb', line 155 def _nt_relation start_index = index if node_cache[:relation].has_key?(index) cached = node_cache[:relation][index] @index = cached.interval.end if cached return cached end i0 = index r1 = _nt_is_relation if r1 r0 = r1 else r2 = _nt_in_relation if r2 r0 = r2 else r3 = _nt_within_relation if r3 r0 = r3 else if input.index("n", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("n") r4 = nil end if r4 r0 = r4 else self.index = i0 r0 = nil end end end end node_cache[:relation][start_index] = r0 return r0 end |
#_nt_value ⇒ Object
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
# File 'lib/cldr/export/data/plurals/grammar.rb', line 502 def _nt_value start_index = index if node_cache[:value].has_key?(index) cached = node_cache[:value][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[:value][start_index] = r0 return r0 end |
#_nt_within_relation ⇒ Object
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 |
# File 'lib/cldr/export/data/plurals/grammar.rb', line 334 def _nt_within_relation start_index = index if node_cache[:within_relation].has_key?(index) cached = node_cache[:within_relation][index] @index = cached.interval.end if cached return cached end i0, s0 = index, [] r1 = _nt_expr s0 << r1 if r1 if input.index(" not", index) == index r3 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure(" not") r3 = nil end if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 if r2 if input.index(" within ", index) == index r4 = instantiate_node(SyntaxNode,input, index...(index + 8)) @index += 8 else terminal_parse_failure(" within ") r4 = nil end s0 << r4 if r4 r5 = _nt_range s0 << r5 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(WithinRelation0) else self.index = i0 r0 = nil end node_cache[:within_relation][start_index] = r0 return r0 end |
#root ⇒ Object
21 22 23 |
# File 'lib/cldr/export/data/plurals/grammar.rb', line 21 def root @root || :or_condition end |