| 1 | #################################################################### | ||
| 2 | # | ||
| 3 | # This file was generated using Parse::Yapp version 1.05. | ||
| 4 | # | ||
| 5 | # Don't edit this file, use source file instead. | ||
| 6 | # | ||
| 7 | # ANY CHANGE MADE HERE WILL BE LOST ! | ||
| 8 | # | ||
| 9 | #################################################################### | ||
| 10 | package Lingua::Ogmios::NLPWrappers::PatternParser; | ||
| 11 | 6 | ▶ | use vars qw ( @ISA ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 6 | @ISA= qw ( Parse::Yapp::Driver ); | |
| 15 | 6 | ▶ | use Parse::Yapp::Driver; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | #line 12 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 18 | |||
| 19 | use Data::Dumper; | ||
| 20 | use warnings; | ||
| 21 | |||
| 22 | my $node_set = []; | ||
| 23 | my $node; | ||
| 24 | my @node_stack; | ||
| 25 | my @uncomplete; | ||
| 26 | my @parse; | ||
| 27 | |||
| 28 | my $action; | ||
| 29 | |||
| 30 | |||
| 31 | my $num_content_words; | ||
| 32 | my @pos_sequence; | ||
| 33 | my $priority; | ||
| 34 | |||
| 35 | my $distance; | ||
| 36 | |||
| 37 | my $pos_sequence; | ||
| 38 | my $pattern; | ||
| 39 | my $parse; | ||
| 40 | my $num_line = 1; | ||
| 41 | |||
| 42 | |||
| 43 | sub new { | ||
| 44 | my($class)=shift; | ||
| 45 | ref($class) | ||
| 46 | and $class=ref($class); | ||
| 47 | |||
| 48 | my($self)=$class->SUPER::new( yyversion => '1.05', | ||
| 49 | yystates => | ||
| 50 | [ | ||
| 51 | {#State 0 | ||
| 52 | DEFAULT => -1, | ||
| 53 | GOTOS => { | ||
| 54 | 'input' => 1 | ||
| 55 | } | ||
| 56 | }, | ||
| 57 | {#State 1 | ||
| 58 | ACTIONS => { | ||
| 59 | 'REGEXP_SEQ' => -8, | ||
| 60 | '' => 2, | ||
| 61 | 'SYNDEP_SEQ' => -5, | ||
| 62 | 'SEMTYPE_TAG' => -8, | ||
| 63 | 'TERMCONTENT_SEQ' => -8, | ||
| 64 | "\n" => 5, | ||
| 65 | 'TERM_SEQ' => -8, | ||
| 66 | 'WORD_SEQ' => -8, | ||
| 67 | 'POSTAG_TAG' => -8, | ||
| 68 | 'OPEN_CHUNK' => -8, | ||
| 69 | 'DISTANCE_SEQ' => -8, | ||
| 70 | 'error' => 6 | ||
| 71 | }, | ||
| 72 | GOTOS => { | ||
| 73 | 'pattern' => 3, | ||
| 74 | '@1-0' => 4, | ||
| 75 | 'line' => 7 | ||
| 76 | } | ||
| 77 | }, | ||
| 78 | {#State 2 | ||
| 79 | DEFAULT => 0 | ||
| 80 | }, | ||
| 81 | {#State 3 | ||
| 82 | ACTIONS => { | ||
| 83 | 'REGEXP_SEQ' => 16, | ||
| 84 | 'SEMTYPE_TAG' => 18, | ||
| 85 | 'TERMCONTENT_SEQ' => 10, | ||
| 86 | 'TERM_SEQ' => 20, | ||
| 87 | 'WORD_SEQ' => 22, | ||
| 88 | 'POSTAG_TAG' => 12, | ||
| 89 | 'OPEN_CHUNK' => 13, | ||
| 90 | 'error' => 14, | ||
| 91 | 'DISTANCE_SEQ' => 15 | ||
| 92 | }, | ||
| 93 | GOTOS => { | ||
| 94 | 'POSTAG' => 9, | ||
| 95 | 'WORD' => 8, | ||
| 96 | 'CHUNK' => 17, | ||
| 97 | 'DISTANCE' => 11, | ||
| 98 | 'TERMCONTENT' => 19, | ||
| 99 | 'REGEXP' => 21, | ||
| 100 | 'TERM' => 23, | ||
| 101 | 'SEMTYPE' => 24 | ||
| 102 | } | ||
| 103 | }, | ||
| 104 | {#State 4 | ||
| 105 | ACTIONS => { | ||
| 106 | 'SYNDEP_SEQ' => 25, | ||
| 107 | 'error' => 26 | ||
| 108 | }, | ||
| 109 | GOTOS => { | ||
| 110 | 'SYN_DEP' => 27 | ||
| 111 | } | ||
| 112 | }, | ||
| 113 | {#State 5 | ||
| 114 | DEFAULT => -3 | ||
| 115 | }, | ||
| 116 | {#State 6 | ||
| 117 | ACTIONS => { | ||
| 118 | "\npattern: " => 29, | ||
| 119 | "\nline:" => 28 | ||
| 120 | } | ||
| 121 | }, | ||
| 122 | {#State 7 | ||
| 123 | DEFAULT => -2 | ||
| 124 | }, | ||
| 125 | {#State 8 | ||
| 126 | DEFAULT => -15 | ||
| 127 | }, | ||
| 128 | {#State 9 | ||
| 129 | DEFAULT => -12 | ||
| 130 | }, | ||
| 131 | {#State 10 | ||
| 132 | DEFAULT => -31 | ||
| 133 | }, | ||
| 134 | {#State 11 | ||
| 135 | ACTIONS => { | ||
| 136 | 'error' => 30, | ||
| 137 | 'ACTION_SEQ' => 32 | ||
| 138 | }, | ||
| 139 | GOTOS => { | ||
| 140 | 'ACTION' => 31 | ||
| 141 | } | ||
| 142 | }, | ||
| 143 | {#State 12 | ||
| 144 | DEFAULT => -23 | ||
| 145 | }, | ||
| 146 | {#State 13 | ||
| 147 | DEFAULT => -35, | ||
| 148 | GOTOS => { | ||
| 149 | '@2-1' => 33 | ||
| 150 | } | ||
| 151 | }, | ||
| 152 | {#State 14 | ||
| 153 | ACTIONS => { | ||
| 154 | "\nDISTANCE: " => 35, | ||
| 155 | "\nTERM: " => 34, | ||
| 156 | "\nREGEXP: " => 39, | ||
| 157 | "\nSEMTYPE: " => 40, | ||
| 158 | "\nCHUNK: " => 36, | ||
| 159 | "\nTERM_CONTENT: " => 37, | ||
| 160 | "\nWORD: " => 38, | ||
| 161 | "\nPOSTAG: " => 41 | ||
| 162 | } | ||
| 163 | }, | ||
| 164 | {#State 15 | ||
| 165 | DEFAULT => -19 | ||
| 166 | }, | ||
| 167 | {#State 16 | ||
| 168 | DEFAULT => -25 | ||
| 169 | }, | ||
| 170 | {#State 17 | ||
| 171 | DEFAULT => -10 | ||
| 172 | }, | ||
| 173 | {#State 18 | ||
| 174 | DEFAULT => -21 | ||
| 175 | }, | ||
| 176 | {#State 19 | ||
| 177 | DEFAULT => -14 | ||
| 178 | }, | ||
| 179 | {#State 20 | ||
| 180 | DEFAULT => -29 | ||
| 181 | }, | ||
| 182 | {#State 21 | ||
| 183 | DEFAULT => -11 | ||
| 184 | }, | ||
| 185 | {#State 22 | ||
| 186 | DEFAULT => -27 | ||
| 187 | }, | ||
| 188 | {#State 23 | ||
| 189 | DEFAULT => -13 | ||
| 190 | }, | ||
| 191 | {#State 24 | ||
| 192 | DEFAULT => -9 | ||
| 193 | }, | ||
| 194 | {#State 25 | ||
| 195 | DEFAULT => -33 | ||
| 196 | }, | ||
| 197 | {#State 26 | ||
| 198 | ACTIONS => { | ||
| 199 | "\nSYNDEP: " => 42 | ||
| 200 | } | ||
| 201 | }, | ||
| 202 | {#State 27 | ||
| 203 | ACTIONS => { | ||
| 204 | 'REGEXP_SEQ' => -38, | ||
| 205 | 'SEMTYPE_TAG' => -38, | ||
| 206 | 'TERMCONTENT_SEQ' => -38, | ||
| 207 | 'TERM_SEQ' => -38, | ||
| 208 | 'WORD_SEQ' => -38, | ||
| 209 | 'POSTAG_TAG' => -38, | ||
| 210 | 'error' => 43, | ||
| 211 | 'DISTANCE_SEQ' => -38 | ||
| 212 | }, | ||
| 213 | GOTOS => { | ||
| 214 | 'phrase' => 44 | ||
| 215 | } | ||
| 216 | }, | ||
| 217 | {#State 28 | ||
| 218 | DEFAULT => -7 | ||
| 219 | }, | ||
| 220 | {#State 29 | ||
| 221 | DEFAULT => -16 | ||
| 222 | }, | ||
| 223 | {#State 30 | ||
| 224 | ACTIONS => { | ||
| 225 | "\nACTION: " => 45 | ||
| 226 | } | ||
| 227 | }, | ||
| 228 | {#State 31 | ||
| 229 | ACTIONS => { | ||
| 230 | "\n" => 46 | ||
| 231 | } | ||
| 232 | }, | ||
| 233 | {#State 32 | ||
| 234 | DEFAULT => -17 | ||
| 235 | }, | ||
| 236 | {#State 33 | ||
| 237 | ACTIONS => { | ||
| 238 | 'SYNDEP_SEQ' => 25, | ||
| 239 | 'error' => 26 | ||
| 240 | }, | ||
| 241 | GOTOS => { | ||
| 242 | 'SYN_DEP' => 47 | ||
| 243 | } | ||
| 244 | }, | ||
| 245 | {#State 34 | ||
| 246 | DEFAULT => -30 | ||
| 247 | }, | ||
| 248 | {#State 35 | ||
| 249 | DEFAULT => -20 | ||
| 250 | }, | ||
| 251 | {#State 36 | ||
| 252 | DEFAULT => -37 | ||
| 253 | }, | ||
| 254 | {#State 37 | ||
| 255 | DEFAULT => -32 | ||
| 256 | }, | ||
| 257 | {#State 38 | ||
| 258 | DEFAULT => -28 | ||
| 259 | }, | ||
| 260 | {#State 39 | ||
| 261 | DEFAULT => -26 | ||
| 262 | }, | ||
| 263 | {#State 40 | ||
| 264 | DEFAULT => -22 | ||
| 265 | }, | ||
| 266 | {#State 41 | ||
| 267 | DEFAULT => -24 | ||
| 268 | }, | ||
| 269 | {#State 42 | ||
| 270 | DEFAULT => -34 | ||
| 271 | }, | ||
| 272 | {#State 43 | ||
| 273 | ACTIONS => { | ||
| 274 | "\nphrase: " => 48 | ||
| 275 | } | ||
| 276 | }, | ||
| 277 | {#State 44 | ||
| 278 | ACTIONS => { | ||
| 279 | 'REGEXP_SEQ' => 16, | ||
| 280 | 'SEMTYPE_TAG' => 18, | ||
| 281 | 'TERMCONTENT_SEQ' => 10, | ||
| 282 | 'TERM_SEQ' => 20, | ||
| 283 | 'WORD_SEQ' => 22, | ||
| 284 | 'POSTAG_TAG' => 12, | ||
| 285 | 'error' => 52, | ||
| 286 | 'DISTANCE_SEQ' => 15 | ||
| 287 | }, | ||
| 288 | GOTOS => { | ||
| 289 | 'REGEXP' => 54, | ||
| 290 | 'POSTAG' => 50, | ||
| 291 | 'WORD' => 49, | ||
| 292 | 'TERM' => 55, | ||
| 293 | 'DISTANCE' => 51, | ||
| 294 | 'SEMTYPE' => 56, | ||
| 295 | 'TERMCONTENT' => 53 | ||
| 296 | } | ||
| 297 | }, | ||
| 298 | {#State 45 | ||
| 299 | DEFAULT => -18 | ||
| 300 | }, | ||
| 301 | {#State 46 | ||
| 302 | DEFAULT => -4 | ||
| 303 | }, | ||
| 304 | {#State 47 | ||
| 305 | ACTIONS => { | ||
| 306 | 'REGEXP_SEQ' => -38, | ||
| 307 | 'CLOSE_CHUNK' => -38, | ||
| 308 | 'SEMTYPE_TAG' => -38, | ||
| 309 | 'TERMCONTENT_SEQ' => -38, | ||
| 310 | 'TERM_SEQ' => -38, | ||
| 311 | 'WORD_SEQ' => -38, | ||
| 312 | 'POSTAG_TAG' => -38, | ||
| 313 | 'error' => 43 | ||
| 314 | }, | ||
| 315 | GOTOS => { | ||
| 316 | 'phrase' => 57 | ||
| 317 | } | ||
| 318 | }, | ||
| 319 | {#State 48 | ||
| 320 | DEFAULT => -45 | ||
| 321 | }, | ||
| 322 | {#State 49 | ||
| 323 | DEFAULT => -44 | ||
| 324 | }, | ||
| 325 | {#State 50 | ||
| 326 | DEFAULT => -41 | ||
| 327 | }, | ||
| 328 | {#State 51 | ||
| 329 | ACTIONS => { | ||
| 330 | 'error' => 30, | ||
| 331 | 'ACTION_SEQ' => 32 | ||
| 332 | }, | ||
| 333 | GOTOS => { | ||
| 334 | 'ACTION' => 58 | ||
| 335 | } | ||
| 336 | }, | ||
| 337 | {#State 52 | ||
| 338 | ACTIONS => { | ||
| 339 | "\nTERM_CONTENT: " => 37, | ||
| 340 | "\nWORD: " => 38, | ||
| 341 | "\nDISTANCE: " => 35, | ||
| 342 | "\nTERM: " => 34, | ||
| 343 | "\nREGEXP: " => 39, | ||
| 344 | "\nPOSTAG: " => 41, | ||
| 345 | "\nSEMTYPE: " => 40 | ||
| 346 | } | ||
| 347 | }, | ||
| 348 | {#State 53 | ||
| 349 | DEFAULT => -43 | ||
| 350 | }, | ||
| 351 | {#State 54 | ||
| 352 | DEFAULT => -39 | ||
| 353 | }, | ||
| 354 | {#State 55 | ||
| 355 | DEFAULT => -42 | ||
| 356 | }, | ||
| 357 | {#State 56 | ||
| 358 | DEFAULT => -40 | ||
| 359 | }, | ||
| 360 | {#State 57 | ||
| 361 | ACTIONS => { | ||
| 362 | 'REGEXP_SEQ' => 16, | ||
| 363 | 'CLOSE_CHUNK' => 60, | ||
| 364 | 'SEMTYPE_TAG' => 18, | ||
| 365 | 'TERMCONTENT_SEQ' => 10, | ||
| 366 | 'TERM_SEQ' => 20, | ||
| 367 | 'WORD_SEQ' => 22, | ||
| 368 | 'POSTAG_TAG' => 12, | ||
| 369 | 'error' => 59 | ||
| 370 | }, | ||
| 371 | GOTOS => { | ||
| 372 | 'REGEXP' => 54, | ||
| 373 | 'POSTAG' => 50, | ||
| 374 | 'WORD' => 49, | ||
| 375 | 'TERM' => 55, | ||
| 376 | 'SEMTYPE' => 56, | ||
| 377 | 'TERMCONTENT' => 53 | ||
| 378 | } | ||
| 379 | }, | ||
| 380 | {#State 58 | ||
| 381 | ACTIONS => { | ||
| 382 | "\n" => 61 | ||
| 383 | } | ||
| 384 | }, | ||
| 385 | {#State 59 | ||
| 386 | ACTIONS => { | ||
| 387 | "\nTERM_CONTENT: " => 37, | ||
| 388 | "\nWORD: " => 38, | ||
| 389 | "\nTERM: " => 34, | ||
| 390 | "\nREGEXP: " => 39, | ||
| 391 | "\nPOSTAG: " => 41, | ||
| 392 | "\nSEMTYPE: " => 40 | ||
| 393 | } | ||
| 394 | }, | ||
| 395 | {#State 60 | ||
| 396 | DEFAULT => -36 | ||
| 397 | }, | ||
| 398 | {#State 61 | ||
| 399 | DEFAULT => -6 | ||
| 400 | } | ||
| 401 | ], | ||
| 402 | yyrules => | ||
| 403 | [ | ||
| 404 | [#Rule 0 | ||
| 405 | '$start', 2, undef | ||
| 406 | ], | ||
| 407 | [#Rule 1 | ||
| 408 | 'input', 0, undef | ||
| 409 | ], | ||
| 410 | [#Rule 2 | ||
| 411 | 'input', 2, | ||
| 412 | sub | ||
| 413 | #line 40 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 414 | { # print STDERR "INPUT $_[2] \n"; | ||
| 415 | } | ||
| 416 | ], | ||
| 417 | [#Rule 3 | ||
| 418 | 'line', 1, | ||
| 419 | sub | ||
| 420 | #line 44 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 421 | { $_[1] } | ||
| 422 | ], | ||
| 423 | [#Rule 4 | ||
| 424 | 'line', 4, | ||
| 425 | sub | ||
| 426 | #line 45 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 427 | { | ||
| 428 | # print STDERR "=>$_[1] ($action)\n"; | ||
| 429 | $_[0]->YYData->{PPRS}->addSynPattern($node_set, $action, $distance); | ||
| 430 | @$node_set = (); | ||
| 431 | } | ||
| 432 | ], | ||
| 433 | [#Rule 5 | ||
| 434 | '@1-0', 0, | ||
| 435 | sub | ||
| 436 | #line 50 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 437 | { #print STDERR "START\n"; | ||
| 438 | $node = $node_set; | ||
| 439 | } | ||
| 440 | ], | ||
| 441 | [#Rule 6 | ||
| 442 | 'line', 6, | ||
| 443 | sub | ||
| 444 | #line 52 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 445 | { | ||
| 446 | push @$node, shift @$node; | ||
| 447 | # print "++>$_[1] ($action)\n"; | ||
| 448 | $_[0]->YYData->{PPRS}->addSynPattern($node_set, $action, $distance); | ||
| 449 | @$node_set = (); | ||
| 450 | } | ||
| 451 | ], | ||
| 452 | [#Rule 7 | ||
| 453 | 'line', 2, | ||
| 454 | sub | ||
| 455 | #line 58 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 456 | { $_[0]->YYErrok } | ||
| 457 | ], | ||
| 458 | [#Rule 8 | ||
| 459 | 'pattern', 0, | ||
| 460 | sub | ||
| 461 | #line 67 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 462 | { #print STDERR "START\n"; | ||
| 463 | $node = $node_set; | ||
| 464 | } | ||
| 465 | ], | ||
| 466 | [#Rule 9 | ||
| 467 | 'pattern', 2, undef | ||
| 468 | ], | ||
| 469 | [#Rule 10 | ||
| 470 | 'pattern', 2, undef | ||
| 471 | ], | ||
| 472 | [#Rule 11 | ||
| 473 | 'pattern', 2, undef | ||
| 474 | ], | ||
| 475 | [#Rule 12 | ||
| 476 | 'pattern', 2, undef | ||
| 477 | ], | ||
| 478 | [#Rule 13 | ||
| 479 | 'pattern', 2, undef | ||
| 480 | ], | ||
| 481 | [#Rule 14 | ||
| 482 | 'pattern', 2, undef | ||
| 483 | ], | ||
| 484 | [#Rule 15 | ||
| 485 | 'pattern', 2, undef | ||
| 486 | ], | ||
| 487 | [#Rule 16 | ||
| 488 | 'pattern', 2, | ||
| 489 | sub | ||
| 490 | #line 77 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 491 | { $_[0]->YYErrok } | ||
| 492 | ], | ||
| 493 | [#Rule 17 | ||
| 494 | 'ACTION', 1, | ||
| 495 | sub | ||
| 496 | #line 80 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 497 | { | ||
| 498 | $action = $_[1]; | ||
| 499 | # print STDERR "ACTION: $action\n"; | ||
| 500 | } | ||
| 501 | ], | ||
| 502 | [#Rule 18 | ||
| 503 | 'ACTION', 2, | ||
| 504 | sub | ||
| 505 | #line 84 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 506 | { $_[0]->YYErrok } | ||
| 507 | ], | ||
| 508 | [#Rule 19 | ||
| 509 | 'DISTANCE', 1, | ||
| 510 | sub | ||
| 511 | #line 87 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 512 | { | ||
| 513 | $distance = $_[1]; | ||
| 514 | # print STDERR "DISTANCE: $distance\n"; | ||
| 515 | } | ||
| 516 | ], | ||
| 517 | [#Rule 20 | ||
| 518 | 'DISTANCE', 2, | ||
| 519 | sub | ||
| 520 | #line 91 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 521 | { $_[0]->YYErrok } | ||
| 522 | ], | ||
| 523 | [#Rule 21 | ||
| 524 | 'SEMTYPE', 1, | ||
| 525 | sub | ||
| 526 | #line 94 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 527 | { | ||
| 528 | # print STDERR "SEMTYPE $_[1]\n"; | ||
| 529 | push @$node, {'type' => 'semtype', | ||
| 530 | 'semtype' => $_[1]}; | ||
| 531 | } | ||
| 532 | ], | ||
| 533 | [#Rule 22 | ||
| 534 | 'SEMTYPE', 2, | ||
| 535 | sub | ||
| 536 | #line 99 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 537 | { $_[0]->YYErrok } | ||
| 538 | ], | ||
| 539 | [#Rule 23 | ||
| 540 | 'POSTAG', 1, | ||
| 541 | sub | ||
| 542 | #line 102 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 543 | { | ||
| 544 | # print STDERR "POSTAG $_[1]\n"; | ||
| 545 | push @$node, {'type' => 'postag', | ||
| 546 | 'postag' => $_[1]}; | ||
| 547 | } | ||
| 548 | ], | ||
| 549 | [#Rule 24 | ||
| 550 | 'POSTAG', 2, | ||
| 551 | sub | ||
| 552 | #line 107 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 553 | { $_[0]->YYErrok } | ||
| 554 | ], | ||
| 555 | [#Rule 25 | ||
| 556 | 'REGEXP', 1, | ||
| 557 | sub | ||
| 558 | #line 110 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 559 | { | ||
| 560 | # print STDERR "REGEXP $_[1]\n"; | ||
| 561 | push @$node, {'type' => 'word_re', | ||
| 562 | 'word_re' => $_[1]}; | ||
| 563 | } | ||
| 564 | ], | ||
| 565 | [#Rule 26 | ||
| 566 | 'REGEXP', 2, | ||
| 567 | sub | ||
| 568 | #line 115 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 569 | { $_[0]->YYErrok } | ||
| 570 | ], | ||
| 571 | [#Rule 27 | ||
| 572 | 'WORD', 1, | ||
| 573 | sub | ||
| 574 | #line 118 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 575 | { | ||
| 576 | # print STDERR "WORD $_[1]\n"; | ||
| 577 | push @$node, {'type' => 'word', | ||
| 578 | 'word' => $_[1]}; | ||
| 579 | } | ||
| 580 | ], | ||
| 581 | [#Rule 28 | ||
| 582 | 'WORD', 2, | ||
| 583 | sub | ||
| 584 | #line 123 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 585 | { $_[0]->YYErrok } | ||
| 586 | ], | ||
| 587 | [#Rule 29 | ||
| 588 | 'TERM', 1, | ||
| 589 | sub | ||
| 590 | #line 126 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 591 | { | ||
| 592 | # print STDERR "TERM $_[1]\n"; | ||
| 593 | push @$node, {'type' => 'term', | ||
| 594 | 'term' => $_[1]}; | ||
| 595 | } | ||
| 596 | ], | ||
| 597 | [#Rule 30 | ||
| 598 | 'TERM', 2, | ||
| 599 | sub | ||
| 600 | #line 131 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 601 | { $_[0]->YYErrok } | ||
| 602 | ], | ||
| 603 | [#Rule 31 | ||
| 604 | 'TERMCONTENT', 1, | ||
| 605 | sub | ||
| 606 | #line 134 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 607 | { | ||
| 608 | # print STDERR "TERMCONTENT $_[1]\n"; | ||
| 609 | push @$node, {'type' => 'termContent', | ||
| 610 | 'termContent' => $_[1]}; | ||
| 611 | } | ||
| 612 | ], | ||
| 613 | [#Rule 32 | ||
| 614 | 'TERMCONTENT', 2, | ||
| 615 | sub | ||
| 616 | #line 139 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 617 | { $_[0]->YYErrok } | ||
| 618 | ], | ||
| 619 | [#Rule 33 | ||
| 620 | 'SYN_DEP', 1, | ||
| 621 | sub | ||
| 622 | #line 142 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 623 | { | ||
| 624 | # print STDERR "SYNDEP $_[1]\n"; | ||
| 625 | push @$node, {'type' => 'syndep', | ||
| 626 | 'syndep' => $_[1]}; | ||
| 627 | } | ||
| 628 | ], | ||
| 629 | [#Rule 34 | ||
| 630 | 'SYN_DEP', 2, | ||
| 631 | sub | ||
| 632 | #line 147 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 633 | { $_[0]->YYErrok } | ||
| 634 | ], | ||
| 635 | [#Rule 35 | ||
| 636 | '@2-1', 0, | ||
| 637 | sub | ||
| 638 | #line 152 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 639 | { my $nodetmp = []; | ||
| 640 | push @node_stack, $node; | ||
| 641 | push @$node, {'type' => 'chunk', | ||
| 642 | 'chunk' => $nodetmp }; | ||
| 643 | $node = $nodetmp; | ||
| 644 | } | ||
| 645 | ], | ||
| 646 | [#Rule 36 | ||
| 647 | 'CHUNK', 5, | ||
| 648 | sub | ||
| 649 | #line 157 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 650 | { | ||
| 651 | # print STDERR "CHUNK $_[3]\n"; | ||
| 652 | push @$node, shift @$node; | ||
| 653 | $node = pop @node_stack; | ||
| 654 | } | ||
| 655 | ], | ||
| 656 | [#Rule 37 | ||
| 657 | 'CHUNK', 2, | ||
| 658 | sub | ||
| 659 | #line 162 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 660 | { $_[0]->YYErrok } | ||
| 661 | ], | ||
| 662 | [#Rule 38 | ||
| 663 | 'phrase', 0, | ||
| 664 | sub | ||
| 665 | #line 166 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 666 | {# print STDERR "phrase\n"; | ||
| 667 | } | ||
| 668 | ], | ||
| 669 | [#Rule 39 | ||
| 670 | 'phrase', 2, undef | ||
| 671 | ], | ||
| 672 | [#Rule 40 | ||
| 673 | 'phrase', 2, undef | ||
| 674 | ], | ||
| 675 | [#Rule 41 | ||
| 676 | 'phrase', 2, undef | ||
| 677 | ], | ||
| 678 | [#Rule 42 | ||
| 679 | 'phrase', 2, undef | ||
| 680 | ], | ||
| 681 | [#Rule 43 | ||
| 682 | 'phrase', 2, undef | ||
| 683 | ], | ||
| 684 | [#Rule 44 | ||
| 685 | 'phrase', 2, undef | ||
| 686 | ], | ||
| 687 | [#Rule 45 | ||
| 688 | 'phrase', 2, | ||
| 689 | sub | ||
| 690 | #line 174 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 691 | { $_[0]->YYErrok } | ||
| 692 | ] | ||
| 693 | ], | ||
| 694 | @_); | ||
| 695 | bless($self,$class); | ||
| 696 | } | ||
| 697 | |||
| 698 | #line 177 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 699 | |||
| 700 | |||
| 701 | |||
| 702 | |||
| 703 | sub _Error { | ||
| 704 | exists $_[0]->YYData->{ERRMSG} | ||
| 705 | and do { | ||
| 706 | print $_[0]->YYData->{ERRMSG}; | ||
| 707 | delete $_[0]->YYData->{ERRMSG}; | ||
| 708 | return; | ||
| 709 | }; | ||
| 710 | print STDERR "Syntax error.\n"; | ||
| 711 | print "Syntax error.\n"; | ||
| 712 | } | ||
| 713 | |||
| 714 | sub _Lexer { | ||
| 715 | my($parser)=shift; | ||
| 716 | |||
| 717 | my $fh = $parser->YYData->{FH}; | ||
| 718 | |||
| 719 | my $semtype = '(@semtype\(([^\)]+)\))'; | ||
| 720 | my $openchunk = '(\[)'; | ||
| 721 | my $closechunk = '(\])'; | ||
| 722 | my $syn_dep = '(@syndep\(([^\)]+)\))'; | ||
| 723 | my $postag = '(@postag\(([^\)]+)\))'; | ||
| 724 | # my $regexp = '(@re_begin(.*?)@re_end)'; | ||
| 725 | my $regexp = '(@word_re(\(.*?\))@)'; | ||
| 726 | my $termcontent = '(@term\(([^\)]+)\))'; | ||
| 727 | my $term = '(@term@)'; | ||
| 728 | my $word = '([^ \|\n\]]+)'; | ||
| 729 | my $action = '(\|\|\s*([^\n]+))'; | ||
| 730 | my $distance = '(\|\|\s*([0-9]+))'; | ||
| 731 | |||
| 732 | $parser->YYData->{INPUT} | ||
| 733 | or $parser->YYData->{INPUT} = <$fh> | ||
| 734 | or return('', undef); | ||
| 735 | |||
| 736 | $parser->YYData->{INPUT} =~ s/^[ \t]*#.*//; | ||
| 737 | $parser->YYData->{INPUT} =~ s/^[ \t]*//; | ||
| 738 | |||
| 739 | # warn "==>" . $parser->YYData->{INPUT} . ";\n"; | ||
| 740 | # print "==>" . $parser->YYData->{INPUT} . ";\n"; | ||
| 741 | |||
| 742 | for ($parser->YYData->{INPUT}) { | ||
| 743 | s/^$semtype\s*// and return ('SEMTYPE_TAG', $2); | ||
| 744 | s/^$openchunk\s*// and return ('OPEN_CHUNK', $1); | ||
| 745 | s/^$closechunk// and return('CLOSE_CHUNK', $1); | ||
| 746 | s/^$syn_dep// and return('SYNDEP_SEQ', $2); | ||
| 747 | s/^$postag// and return('POSTAG_TAG', $2); | ||
| 748 | s/^$regexp// and return('REGEXP_SEQ', $2); | ||
| 749 | s/^$termcontent// and return('TERMCONTENT_SEQ', $2); | ||
| 750 | s/^$term// and return('TERM_SEQ', $1); | ||
| 751 | s/^$distance// and return('DISTANCE_SEQ', $2); | ||
| 752 | s/^$action// and return('ACTION_SEQ', $2); | ||
| 753 | s/^$word// and return('WORD_SEQ', $1); | ||
| 754 | s/^(.)//s and return($1,$1); | ||
| 755 | } | ||
| 756 | } | ||
| 757 | |||
| 758 | # sub Run { | ||
| 759 | # my($self)=shift; | ||
| 760 | # $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error ); | ||
| 761 | # } | ||
| 762 | |||
| 763 | # my($parsingpattern)=new ParsingPatternParser; | ||
| 764 | # $parsingpattern->Run; | ||
| 765 | |||
| 766 | |||
| 767 | __END__ | ||