| 1 | #################################################################### | ||
| 2 | # | ||
| 3 | # This file was generated using Parse::Yapp version 1.21. | ||
| 4 | # | ||
| 5 | # Don't edit this file, use source file instead. | ||
| 6 | # | ||
| 7 | # ANY CHANGE MADE HERE WILL BE LOST ! | ||
| 8 | # | ||
| 9 | #################################################################### | ||
| 10 | package XDR::Parse v1.0.1; | ||
| 11 | 1 | ▶ | use vars qw ( @ISA ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 1 | @ISA= qw ( Parse::Yapp::Driver ); | |
| 15 | 1 | ▶ | use Parse::Yapp::Driver; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | #line 5 "xdr.yp" | ||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | sub new { | ||
| 23 | my($class)=shift; | ||
| 24 | ref($class) | ||
| 25 | and $class=ref($class); | ||
| 26 | |||
| 27 | my($self)=$class->SUPER::new( yyversion => '1.21', | ||
| 28 | yystates => | ||
| 29 | [ | ||
| 30 | {#State 0 | ||
| 31 | ACTIONS => { | ||
| 32 | "const" => 2, | ||
| 33 | "enum" => 6, | ||
| 34 | "union" => 8, | ||
| 35 | "typedef" => 10, | ||
| 36 | 'PREPROC' => 9, | ||
| 37 | "struct" => 4, | ||
| 38 | 'PASSTHROUGH' => 3 | ||
| 39 | }, | ||
| 40 | GOTOS => { | ||
| 41 | 'definitions' => 11, | ||
| 42 | 'specification' => 7, | ||
| 43 | 'typeDef' => 12, | ||
| 44 | 'constantDef' => 5, | ||
| 45 | 'definition' => 1 | ||
| 46 | } | ||
| 47 | }, | ||
| 48 | {#State 1 | ||
| 49 | ACTIONS => { | ||
| 50 | 'PASSTHROUGH' => 3, | ||
| 51 | "struct" => 4, | ||
| 52 | 'PREPROC' => 9, | ||
| 53 | "typedef" => 10, | ||
| 54 | "union" => 8, | ||
| 55 | "enum" => 6, | ||
| 56 | "const" => 2 | ||
| 57 | }, | ||
| 58 | DEFAULT => -3, | ||
| 59 | GOTOS => { | ||
| 60 | 'definitions' => 13, | ||
| 61 | 'constantDef' => 5, | ||
| 62 | 'typeDef' => 12, | ||
| 63 | 'definition' => 1 | ||
| 64 | } | ||
| 65 | }, | ||
| 66 | {#State 2 | ||
| 67 | ACTIONS => { | ||
| 68 | 'IDENT' => 14 | ||
| 69 | } | ||
| 70 | }, | ||
| 71 | {#State 3 | ||
| 72 | DEFAULT => -5 | ||
| 73 | }, | ||
| 74 | {#State 4 | ||
| 75 | ACTIONS => { | ||
| 76 | 'IDENT' => 15 | ||
| 77 | } | ||
| 78 | }, | ||
| 79 | {#State 5 | ||
| 80 | DEFAULT => -8 | ||
| 81 | }, | ||
| 82 | {#State 6 | ||
| 83 | ACTIONS => { | ||
| 84 | 'IDENT' => 16 | ||
| 85 | } | ||
| 86 | }, | ||
| 87 | {#State 7 | ||
| 88 | ACTIONS => { | ||
| 89 | '' => 17 | ||
| 90 | } | ||
| 91 | }, | ||
| 92 | {#State 8 | ||
| 93 | ACTIONS => { | ||
| 94 | 'IDENT' => 18 | ||
| 95 | } | ||
| 96 | }, | ||
| 97 | {#State 9 | ||
| 98 | DEFAULT => -6 | ||
| 99 | }, | ||
| 100 | {#State 10 | ||
| 101 | ACTIONS => { | ||
| 102 | "void" => 24, | ||
| 103 | "double" => 25, | ||
| 104 | "struct" => 26, | ||
| 105 | "bool" => 27, | ||
| 106 | "int" => 20, | ||
| 107 | 'IDENT' => 19, | ||
| 108 | "char" => 21, | ||
| 109 | "float" => 22, | ||
| 110 | "string" => 23, | ||
| 111 | "long" => 33, | ||
| 112 | "union" => 35, | ||
| 113 | "unsigned" => 36, | ||
| 114 | "hyper" => 37, | ||
| 115 | "opaque" => 28, | ||
| 116 | "enum" => 30, | ||
| 117 | "quadruple" => 31, | ||
| 118 | "short" => 32 | ||
| 119 | }, | ||
| 120 | GOTOS => { | ||
| 121 | 'declaration' => 29, | ||
| 122 | 'typeSpecifier' => 34 | ||
| 123 | } | ||
| 124 | }, | ||
| 125 | {#State 11 | ||
| 126 | ACTIONS => { | ||
| 127 | 'TRAILING_COMMENT' => 38 | ||
| 128 | }, | ||
| 129 | DEFAULT => -1 | ||
| 130 | }, | ||
| 131 | {#State 12 | ||
| 132 | DEFAULT => -7 | ||
| 133 | }, | ||
| 134 | {#State 13 | ||
| 135 | DEFAULT => -4 | ||
| 136 | }, | ||
| 137 | {#State 14 | ||
| 138 | ACTIONS => { | ||
| 139 | "=" => 39 | ||
| 140 | } | ||
| 141 | }, | ||
| 142 | {#State 15 | ||
| 143 | ACTIONS => { | ||
| 144 | "{" => 41 | ||
| 145 | }, | ||
| 146 | GOTOS => { | ||
| 147 | 'structBody' => 40 | ||
| 148 | } | ||
| 149 | }, | ||
| 150 | {#State 16 | ||
| 151 | ACTIONS => { | ||
| 152 | "{" => 42 | ||
| 153 | }, | ||
| 154 | GOTOS => { | ||
| 155 | 'enumBody' => 43 | ||
| 156 | } | ||
| 157 | }, | ||
| 158 | {#State 17 | ||
| 159 | DEFAULT => 0 | ||
| 160 | }, | ||
| 161 | {#State 18 | ||
| 162 | ACTIONS => { | ||
| 163 | "switch" => 44 | ||
| 164 | }, | ||
| 165 | GOTOS => { | ||
| 166 | 'switch' => 45 | ||
| 167 | } | ||
| 168 | }, | ||
| 169 | {#State 19 | ||
| 170 | DEFAULT => -48 | ||
| 171 | }, | ||
| 172 | {#State 20 | ||
| 173 | DEFAULT => -30 | ||
| 174 | }, | ||
| 175 | {#State 21 | ||
| 176 | DEFAULT => -33 | ||
| 177 | }, | ||
| 178 | {#State 22 | ||
| 179 | DEFAULT => -41 | ||
| 180 | }, | ||
| 181 | {#State 23 | ||
| 182 | ACTIONS => { | ||
| 183 | 'IDENT' => 46 | ||
| 184 | } | ||
| 185 | }, | ||
| 186 | {#State 24 | ||
| 187 | DEFAULT => -61 | ||
| 188 | }, | ||
| 189 | {#State 25 | ||
| 190 | DEFAULT => -42 | ||
| 191 | }, | ||
| 192 | {#State 26 | ||
| 193 | ACTIONS => { | ||
| 194 | "{" => 41 | ||
| 195 | }, | ||
| 196 | GOTOS => { | ||
| 197 | 'structBody' => 47 | ||
| 198 | } | ||
| 199 | }, | ||
| 200 | {#State 27 | ||
| 201 | DEFAULT => -44 | ||
| 202 | }, | ||
| 203 | {#State 28 | ||
| 204 | ACTIONS => { | ||
| 205 | 'IDENT' => 48 | ||
| 206 | } | ||
| 207 | }, | ||
| 208 | {#State 29 | ||
| 209 | ACTIONS => { | ||
| 210 | ";" => 49 | ||
| 211 | } | ||
| 212 | }, | ||
| 213 | {#State 30 | ||
| 214 | ACTIONS => { | ||
| 215 | "{" => 42 | ||
| 216 | }, | ||
| 217 | GOTOS => { | ||
| 218 | 'enumBody' => 50 | ||
| 219 | } | ||
| 220 | }, | ||
| 221 | {#State 31 | ||
| 222 | DEFAULT => -43 | ||
| 223 | }, | ||
| 224 | {#State 32 | ||
| 225 | DEFAULT => -35 | ||
| 226 | }, | ||
| 227 | {#State 33 | ||
| 228 | DEFAULT => -37 | ||
| 229 | }, | ||
| 230 | {#State 34 | ||
| 231 | ACTIONS => { | ||
| 232 | "*" => 51, | ||
| 233 | 'IDENT' => 52 | ||
| 234 | } | ||
| 235 | }, | ||
| 236 | {#State 35 | ||
| 237 | ACTIONS => { | ||
| 238 | "switch" => 44 | ||
| 239 | }, | ||
| 240 | GOTOS => { | ||
| 241 | 'switch' => 53 | ||
| 242 | } | ||
| 243 | }, | ||
| 244 | {#State 36 | ||
| 245 | ACTIONS => { | ||
| 246 | "long" => 55, | ||
| 247 | "hyper" => 56, | ||
| 248 | "int" => 58, | ||
| 249 | "char" => 57, | ||
| 250 | "short" => 54 | ||
| 251 | }, | ||
| 252 | DEFAULT => -31 | ||
| 253 | }, | ||
| 254 | {#State 37 | ||
| 255 | DEFAULT => -39 | ||
| 256 | }, | ||
| 257 | {#State 38 | ||
| 258 | DEFAULT => -2 | ||
| 259 | }, | ||
| 260 | {#State 39 | ||
| 261 | ACTIONS => { | ||
| 262 | 'CONST' => 59, | ||
| 263 | 'IDENT' => 60 | ||
| 264 | } | ||
| 265 | }, | ||
| 266 | {#State 40 | ||
| 267 | ACTIONS => { | ||
| 268 | ";" => 61 | ||
| 269 | } | ||
| 270 | }, | ||
| 271 | {#State 41 | ||
| 272 | ACTIONS => { | ||
| 273 | "enum" => 30, | ||
| 274 | "short" => 32, | ||
| 275 | "quadruple" => 31, | ||
| 276 | "opaque" => 28, | ||
| 277 | "unsigned" => 36, | ||
| 278 | "hyper" => 37, | ||
| 279 | "union" => 35, | ||
| 280 | "long" => 33, | ||
| 281 | "float" => 22, | ||
| 282 | "string" => 23, | ||
| 283 | "int" => 20, | ||
| 284 | 'IDENT' => 19, | ||
| 285 | "char" => 21, | ||
| 286 | "struct" => 26, | ||
| 287 | "bool" => 27, | ||
| 288 | "void" => 24, | ||
| 289 | "double" => 25 | ||
| 290 | }, | ||
| 291 | GOTOS => { | ||
| 292 | 'declaration' => 63, | ||
| 293 | 'structItem' => 62, | ||
| 294 | 'structItems' => 64, | ||
| 295 | 'typeSpecifier' => 34 | ||
| 296 | } | ||
| 297 | }, | ||
| 298 | {#State 42 | ||
| 299 | ACTIONS => { | ||
| 300 | 'IDENT' => 66 | ||
| 301 | }, | ||
| 302 | GOTOS => { | ||
| 303 | 'enumItems' => 67, | ||
| 304 | 'enumItem' => 65 | ||
| 305 | } | ||
| 306 | }, | ||
| 307 | {#State 43 | ||
| 308 | ACTIONS => { | ||
| 309 | ";" => 68 | ||
| 310 | } | ||
| 311 | }, | ||
| 312 | {#State 44 | ||
| 313 | ACTIONS => { | ||
| 314 | "(" => 69 | ||
| 315 | } | ||
| 316 | }, | ||
| 317 | {#State 45 | ||
| 318 | ACTIONS => { | ||
| 319 | ";" => 70 | ||
| 320 | } | ||
| 321 | }, | ||
| 322 | {#State 46 | ||
| 323 | ACTIONS => { | ||
| 324 | "<" => 71 | ||
| 325 | } | ||
| 326 | }, | ||
| 327 | {#State 47 | ||
| 328 | DEFAULT => -46 | ||
| 329 | }, | ||
| 330 | {#State 48 | ||
| 331 | ACTIONS => { | ||
| 332 | "[" => 72, | ||
| 333 | "<" => 73 | ||
| 334 | } | ||
| 335 | }, | ||
| 336 | {#State 49 | ||
| 337 | DEFAULT => -9 | ||
| 338 | }, | ||
| 339 | {#State 50 | ||
| 340 | DEFAULT => -45 | ||
| 341 | }, | ||
| 342 | {#State 51 | ||
| 343 | ACTIONS => { | ||
| 344 | 'IDENT' => 74 | ||
| 345 | } | ||
| 346 | }, | ||
| 347 | {#State 52 | ||
| 348 | ACTIONS => { | ||
| 349 | "<" => 75, | ||
| 350 | "[" => 76 | ||
| 351 | }, | ||
| 352 | DEFAULT => -51 | ||
| 353 | }, | ||
| 354 | {#State 53 | ||
| 355 | DEFAULT => -47 | ||
| 356 | }, | ||
| 357 | {#State 54 | ||
| 358 | DEFAULT => -36 | ||
| 359 | }, | ||
| 360 | {#State 55 | ||
| 361 | DEFAULT => -38 | ||
| 362 | }, | ||
| 363 | {#State 56 | ||
| 364 | DEFAULT => -40 | ||
| 365 | }, | ||
| 366 | {#State 57 | ||
| 367 | DEFAULT => -34 | ||
| 368 | }, | ||
| 369 | {#State 58 | ||
| 370 | DEFAULT => -32 | ||
| 371 | }, | ||
| 372 | {#State 59 | ||
| 373 | ACTIONS => { | ||
| 374 | ";" => 77 | ||
| 375 | } | ||
| 376 | }, | ||
| 377 | {#State 60 | ||
| 378 | ACTIONS => { | ||
| 379 | ";" => 78 | ||
| 380 | } | ||
| 381 | }, | ||
| 382 | {#State 61 | ||
| 383 | DEFAULT => -11 | ||
| 384 | }, | ||
| 385 | {#State 62 | ||
| 386 | ACTIONS => { | ||
| 387 | "enum" => 30, | ||
| 388 | "short" => 32, | ||
| 389 | "quadruple" => 31, | ||
| 390 | "opaque" => 28, | ||
| 391 | "unsigned" => 36, | ||
| 392 | "hyper" => 37, | ||
| 393 | "union" => 35, | ||
| 394 | "long" => 33, | ||
| 395 | "string" => 23, | ||
| 396 | "float" => 22, | ||
| 397 | "int" => 20, | ||
| 398 | 'IDENT' => 19, | ||
| 399 | "char" => 21, | ||
| 400 | "struct" => 26, | ||
| 401 | "bool" => 27, | ||
| 402 | "void" => 24, | ||
| 403 | "double" => 25 | ||
| 404 | }, | ||
| 405 | DEFAULT => -23, | ||
| 406 | GOTOS => { | ||
| 407 | 'structItem' => 62, | ||
| 408 | 'declaration' => 63, | ||
| 409 | 'typeSpecifier' => 34, | ||
| 410 | 'structItems' => 79 | ||
| 411 | } | ||
| 412 | }, | ||
| 413 | {#State 63 | ||
| 414 | ACTIONS => { | ||
| 415 | ";" => 80 | ||
| 416 | } | ||
| 417 | }, | ||
| 418 | {#State 64 | ||
| 419 | ACTIONS => { | ||
| 420 | "}" => 81 | ||
| 421 | } | ||
| 422 | }, | ||
| 423 | {#State 65 | ||
| 424 | ACTIONS => { | ||
| 425 | "," => 82 | ||
| 426 | }, | ||
| 427 | DEFAULT => -27 | ||
| 428 | }, | ||
| 429 | {#State 66 | ||
| 430 | ACTIONS => { | ||
| 431 | "=" => 83 | ||
| 432 | } | ||
| 433 | }, | ||
| 434 | {#State 67 | ||
| 435 | ACTIONS => { | ||
| 436 | "}" => 84 | ||
| 437 | } | ||
| 438 | }, | ||
| 439 | {#State 68 | ||
| 440 | DEFAULT => -10 | ||
| 441 | }, | ||
| 442 | {#State 69 | ||
| 443 | ACTIONS => { | ||
| 444 | "union" => 35, | ||
| 445 | "long" => 33, | ||
| 446 | "hyper" => 37, | ||
| 447 | "unsigned" => 36, | ||
| 448 | "opaque" => 28, | ||
| 449 | "short" => 32, | ||
| 450 | "quadruple" => 31, | ||
| 451 | "enum" => 30, | ||
| 452 | "double" => 25, | ||
| 453 | "void" => 24, | ||
| 454 | "bool" => 27, | ||
| 455 | "struct" => 26, | ||
| 456 | "char" => 21, | ||
| 457 | 'IDENT' => 19, | ||
| 458 | "int" => 20, | ||
| 459 | "float" => 22, | ||
| 460 | "string" => 23 | ||
| 461 | }, | ||
| 462 | GOTOS => { | ||
| 463 | 'typeSpecifier' => 34, | ||
| 464 | 'declaration' => 85 | ||
| 465 | } | ||
| 466 | }, | ||
| 467 | {#State 70 | ||
| 468 | DEFAULT => -12 | ||
| 469 | }, | ||
| 470 | {#State 71 | ||
| 471 | ACTIONS => { | ||
| 472 | ">" => 86, | ||
| 473 | 'IDENT' => 89, | ||
| 474 | 'CONST' => 87 | ||
| 475 | }, | ||
| 476 | GOTOS => { | ||
| 477 | 'value' => 88 | ||
| 478 | } | ||
| 479 | }, | ||
| 480 | {#State 72 | ||
| 481 | ACTIONS => { | ||
| 482 | 'CONST' => 87, | ||
| 483 | 'IDENT' => 89 | ||
| 484 | }, | ||
| 485 | GOTOS => { | ||
| 486 | 'value' => 90 | ||
| 487 | } | ||
| 488 | }, | ||
| 489 | {#State 73 | ||
| 490 | ACTIONS => { | ||
| 491 | 'CONST' => 87, | ||
| 492 | ">" => 91, | ||
| 493 | 'IDENT' => 89 | ||
| 494 | }, | ||
| 495 | GOTOS => { | ||
| 496 | 'value' => 92 | ||
| 497 | } | ||
| 498 | }, | ||
| 499 | {#State 74 | ||
| 500 | DEFAULT => -60 | ||
| 501 | }, | ||
| 502 | {#State 75 | ||
| 503 | ACTIONS => { | ||
| 504 | 'CONST' => 87, | ||
| 505 | ">" => 93, | ||
| 506 | 'IDENT' => 89 | ||
| 507 | }, | ||
| 508 | GOTOS => { | ||
| 509 | 'value' => 94 | ||
| 510 | } | ||
| 511 | }, | ||
| 512 | {#State 76 | ||
| 513 | ACTIONS => { | ||
| 514 | 'CONST' => 87, | ||
| 515 | 'IDENT' => 89 | ||
| 516 | }, | ||
| 517 | GOTOS => { | ||
| 518 | 'value' => 95 | ||
| 519 | } | ||
| 520 | }, | ||
| 521 | {#State 77 | ||
| 522 | DEFAULT => -13 | ||
| 523 | }, | ||
| 524 | {#State 78 | ||
| 525 | DEFAULT => -14 | ||
| 526 | }, | ||
| 527 | {#State 79 | ||
| 528 | DEFAULT => -24 | ||
| 529 | }, | ||
| 530 | {#State 80 | ||
| 531 | DEFAULT => -25 | ||
| 532 | }, | ||
| 533 | {#State 81 | ||
| 534 | DEFAULT => -22 | ||
| 535 | }, | ||
| 536 | {#State 82 | ||
| 537 | ACTIONS => { | ||
| 538 | 'IDENT' => 66 | ||
| 539 | }, | ||
| 540 | GOTOS => { | ||
| 541 | 'enumItems' => 96, | ||
| 542 | 'enumItem' => 65 | ||
| 543 | } | ||
| 544 | }, | ||
| 545 | {#State 83 | ||
| 546 | ACTIONS => { | ||
| 547 | 'CONST' => 87, | ||
| 548 | 'IDENT' => 89 | ||
| 549 | }, | ||
| 550 | GOTOS => { | ||
| 551 | 'value' => 97 | ||
| 552 | } | ||
| 553 | }, | ||
| 554 | {#State 84 | ||
| 555 | DEFAULT => -26 | ||
| 556 | }, | ||
| 557 | {#State 85 | ||
| 558 | ACTIONS => { | ||
| 559 | ")" => 98 | ||
| 560 | } | ||
| 561 | }, | ||
| 562 | {#State 86 | ||
| 563 | DEFAULT => -58 | ||
| 564 | }, | ||
| 565 | {#State 87 | ||
| 566 | DEFAULT => -49 | ||
| 567 | }, | ||
| 568 | {#State 88 | ||
| 569 | ACTIONS => { | ||
| 570 | ">" => 99 | ||
| 571 | } | ||
| 572 | }, | ||
| 573 | {#State 89 | ||
| 574 | DEFAULT => -50 | ||
| 575 | }, | ||
| 576 | {#State 90 | ||
| 577 | ACTIONS => { | ||
| 578 | "]" => 100 | ||
| 579 | } | ||
| 580 | }, | ||
| 581 | {#State 91 | ||
| 582 | DEFAULT => -56 | ||
| 583 | }, | ||
| 584 | {#State 92 | ||
| 585 | ACTIONS => { | ||
| 586 | ">" => 101 | ||
| 587 | } | ||
| 588 | }, | ||
| 589 | {#State 93 | ||
| 590 | DEFAULT => -53 | ||
| 591 | }, | ||
| 592 | {#State 94 | ||
| 593 | ACTIONS => { | ||
| 594 | ">" => 102 | ||
| 595 | } | ||
| 596 | }, | ||
| 597 | {#State 95 | ||
| 598 | ACTIONS => { | ||
| 599 | "]" => 103 | ||
| 600 | } | ||
| 601 | }, | ||
| 602 | {#State 96 | ||
| 603 | DEFAULT => -28 | ||
| 604 | }, | ||
| 605 | {#State 97 | ||
| 606 | DEFAULT => -29 | ||
| 607 | }, | ||
| 608 | {#State 98 | ||
| 609 | ACTIONS => { | ||
| 610 | "{" => 104 | ||
| 611 | } | ||
| 612 | }, | ||
| 613 | {#State 99 | ||
| 614 | DEFAULT => -59 | ||
| 615 | }, | ||
| 616 | {#State 100 | ||
| 617 | DEFAULT => -55 | ||
| 618 | }, | ||
| 619 | {#State 101 | ||
| 620 | DEFAULT => -57 | ||
| 621 | }, | ||
| 622 | {#State 102 | ||
| 623 | DEFAULT => -54 | ||
| 624 | }, | ||
| 625 | {#State 103 | ||
| 626 | DEFAULT => -52 | ||
| 627 | }, | ||
| 628 | {#State 104 | ||
| 629 | ACTIONS => { | ||
| 630 | "case" => 105 | ||
| 631 | }, | ||
| 632 | GOTOS => { | ||
| 633 | 'caseClauses' => 106, | ||
| 634 | 'caseClause' => 107, | ||
| 635 | 'caseBody' => 108 | ||
| 636 | } | ||
| 637 | }, | ||
| 638 | {#State 105 | ||
| 639 | ACTIONS => { | ||
| 640 | 'CONST' => 87, | ||
| 641 | 'IDENT' => 89 | ||
| 642 | }, | ||
| 643 | GOTOS => { | ||
| 644 | 'value' => 109 | ||
| 645 | } | ||
| 646 | }, | ||
| 647 | {#State 106 | ||
| 648 | ACTIONS => { | ||
| 649 | "default" => 110 | ||
| 650 | }, | ||
| 651 | DEFAULT => -16, | ||
| 652 | GOTOS => { | ||
| 653 | 'defaultClause' => 111 | ||
| 654 | } | ||
| 655 | }, | ||
| 656 | {#State 107 | ||
| 657 | ACTIONS => { | ||
| 658 | "case" => 105 | ||
| 659 | }, | ||
| 660 | DEFAULT => -18, | ||
| 661 | GOTOS => { | ||
| 662 | 'caseClauses' => 112, | ||
| 663 | 'caseClause' => 107 | ||
| 664 | } | ||
| 665 | }, | ||
| 666 | {#State 108 | ||
| 667 | ACTIONS => { | ||
| 668 | "}" => 113 | ||
| 669 | } | ||
| 670 | }, | ||
| 671 | {#State 109 | ||
| 672 | ACTIONS => { | ||
| 673 | ":" => 114 | ||
| 674 | } | ||
| 675 | }, | ||
| 676 | {#State 110 | ||
| 677 | ACTIONS => { | ||
| 678 | ":" => 115 | ||
| 679 | } | ||
| 680 | }, | ||
| 681 | {#State 111 | ||
| 682 | DEFAULT => -17 | ||
| 683 | }, | ||
| 684 | {#State 112 | ||
| 685 | DEFAULT => -19 | ||
| 686 | }, | ||
| 687 | {#State 113 | ||
| 688 | DEFAULT => -15 | ||
| 689 | }, | ||
| 690 | {#State 114 | ||
| 691 | ACTIONS => { | ||
| 692 | "long" => 33, | ||
| 693 | "union" => 35, | ||
| 694 | "unsigned" => 36, | ||
| 695 | "hyper" => 37, | ||
| 696 | "opaque" => 28, | ||
| 697 | "enum" => 30, | ||
| 698 | "quadruple" => 31, | ||
| 699 | "short" => 32, | ||
| 700 | "void" => 24, | ||
| 701 | "double" => 25, | ||
| 702 | "struct" => 26, | ||
| 703 | "bool" => 27, | ||
| 704 | "int" => 20, | ||
| 705 | 'IDENT' => 19, | ||
| 706 | "char" => 21, | ||
| 707 | "string" => 23, | ||
| 708 | "float" => 22 | ||
| 709 | }, | ||
| 710 | GOTOS => { | ||
| 711 | 'typeSpecifier' => 34, | ||
| 712 | 'declaration' => 116 | ||
| 713 | } | ||
| 714 | }, | ||
| 715 | {#State 115 | ||
| 716 | ACTIONS => { | ||
| 717 | 'IDENT' => 19, | ||
| 718 | "int" => 20, | ||
| 719 | "char" => 21, | ||
| 720 | "string" => 23, | ||
| 721 | "float" => 22, | ||
| 722 | "void" => 24, | ||
| 723 | "double" => 25, | ||
| 724 | "struct" => 26, | ||
| 725 | "bool" => 27, | ||
| 726 | "opaque" => 28, | ||
| 727 | "enum" => 30, | ||
| 728 | "short" => 32, | ||
| 729 | "quadruple" => 31, | ||
| 730 | "union" => 35, | ||
| 731 | "long" => 33, | ||
| 732 | "unsigned" => 36, | ||
| 733 | "hyper" => 37 | ||
| 734 | }, | ||
| 735 | GOTOS => { | ||
| 736 | 'typeSpecifier' => 34, | ||
| 737 | 'declaration' => 117 | ||
| 738 | } | ||
| 739 | }, | ||
| 740 | {#State 116 | ||
| 741 | ACTIONS => { | ||
| 742 | ";" => 118 | ||
| 743 | } | ||
| 744 | }, | ||
| 745 | {#State 117 | ||
| 746 | ACTIONS => { | ||
| 747 | ";" => 119 | ||
| 748 | } | ||
| 749 | }, | ||
| 750 | {#State 118 | ||
| 751 | DEFAULT => -20 | ||
| 752 | }, | ||
| 753 | {#State 119 | ||
| 754 | DEFAULT => -21 | ||
| 755 | } | ||
| 756 | ], | ||
| 757 | yyrules => | ||
| 758 | [ | ||
| 759 | [#Rule 0 | ||
| 760 | '$start', 2, undef | ||
| 761 | ], | ||
| 762 | [#Rule 1 | ||
| 763 | 'specification', 1, undef | ||
| 764 | ], | ||
| 765 | [#Rule 2 | ||
| 766 | 'specification', 2, | ||
| 767 | sub | ||
| 768 | #line 14 "xdr.yp" | ||
| 769 | { [ @{ $_[1] }, $_[2] ] } | ||
| 770 | ], | ||
| 771 | [#Rule 3 | ||
| 772 | 'definitions', 1, | ||
| 773 | sub | ||
| 774 | #line 18 "xdr.yp" | ||
| 775 | { [ $_[1] ] } | ||
| 776 | ], | ||
| 777 | [#Rule 4 | ||
| 778 | 'definitions', 2, | ||
| 779 | sub | ||
| 780 | #line 19 "xdr.yp" | ||
| 781 | { unshift @{$_[2]}, $_[1]; $_[2] } | ||
| 782 | ], | ||
| 783 | [#Rule 5 | ||
| 784 | 'definition', 1, | ||
| 785 | sub | ||
| 786 | #line 23 "xdr.yp" | ||
| 787 | { +{ def => 'passthrough', value => $_[1] } } | ||
| 788 | ], | ||
| 789 | [#Rule 6 | ||
| 790 | 'definition', 1, | ||
| 791 | sub | ||
| 792 | #line 24 "xdr.yp" | ||
| 793 | { +{ def => 'preprocessor', value => $_[1] } } | ||
| 794 | ], | ||
| 795 | [#Rule 7 | ||
| 796 | 'definition', 1, undef | ||
| 797 | ], | ||
| 798 | [#Rule 8 | ||
| 799 | 'definition', 1, undef | ||
| 800 | ], | ||
| 801 | [#Rule 9 | ||
| 802 | 'typeDef', 3, | ||
| 803 | sub | ||
| 804 | #line 30 "xdr.yp" | ||
| 805 | { | ||
| 806 | +{ def => 'typedef', | ||
| 807 | name => delete $_[2]->{name}, | ||
| 808 | definition => $_[2], | ||
| 809 | comments => $_[1]->{comments}, | ||
| 810 | location => $_[1]->{location}, | ||
| 811 | trailing_comments => $_[3]->{comments} } } | ||
| 812 | ], | ||
| 813 | [#Rule 10 | ||
| 814 | 'typeDef', 4, | ||
| 815 | sub | ||
| 816 | #line 37 "xdr.yp" | ||
| 817 | { | ||
| 818 | +{ def => 'enum', | ||
| 819 | name => $_[2], | ||
| 820 | definition => { | ||
| 821 | type => { spec => 'enum', declaration => $_[3] } | ||
| 822 | }, | ||
| 823 | comments => $_[1]->{comments}, | ||
| 824 | location => $_[1]->{location}, | ||
| 825 | trailing_comments => $_[4]->{comments} } } | ||
| 826 | ], | ||
| 827 | [#Rule 11 | ||
| 828 | 'typeDef', 4, | ||
| 829 | sub | ||
| 830 | #line 46 "xdr.yp" | ||
| 831 | { | ||
| 832 | +{ def => 'struct', | ||
| 833 | name => $_[2], | ||
| 834 | definition => { | ||
| 835 | type => { spec => 'struct', declaration => $_[3] } | ||
| 836 | }, | ||
| 837 | comments => delete $_[1]->{comments}, | ||
| 838 | location => $_[1]->{location}, | ||
| 839 | trailing_comments => $_[4]->{comments} } } | ||
| 840 | ], | ||
| 841 | [#Rule 12 | ||
| 842 | 'typeDef', 4, | ||
| 843 | sub | ||
| 844 | #line 55 "xdr.yp" | ||
| 845 | { | ||
| 846 | +{ def => 'union', | ||
| 847 | name => $_[2], | ||
| 848 | definition => { | ||
| 849 | type => { spec => 'union', declaration => $_[3] } | ||
| 850 | }, | ||
| 851 | comments => $_[1]->{comments}, | ||
| 852 | location => $_[1]->{location}, | ||
| 853 | trailing_comments => $_[4]->{comments} } } | ||
| 854 | ], | ||
| 855 | [#Rule 13 | ||
| 856 | 'constantDef', 5, | ||
| 857 | sub | ||
| 858 | #line 67 "xdr.yp" | ||
| 859 | { | ||
| 860 | # What to do with comments before the '=' sign? | ||
| 861 | +{ def => 'const', | ||
| 862 | name => $_[2], | ||
| 863 | value => $_[4], | ||
| 864 | type => 'numeric', | ||
| 865 | comments => $_[1]->{comments}, | ||
| 866 | location => $_[1]->{location}, | ||
| 867 | trailing_comments => $_[5]->{comments} } } | ||
| 868 | ], | ||
| 869 | [#Rule 14 | ||
| 870 | 'constantDef', 5, | ||
| 871 | sub | ||
| 872 | #line 76 "xdr.yp" | ||
| 873 | { | ||
| 874 | # What to do with comments before the '=' sign? | ||
| 875 | +{ def => 'const', | ||
| 876 | name => $_[2], | ||
| 877 | value => $_[4], | ||
| 878 | type => 'symbolic', | ||
| 879 | comments => $_[1]->{comments}, | ||
| 880 | location => $_[1]->{location}, | ||
| 881 | trailing_comments => $_[5]->{comments} } } | ||
| 882 | ], | ||
| 883 | [#Rule 15 | ||
| 884 | 'switch', 7, | ||
| 885 | sub | ||
| 886 | #line 88 "xdr.yp" | ||
| 887 | { | ||
| 888 | +{ discriminator => { | ||
| 889 | name => delete $_[3]->{name}, | ||
| 890 | declaration => $_[3], | ||
| 891 | comments => $_[2]->{comments}, | ||
| 892 | trailing_comments => $_[4]->{comments} | ||
| 893 | }, | ||
| 894 | members => { | ||
| 895 | cases => $_[6]->{clauses}, | ||
| 896 | default => $_[6]->{default}, | ||
| 897 | comments => $_[5]->{comments}, | ||
| 898 | location => $_[5]->{location}, | ||
| 899 | trailing_comments => $_[7]->{comments} | ||
| 900 | }, | ||
| 901 | comments => $_[1]->{comments}, | ||
| 902 | location => $_[1]->{location}, | ||
| 903 | trailing_comments => $_[7]->{comments} } } | ||
| 904 | ], | ||
| 905 | [#Rule 16 | ||
| 906 | 'caseBody', 1, | ||
| 907 | sub | ||
| 908 | #line 108 "xdr.yp" | ||
| 909 | { +{ clauses => $_[1] } } | ||
| 910 | ], | ||
| 911 | [#Rule 17 | ||
| 912 | 'caseBody', 2, | ||
| 913 | sub | ||
| 914 | #line 109 "xdr.yp" | ||
| 915 | { +{ clauses => $_[1], default => $_[2] } } | ||
| 916 | ], | ||
| 917 | [#Rule 18 | ||
| 918 | 'caseClauses', 1, | ||
| 919 | sub | ||
| 920 | #line 113 "xdr.yp" | ||
| 921 | { [ $_[1] ] } | ||
| 922 | ], | ||
| 923 | [#Rule 19 | ||
| 924 | 'caseClauses', 2, | ||
| 925 | sub | ||
| 926 | #line 114 "xdr.yp" | ||
| 927 | { unshift @{ $_[2] }, $_[1]; $_[2] } | ||
| 928 | ], | ||
| 929 | [#Rule 20 | ||
| 930 | 'caseClause', 5, | ||
| 931 | sub | ||
| 932 | #line 118 "xdr.yp" | ||
| 933 | { | ||
| 934 | $_[2]->{trailing_comments} = $_[3]->{comments}; | ||
| 935 | +{ value => $_[2], | ||
| 936 | name => delete $_[4]->{name}, | ||
| 937 | declaration => $_[4], | ||
| 938 | comments => $_[1]->{comments}, | ||
| 939 | location => $_[1]->{location}, | ||
| 940 | trailing_comments => $_[5]->{comments} } } | ||
| 941 | ], | ||
| 942 | [#Rule 21 | ||
| 943 | 'defaultClause', 4, | ||
| 944 | sub | ||
| 945 | #line 129 "xdr.yp" | ||
| 946 | { | ||
| 947 | # What to do with comments on the ':'? | ||
| 948 | +{ name => delete $_[3]->{name}, | ||
| 949 | declaration => $_[3], | ||
| 950 | comments => $_[1]->{comments}, | ||
| 951 | location => $_[1]->{location}, | ||
| 952 | trailing_comments => $_[4]->{comments} } } | ||
| 953 | ], | ||
| 954 | [#Rule 22 | ||
| 955 | 'structBody', 3, | ||
| 956 | sub | ||
| 957 | #line 139 "xdr.yp" | ||
| 958 | { +{ members => $_[2], | ||
| 959 | comments => $_[1]->{comments}, | ||
| 960 | location => $_[1]->{location}, | ||
| 961 | trailing_comments => $_[3]->{comments} } } | ||
| 962 | ], | ||
| 963 | [#Rule 23 | ||
| 964 | 'structItems', 1, | ||
| 965 | sub | ||
| 966 | #line 146 "xdr.yp" | ||
| 967 | { [ $_[1] ] } | ||
| 968 | ], | ||
| 969 | [#Rule 24 | ||
| 970 | 'structItems', 2, | ||
| 971 | sub | ||
| 972 | #line 147 "xdr.yp" | ||
| 973 | { unshift @{ $_[2] }, $_[1]; $_[2] } | ||
| 974 | ], | ||
| 975 | [#Rule 25 | ||
| 976 | 'structItem', 2, | ||
| 977 | sub | ||
| 978 | #line 151 "xdr.yp" | ||
| 979 | { | ||
| 980 | +{ name => delete $_[1]->{name}, | ||
| 981 | declaration => $_[1], | ||
| 982 | trailing_comments => $_[2]->{comments} } } | ||
| 983 | ], | ||
| 984 | [#Rule 26 | ||
| 985 | 'enumBody', 3, | ||
| 986 | sub | ||
| 987 | #line 158 "xdr.yp" | ||
| 988 | { +{ elements => $_[2], | ||
| 989 | comments => $_[1]->{comments}, | ||
| 990 | location => $_[1]->{location}, | ||
| 991 | trailing_comments => $_[3]->{comments} } } | ||
| 992 | ], | ||
| 993 | [#Rule 27 | ||
| 994 | 'enumItems', 1, | ||
| 995 | sub | ||
| 996 | #line 165 "xdr.yp" | ||
| 997 | { [ $_[1] ] } | ||
| 998 | ], | ||
| 999 | [#Rule 28 | ||
| 1000 | 'enumItems', 3, | ||
| 1001 | sub | ||
| 1002 | #line 166 "xdr.yp" | ||
| 1003 | { $_[1]->{trailing_comments} = $_[2]->{comments}; | ||
| 1004 | unshift @{ $_[3] }, $_[1]; $_[3] } | ||
| 1005 | ], | ||
| 1006 | [#Rule 29 | ||
| 1007 | 'enumItem', 3, | ||
| 1008 | sub | ||
| 1009 | #line 171 "xdr.yp" | ||
| 1010 | { | ||
| 1011 | # What to do with comments on the '=' sign? | ||
| 1012 | $_[1]->{trailing_comments} = $_[2]->{comments}; | ||
| 1013 | +{ name => $_[1], | ||
| 1014 | value => $_[3], | ||
| 1015 | comments => delete $_[1]->{comments}, | ||
| 1016 | location => $_[1]->{location} } } | ||
| 1017 | ], | ||
| 1018 | [#Rule 30 | ||
| 1019 | 'typeSpecifier', 1, | ||
| 1020 | sub | ||
| 1021 | #line 181 "xdr.yp" | ||
| 1022 | { +{ spec => 'primitive', name => 'int', unsigned => 0, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1023 | ], | ||
| 1024 | [#Rule 31 | ||
| 1025 | 'typeSpecifier', 1, | ||
| 1026 | sub | ||
| 1027 | #line 182 "xdr.yp" | ||
| 1028 | { +{ spec => 'primitive', name => 'int', unsigned => 1, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1029 | ], | ||
| 1030 | [#Rule 32 | ||
| 1031 | 'typeSpecifier', 2, | ||
| 1032 | sub | ||
| 1033 | #line 183 "xdr.yp" | ||
| 1034 | { +{ spec => 'primitive', name => 'int', unsigned => 1, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1035 | ], | ||
| 1036 | [#Rule 33 | ||
| 1037 | 'typeSpecifier', 1, | ||
| 1038 | sub | ||
| 1039 | #line 184 "xdr.yp" | ||
| 1040 | { +{ spec => 'primitive', name => 'char', unsigned => 0, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1041 | ], | ||
| 1042 | [#Rule 34 | ||
| 1043 | 'typeSpecifier', 2, | ||
| 1044 | sub | ||
| 1045 | #line 185 "xdr.yp" | ||
| 1046 | { +{ spec => 'primitive', name => 'char', unsigned => 1, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1047 | ], | ||
| 1048 | [#Rule 35 | ||
| 1049 | 'typeSpecifier', 1, | ||
| 1050 | sub | ||
| 1051 | #line 186 "xdr.yp" | ||
| 1052 | { +{ spec => 'primitive', name => 'short', unsigned => 0, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1053 | ], | ||
| 1054 | [#Rule 36 | ||
| 1055 | 'typeSpecifier', 2, | ||
| 1056 | sub | ||
| 1057 | #line 187 "xdr.yp" | ||
| 1058 | { +{ spec => 'primitive', name => 'short', unsigned => 1, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1059 | ], | ||
| 1060 | [#Rule 37 | ||
| 1061 | 'typeSpecifier', 1, | ||
| 1062 | sub | ||
| 1063 | #line 188 "xdr.yp" | ||
| 1064 | { +{ spec => 'primitive', name => 'long', unsigned => 0, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1065 | ], | ||
| 1066 | [#Rule 38 | ||
| 1067 | 'typeSpecifier', 2, | ||
| 1068 | sub | ||
| 1069 | #line 189 "xdr.yp" | ||
| 1070 | { +{ spec => 'primitive', name => 'long', unsigned => 1, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1071 | ], | ||
| 1072 | [#Rule 39 | ||
| 1073 | 'typeSpecifier', 1, | ||
| 1074 | sub | ||
| 1075 | #line 190 "xdr.yp" | ||
| 1076 | { +{ spec => 'primitive', name => 'hyper', unsigned => 0, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1077 | ], | ||
| 1078 | [#Rule 40 | ||
| 1079 | 'typeSpecifier', 2, | ||
| 1080 | sub | ||
| 1081 | #line 191 "xdr.yp" | ||
| 1082 | { +{ spec => 'primitive', name => 'hyper', unsigned => 1, comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1083 | ], | ||
| 1084 | [#Rule 41 | ||
| 1085 | 'typeSpecifier', 1, | ||
| 1086 | sub | ||
| 1087 | #line 192 "xdr.yp" | ||
| 1088 | { +{ spec => 'primitive', name => 'float', comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1089 | ], | ||
| 1090 | [#Rule 42 | ||
| 1091 | 'typeSpecifier', 1, | ||
| 1092 | sub | ||
| 1093 | #line 193 "xdr.yp" | ||
| 1094 | { +{ spec => 'primitive', name => 'double', comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1095 | ], | ||
| 1096 | [#Rule 43 | ||
| 1097 | 'typeSpecifier', 1, | ||
| 1098 | sub | ||
| 1099 | #line 194 "xdr.yp" | ||
| 1100 | { +{ spec => 'primitive', name => 'quadruple', comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1101 | ], | ||
| 1102 | [#Rule 44 | ||
| 1103 | 'typeSpecifier', 1, | ||
| 1104 | sub | ||
| 1105 | #line 195 "xdr.yp" | ||
| 1106 | { +{ spec => 'primitive', name => 'bool', comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1107 | ], | ||
| 1108 | [#Rule 45 | ||
| 1109 | 'typeSpecifier', 2, | ||
| 1110 | sub | ||
| 1111 | #line 196 "xdr.yp" | ||
| 1112 | { +{ spec => 'enum', declaration => $_[2], comments => $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1113 | ], | ||
| 1114 | [#Rule 46 | ||
| 1115 | 'typeSpecifier', 2, | ||
| 1116 | sub | ||
| 1117 | #line 197 "xdr.yp" | ||
| 1118 | { +{ spec => 'struct', declaration => $_[2], comments => $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1119 | ], | ||
| 1120 | [#Rule 47 | ||
| 1121 | 'typeSpecifier', 2, | ||
| 1122 | sub | ||
| 1123 | #line 198 "xdr.yp" | ||
| 1124 | { +{ spec => 'union', declaration => $_[2], comments => $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1125 | ], | ||
| 1126 | [#Rule 48 | ||
| 1127 | 'typeSpecifier', 1, | ||
| 1128 | sub | ||
| 1129 | #line 199 "xdr.yp" | ||
| 1130 | { +{ spec => 'named', name => $_[1], comments => delete $_[1]->{comments}, location => $_[1]->{location} } } | ||
| 1131 | ], | ||
| 1132 | [#Rule 49 | ||
| 1133 | 'value', 1, undef | ||
| 1134 | ], | ||
| 1135 | [#Rule 50 | ||
| 1136 | 'value', 1, undef | ||
| 1137 | ], | ||
| 1138 | [#Rule 51 | ||
| 1139 | 'declaration', 2, | ||
| 1140 | sub | ||
| 1141 | #line 208 "xdr.yp" | ||
| 1142 | { | ||
| 1143 | +{ name => $_[2], | ||
| 1144 | type => $_[1], | ||
| 1145 | comments => delete $_[1]->{comments}, | ||
| 1146 | location => $_[1]->{location} } } | ||
| 1147 | ], | ||
| 1148 | [#Rule 52 | ||
| 1149 | 'declaration', 5, | ||
| 1150 | sub | ||
| 1151 | #line 213 "xdr.yp" | ||
| 1152 | { | ||
| 1153 | +{ name => $_[2], | ||
| 1154 | type => $_[1], | ||
| 1155 | array => 1, | ||
| 1156 | count => $_[4], | ||
| 1157 | variable => 0, | ||
| 1158 | comments => delete $_[1]->{comments}, | ||
| 1159 | location => $_[1]->{location} } } | ||
| 1160 | ], | ||
| 1161 | [#Rule 53 | ||
| 1162 | 'declaration', 4, | ||
| 1163 | sub | ||
| 1164 | #line 221 "xdr.yp" | ||
| 1165 | { | ||
| 1166 | +{ name => $_[2], | ||
| 1167 | type => $_[1], | ||
| 1168 | array => 1, | ||
| 1169 | max => undef, | ||
| 1170 | variable => 1, | ||
| 1171 | comments => delete $_[1]->{comments}, | ||
| 1172 | location => $_[1]->{location} } } | ||
| 1173 | ], | ||
| 1174 | [#Rule 54 | ||
| 1175 | 'declaration', 5, | ||
| 1176 | sub | ||
| 1177 | #line 229 "xdr.yp" | ||
| 1178 | { | ||
| 1179 | +{ name => $_[2], | ||
| 1180 | type => $_[1], | ||
| 1181 | array => 1, | ||
| 1182 | max => $_[4], | ||
| 1183 | variable => 1, | ||
| 1184 | comments => delete $_[1]->{comments}, | ||
| 1185 | location => $_[1]->{location} } } | ||
| 1186 | ], | ||
| 1187 | [#Rule 55 | ||
| 1188 | 'declaration', 5, | ||
| 1189 | sub | ||
| 1190 | #line 237 "xdr.yp" | ||
| 1191 | { | ||
| 1192 | +{ name => $_[2], | ||
| 1193 | type => { spec => 'primitive', name => $_[1] }, | ||
| 1194 | count => $_[4], | ||
| 1195 | variable => 0, | ||
| 1196 | comments => delete $_[1]->{comments}, | ||
| 1197 | location => $_[1]->{location} } } | ||
| 1198 | ], | ||
| 1199 | [#Rule 56 | ||
| 1200 | 'declaration', 4, | ||
| 1201 | sub | ||
| 1202 | #line 244 "xdr.yp" | ||
| 1203 | { | ||
| 1204 | +{ name => $_[2], | ||
| 1205 | type => { spec => 'primitive', name => $_[1] }, | ||
| 1206 | max => undef, | ||
| 1207 | variable => 1, | ||
| 1208 | comments => delete $_[1]->{comments}, | ||
| 1209 | location => $_[1]->{location} } } | ||
| 1210 | ], | ||
| 1211 | [#Rule 57 | ||
| 1212 | 'declaration', 5, | ||
| 1213 | sub | ||
| 1214 | #line 251 "xdr.yp" | ||
| 1215 | { | ||
| 1216 | +{ name => $_[2], | ||
| 1217 | type => { spec => 'primitive', name => $_[1] }, | ||
| 1218 | max => $_[4], | ||
| 1219 | variable => 1, | ||
| 1220 | comments => delete $_[1]->{comments}, | ||
| 1221 | location => $_[1]->{location} } } | ||
| 1222 | ], | ||
| 1223 | [#Rule 58 | ||
| 1224 | 'declaration', 4, | ||
| 1225 | sub | ||
| 1226 | #line 258 "xdr.yp" | ||
| 1227 | { | ||
| 1228 | +{ name => $_[2], | ||
| 1229 | type => { spec => 'primitive', name => $_[1] }, | ||
| 1230 | max => undef, | ||
| 1231 | variable => 1, | ||
| 1232 | comments => delete $_[1]->{comments}, | ||
| 1233 | location => $_[1]->{location} } } | ||
| 1234 | ], | ||
| 1235 | [#Rule 59 | ||
| 1236 | 'declaration', 5, | ||
| 1237 | sub | ||
| 1238 | #line 265 "xdr.yp" | ||
| 1239 | { | ||
| 1240 | +{ name => $_[2], | ||
| 1241 | type => { spec => 'primitive', name => $_[1] }, | ||
| 1242 | max => $_[4], | ||
| 1243 | variable => 1, | ||
| 1244 | comments => delete $_[1]->{comments}, | ||
| 1245 | location => $_[1]->{location} } } | ||
| 1246 | ], | ||
| 1247 | [#Rule 60 | ||
| 1248 | 'declaration', 3, | ||
| 1249 | sub | ||
| 1250 | #line 272 "xdr.yp" | ||
| 1251 | { | ||
| 1252 | +{ name => $_[3], | ||
| 1253 | type => $_[1], | ||
| 1254 | pointer => 1, | ||
| 1255 | comments => delete $_[1]->{comments}, | ||
| 1256 | location => $_[1]->{location} } } | ||
| 1257 | ], | ||
| 1258 | [#Rule 61 | ||
| 1259 | 'declaration', 1, | ||
| 1260 | sub | ||
| 1261 | #line 278 "xdr.yp" | ||
| 1262 | { | ||
| 1263 | +{ type => { spec => 'primitive', name => $_[1] }, | ||
| 1264 | comments => delete $_[1]->{comments}, | ||
| 1265 | location => $_[1]->{location} } } | ||
| 1266 | ] | ||
| 1267 | ], | ||
| 1268 | @_); | ||
| 1269 | bless($self,$class); | ||
| 1270 | } | ||
| 1271 | |||
| 1272 | #line 285 "xdr.yp" | ||
| 1273 | |||
| 1274 | |||
| 1275 | |||
| 1276 | sub _Lexer { | ||
| 1277 | my ($fh, $parser) = @_; | ||
| 1278 | my $yydata = $parser->YYData; | ||
| 1279 | my @comments; | ||
| 1280 | my $comment; | ||
| 1281 | my $comment_start; | ||
| 1282 | |||
| 1283 | $yydata->{LINENO} //= 0; | ||
| 1284 | while (1) { | ||
| 1285 | unless ($yydata->{INPUT}) { | ||
| 1286 | $yydata->{INPUT} = <$fh>; | ||
| 1287 | $yydata->{LINENO}++; | ||
| 1288 | $yydata->{COLNO} = 1; | ||
| 1289 | |||
| 1290 | if (@comments and not $yydata->{INPUT}) { | ||
| 1291 | return ('TRAILING_COMMENT', { | ||
| 1292 | content => '', | ||
| 1293 | comments => \@comments, | ||
| 1294 | location => $comment_start | ||
| 1295 | }); | ||
| 1296 | } | ||
| 1297 | |||
| 1298 | return ('', undef) unless $yydata->{INPUT}; | ||
| 1299 | |||
| 1300 | if ($yydata->{INPUT} =~ s/^(%.*)//) { | ||
| 1301 | return ('PASSTHROUGH', { | ||
| 1302 | content => $1, | ||
| 1303 | comments => \@comments, | ||
| 1304 | location => [ $yydata->{LINENO}, 1 ] | ||
| 1305 | }); | ||
| 1306 | } | ||
| 1307 | if ($yydata->{INPUT} =~ s/^(#.*)//) { | ||
| 1308 | return ('PREPROC', { | ||
| 1309 | content => $1, | ||
| 1310 | comments => \@comments, | ||
| 1311 | location => [ $yydata->{LINENO}, 1 ] | ||
| 1312 | }); | ||
| 1313 | } | ||
| 1314 | } | ||
| 1315 | |||
| 1316 | $yydata->{INPUT} =~ s/^\s+//; | ||
| 1317 | $yydata->{COLNO} += length($&); | ||
| 1318 | next unless $yydata->{INPUT}; | ||
| 1319 | |||
| 1320 | my $token_start = [ $yydata->{LINENO}, $yydata->{COLNO} ]; | ||
| 1321 | if ($yydata->{INPUT} =~ s|^/\*||) { # strip comments | ||
| 1322 | $yydata->{COLNO} += length($&); | ||
| 1323 | $comment = ''; | ||
| 1324 | while (1) { | ||
| 1325 | if ($yydata->{INPUT} =~ s|(.*?)\*/||) { | ||
| 1326 | $yydata->{COLNO} += length($&); | ||
| 1327 | push @comments, { content => $comment . $1, location => $token_start }; | ||
| 1328 | last; | ||
| 1329 | } | ||
| 1330 | $comment .= $yydata->{INPUT}; | ||
| 1331 | $yydata->{INPUT} = <$fh>; | ||
| 1332 | $yydata->{LINENO}++; | ||
| 1333 | $yydata->{COLNO} = 1; | ||
| 1334 | die "Unclosed comment" unless $yydata->{INPUT}; | ||
| 1335 | } | ||
| 1336 | } | ||
| 1337 | elsif ($yydata->{INPUT} =~ s/^(const|typedef|enum|union|struct|switch|case|default|unsigned|int|char|short|long|hyper|float|string|double|quadruple|bool|opaque|void)\b(?!_)//) { | ||
| 1338 | $yydata->{COLNO} += length($&); | ||
| 1339 | return ($1, { | ||
| 1340 | content => $1, | ||
| 1341 | comments => \@comments, | ||
| 1342 | location => $token_start | ||
| 1343 | }); | ||
| 1344 | } | ||
| 1345 | elsif ($yydata->{INPUT} =~ s/^([a-z][a-z0-9_]*)//i) { | ||
| 1346 | $yydata->{COLNO} += length($&); | ||
| 1347 | return ('IDENT', { | ||
| 1348 | content => $1, | ||
| 1349 | comments => \@comments, | ||
| 1350 | location => $token_start | ||
| 1351 | }); | ||
| 1352 | } | ||
| 1353 | elsif ($yydata->{INPUT} =~ s/^(-?\d+|0x[0-9a-f]+)(?=\b|$)//i) { | ||
| 1354 | $yydata->{COLNO} += length($&); | ||
| 1355 | return ('CONST', { | ||
| 1356 | content => $1, | ||
| 1357 | comments => \@comments, | ||
| 1358 | location => $token_start | ||
| 1359 | }); | ||
| 1360 | } | ||
| 1361 | elsif ($yydata->{INPUT} =~ s/^(.)//) { | ||
| 1362 | $yydata->{COLNO} += length($&); | ||
| 1363 | return ($1, { | ||
| 1364 | content => $1, | ||
| 1365 | comments => \@comments, | ||
| 1366 | location => $token_start | ||
| 1367 | }); | ||
| 1368 | } | ||
| 1369 | else { | ||
| 1370 | die "Remaining input: '$yydata->{INPUT}'"; | ||
| 1371 | } | ||
| 1372 | } | ||
| 1373 | } | ||
| 1374 | |||
| 1375 | sub _Error { | ||
| 1376 | my $tok = $_[0]->YYCurtok; | ||
| 1377 | my $val = $_[0]->YYCurval; | ||
| 1378 | my $line = $tok ? "line: $val->{location}->[0]" : 'at <EOF>'; | ||
| 1379 | |||
| 1380 | print STDERR "Parse error at '$val->{content}' (line: $line)\n"; | ||
| 1381 | } | ||
| 1382 | |||
| 1383 | sub parse { | ||
| 1384 | my ($self, $fh) = @_; | ||
| 1385 | |||
| 1386 | $self->YYParse( yylex => sub { _Lexer( $fh, @_ ); }, | ||
| 1387 | yyerror => \&_Error ); | ||
| 1388 | } | ||
| 1389 | |||
| 1390 | =head1 NAME | ||
| 1391 | |||
| 1392 | XDR::Parse - Creation of an AST of an XDR specification (RFC4506) | ||
| 1393 | |||
| 1394 | =head1 SYNOPSIS | ||
| 1395 | |||
| 1396 | use XDR::Parse; | ||
| 1397 | use Data::Dumper; | ||
| 1398 | |||
| 1399 | my $p = XDR::Parse->new; | ||
| 1400 | print Dumper( $p->parse( \*STDIN ) ); | ||
| 1401 | |||
| 1402 | =head1 VERSION | ||
| 1403 | |||
| 1404 | 1.0.1 | ||
| 1405 | |||
| 1406 | =head1 DESCRIPTION | ||
| 1407 | |||
| 1408 | This module contains a parser for the XDR (eXternal Data Representation) | ||
| 1409 | language as defined in RFC4506. The result is an abstract syntax tree | ||
| 1410 | (AST) which can be used for further processing. | ||
| 1411 | |||
| 1412 | This module extends the supported integer types with C<char>, C<short> and | ||
| 1413 | C<long>, all of which seem to be supported by C<rpcgen>, the tool consuming | ||
| 1414 | XDR to generate remote applications. | ||
| 1415 | |||
| 1416 | =head2 AST | ||
| 1417 | |||
| 1418 | At the top level, the AST is an array of nodes which can be one of the | ||
| 1419 | following, distinguished by the C<def> key in the node's hash: | ||
| 1420 | |||
| 1421 | =over 8 | ||
| 1422 | |||
| 1423 | =item * a 'pass through' instruction (C<passthrough>) | ||
| 1424 | |||
| 1425 | This type of nodes contains a line which starts with '%'; the instruction | ||
| 1426 | to C<rpcgen> to copy that line to output verbatim | ||
| 1427 | |||
| 1428 | =item * a preprocessor instruction (C<preprocessor>) | ||
| 1429 | |||
| 1430 | This type of nodes contains a line which starts with '#'; C<rpcgen> typically | ||
| 1431 | invokes C<cpp> to preprocess its input -- this module simply takes input and | ||
| 1432 | parses that; input which hasn't been preprocessed may contain this type of node | ||
| 1433 | |||
| 1434 | =item * constant declarations (C<const>) | ||
| 1435 | |||
| 1436 | =item * type declarations | ||
| 1437 | |||
| 1438 | Type definitions come in four subtypes C<enum>, C<subst>, C<typedef> | ||
| 1439 | and C<union> | ||
| 1440 | |||
| 1441 | =item * trailing comment | ||
| 1442 | |||
| 1443 | Comments in the input are linked to the first syntax node following the comment; | ||
| 1444 | files having comments between the last syntax and the end of the file, will | ||
| 1445 | contain a special C<trailing comment> node, which doesn't model syntax, but is | ||
| 1446 | required to prevent loosing the last comments in the file. | ||
| 1447 | |||
| 1448 | =back | ||
| 1449 | |||
| 1450 | Each node in the tree -not just the toplevel - is a hash which may have any or | ||
| 1451 | all of the following keys: | ||
| 1452 | |||
| 1453 | =over 8 | ||
| 1454 | |||
| 1455 | =item * comments | ||
| 1456 | |||
| 1457 | Is an array containing all comments following the previous syntax node and | ||
| 1458 | preceeding the one to which the comment(s) are attached | ||
| 1459 | |||
| 1460 | =item * location | ||
| 1461 | |||
| 1462 | Is an array of two elements: the line and column number of the beginning of the | ||
| 1463 | syntax captured by that node | ||
| 1464 | |||
| 1465 | =item * trailing_comments | ||
| 1466 | |||
| 1467 | Trailing comments happen when a node encloses a scope with a termination which | ||
| 1468 | itself is not included in the AST representation. E.g. the closing ';' in a | ||
| 1469 | C<typedef>: | ||
| 1470 | |||
| 1471 | typedef string our_string<> /* trailing comment */ ; | ||
| 1472 | |||
| 1473 | =back | ||
| 1474 | |||
| 1475 | =head3 Constant declarations | ||
| 1476 | |||
| 1477 | Constant declarations exist in two types, distinguished by the C<type> key in | ||
| 1478 | the node's hash: | ||
| 1479 | |||
| 1480 | =over 8 | ||
| 1481 | |||
| 1482 | =item * C<numeric> | ||
| 1483 | |||
| 1484 | const my_const = 0x123; # hexadecimal | ||
| 1485 | const my_other_const = 123; # decimal | ||
| 1486 | const my_third_const = 012; # octal | ||
| 1487 | |||
| 1488 | =item * C<symbolic> | ||
| 1489 | |||
| 1490 | const the_const = my_other_const; | ||
| 1491 | |||
| 1492 | =back | ||
| 1493 | |||
| 1494 | =head3 Type declarations | ||
| 1495 | |||
| 1496 | Top level nodes with a C<def> key valued C<typedef>, C<enum>, C<struct> or | ||
| 1497 | C<union> define types of the named language construct. These nodes share the | ||
| 1498 | following keys, in addition to the keys shared by all nodes: | ||
| 1499 | |||
| 1500 | =over 8 | ||
| 1501 | |||
| 1502 | =item * name | ||
| 1503 | |||
| 1504 | Name of the type being defined. | ||
| 1505 | |||
| 1506 | =item * definition | ||
| 1507 | |||
| 1508 | The node making up the definition of the type, holding a C<type> node with | ||
| 1509 | two keys, C<spec> and C<declaration>. The value of the C<spec> key is one of | ||
| 1510 | C<enum>, C<struct> or C<union>. The elements are specified by the content of | ||
| 1511 | the C<declaration> key. | ||
| 1512 | |||
| 1513 | =back | ||
| 1514 | |||
| 1515 | =head4 'typedef' declarations | ||
| 1516 | |||
| 1517 | This node is a 'declaration' node as documented in the section | ||
| 1518 | 'declaration' nodes below. | ||
| 1519 | |||
| 1520 | =head4 'enum' declarations | ||
| 1521 | |||
| 1522 | The C<declaration> node of C<enum> definitions has a single key (C<elements>): | ||
| 1523 | an array of nodes with C<name> and C<value> keys, one for each value defined | ||
| 1524 | in the enum type. | ||
| 1525 | |||
| 1526 | =head4 'struct' declarations | ||
| 1527 | |||
| 1528 | Th C<declaration> node of C<struct> definitions has a single key (C<members>): | ||
| 1529 | an array of nodes with C<name> and C<declaration> keys describing the members | ||
| 1530 | of the struct type. For more details on the C<type> node, see below. | ||
| 1531 | |||
| 1532 | =head4 'union' declarations | ||
| 1533 | |||
| 1534 | The C<declaration> node of C<union> definitions has a single key (C<switch>): | ||
| 1535 | itself a node which contains a C<members> and a C<discriminator> key. The | ||
| 1536 | discriminator node has a C<name> and a C<type> key; the C<members> node | ||
| 1537 | contains one or two keys: C<cases> and optionally C<default>. C<cases> is an | ||
| 1538 | array of nodes defining the members of the union; each element consists of | ||
| 1539 | three keys: C<value>, C<name> and <declaration>. C<value> is the value | ||
| 1540 | associated with the discriminator, to indicate the current definition. | ||
| 1541 | C<name> is the name of the member. C<declaration> contains the type declaration | ||
| 1542 | for the member. | ||
| 1543 | |||
| 1544 | =head4 'declaration' nodes | ||
| 1545 | |||
| 1546 | These nodes contain a C<type> key specifying the basic type of the declaration | ||
| 1547 | as documented below under L</'type' nodes in declarations>, | ||
| 1548 | with a number of modifiers: | ||
| 1549 | |||
| 1550 | =over 8 | ||
| 1551 | |||
| 1552 | =item * pointer | ||
| 1553 | |||
| 1554 | Optional. Mutually exclusive with the C<array> indicator. | ||
| 1555 | |||
| 1556 | =item * array | ||
| 1557 | |||
| 1558 | Optional. Mutually exclusive with the C<pointer> indicator. | ||
| 1559 | |||
| 1560 | When the C<array> boolean is true, the following additional keys may exist: | ||
| 1561 | |||
| 1562 | =over 8 | ||
| 1563 | |||
| 1564 | =item * variable | ||
| 1565 | |||
| 1566 | Indicates whether the array is of variable length. | ||
| 1567 | |||
| 1568 | =item * max | ||
| 1569 | |||
| 1570 | Indicates the maximum number of items in the array. May be C<undef>, if no | ||
| 1571 | maximum was specified. | ||
| 1572 | |||
| 1573 | Note: this value may be specified using symbolic constant. | ||
| 1574 | |||
| 1575 | =item * count | ||
| 1576 | |||
| 1577 | Indicates the exact number of items in the array, when C<variable> is false | ||
| 1578 | or absent. | ||
| 1579 | |||
| 1580 | Note: this value may be specified using symbolic constant. | ||
| 1581 | |||
| 1582 | =back | ||
| 1583 | |||
| 1584 | =back | ||
| 1585 | |||
| 1586 | =head4 'type' nodes in declarations | ||
| 1587 | |||
| 1588 | These nodes either define an inline C<enum>, C<struct> or C<union>, or refer to any | ||
| 1589 | of the types defined in the standard or at the toplevel, as indiceted by the C<spec> | ||
| 1590 | key using these values: | ||
| 1591 | |||
| 1592 | =over 8 | ||
| 1593 | |||
| 1594 | =item * primitive | ||
| 1595 | |||
| 1596 | The value in the C<name> key refers to a built-in type. When the named type is one | ||
| 1597 | of the integer type (C<char>, C<short>, C<int>, C<long> or C<hyper>), the type hash | ||
| 1598 | contains the additional key C<unsigned>. | ||
| 1599 | |||
| 1600 | The primitive types C<string> and C<opaque> support the same additional keys as | ||
| 1601 | arrays (C<count>, C<max> and C<variable>). These apply to the data within them | ||
| 1602 | and do not mean to define arrays of strings/"opaques". | ||
| 1603 | |||
| 1604 | =item * named | ||
| 1605 | |||
| 1606 | The value in the C<name> key refers to a defined type. | ||
| 1607 | |||
| 1608 | =item * enum | ||
| 1609 | |||
| 1610 | Defines an inline enum through the type's C<declaration> key. | ||
| 1611 | |||
| 1612 | =item * struct | ||
| 1613 | |||
| 1614 | Defines an inline struct through the type's C<declaration> key. | ||
| 1615 | |||
| 1616 | =item * union | ||
| 1617 | |||
| 1618 | Defines an inline union through the type's C<declaration> key. | ||
| 1619 | |||
| 1620 | =back | ||
| 1621 | |||
| 1622 | The node in the C<declaration> key of the inline C<enum>, C<struct> and C<union> | ||
| 1623 | members follow the same pattern as documented in the respective sections on | ||
| 1624 | declarations above. | ||
| 1625 | |||
| 1626 | =head1 METHODS | ||
| 1627 | |||
| 1628 | =head2 new | ||
| 1629 | |||
| 1630 | my $parser = XDR::Parse->new; | ||
| 1631 | |||
| 1632 | =head2 parse | ||
| 1633 | |||
| 1634 | my $ast = $parser->parse( \*STDIN ); | ||
| 1635 | |||
| 1636 | =head2 YYParse (inherited) | ||
| 1637 | |||
| 1638 | =head1 LICENSE | ||
| 1639 | |||
| 1640 | This distribution may be used under the same terms as Perl itself. | ||
| 1641 | |||
| 1642 | =head1 AUTHOR | ||
| 1643 | |||
| 1644 | =over 8 | ||
| 1645 | |||
| 1646 | =item * Erik Huelsmann | ||
| 1647 | |||
| 1648 | =back | ||
| 1649 | |||
| 1650 | =head1 SEE ALSO | ||
| 1651 | |||
| 1652 | L<XDR>, L<perlrpcgen> | ||
| 1653 | |||
| 1654 | =cut | ||
| 1655 | 1; | ||