1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 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 154 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 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 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 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 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 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 690 691 692 693 694 695 696 697 698 699 700 701 702 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 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 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 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 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 1157 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 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
|
'\"
'\" Generated from file 'pt_rdengine\&.man' by tcllib/doctools with format 'nroff'
'\" Copyright (c) 2009 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
'\"
.TH "pt::rde" n 1\&.2 tcllib "Parser Tools"
.\" The -*- nroff -*- definitions below are for supplemental macros used
.\" in Tcl/Tk manual entries.
.\"
.\" .AP type name in/out ?indent?
.\" Start paragraph describing an argument to a library procedure.
.\" type is type of argument (int, etc.), in/out is either "in", "out",
.\" or "in/out" to describe whether procedure reads or modifies arg,
.\" and indent is equivalent to second arg of .IP (shouldn't ever be
.\" needed; use .AS below instead)
.\"
.\" .AS ?type? ?name?
.\" Give maximum sizes of arguments for setting tab stops. Type and
.\" name are examples of largest possible arguments that will be passed
.\" to .AP later. If args are omitted, default tab stops are used.
.\"
.\" .BS
.\" Start box enclosure. From here until next .BE, everything will be
.\" enclosed in one large box.
.\"
.\" .BE
.\" End of box enclosure.
.\"
.\" .CS
.\" Begin code excerpt.
.\"
.\" .CE
.\" End code excerpt.
.\"
.\" .VS ?version? ?br?
.\" Begin vertical sidebar, for use in marking newly-changed parts
.\" of man pages. The first argument is ignored and used for recording
.\" the version when the .VS was added, so that the sidebars can be
.\" found and removed when they reach a certain age. If another argument
.\" is present, then a line break is forced before starting the sidebar.
.\"
.\" .VE
.\" End of vertical sidebar.
.\"
.\" .DS
.\" Begin an indented unfilled display.
.\"
.\" .DE
.\" End of indented unfilled display.
.\"
.\" .SO ?manpage?
.\" Start of list of standard options for a Tk widget. The manpage
.\" argument defines where to look up the standard options; if
.\" omitted, defaults to "options". The options follow on successive
.\" lines, in three columns separated by tabs.
.\"
.\" .SE
.\" End of list of standard options for a Tk widget.
.\"
.\" .OP cmdName dbName dbClass
.\" Start of description of a specific option. cmdName gives the
.\" option's name as specified in the class command, dbName gives
.\" the option's name in the option database, and dbClass gives
.\" the option's class in the option database.
.\"
.\" .UL arg1 arg2
.\" Print arg1 underlined, then print arg2 normally.
.\"
.\" .QW arg1 ?arg2?
.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation).
.\"
.\" .PQ arg1 ?arg2?
.\" Print an open parenthesis, arg1 in quotes, then arg2 normally
.\" (for trailing punctuation) and then a closing parenthesis.
.\"
.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.if t .wh -1.3i ^B
.nr ^l \n(.l
.ad b
.\" # Start an argument description
.de AP
.ie !"\\$4"" .TP \\$4
.el \{\
. ie !"\\$2"" .TP \\n()Cu
. el .TP 15
.\}
.ta \\n()Au \\n()Bu
.ie !"\\$3"" \{\
\&\\$1 \\fI\\$2\\fP (\\$3)
.\".b
.\}
.el \{\
.br
.ie !"\\$2"" \{\
\&\\$1 \\fI\\$2\\fP
.\}
.el \{\
\&\\fI\\$1\\fP
.\}
.\}
..
.\" # define tabbing values for .AP
.de AS
.nr )A 10n
.if !"\\$1"" .nr )A \\w'\\$1'u+3n
.nr )B \\n()Au+15n
.\"
.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
.nr )C \\n()Bu+\\w'(in/out)'u+2n
..
.AS Tcl_Interp Tcl_CreateInterp in/out
.\" # BS - start boxed text
.\" # ^y = starting y location
.\" # ^b = 1
.de BS
.br
.mk ^y
.nr ^b 1u
.if n .nf
.if n .ti 0
.if n \l'\\n(.lu\(ul'
.if n .fi
..
.\" # BE - end boxed text (draw box now)
.de BE
.nf
.ti 0
.mk ^t
.ie n \l'\\n(^lu\(ul'
.el \{\
.\" Draw four-sided box normally, but don't draw top of
.\" box if the box started on an earlier page.
.ie !\\n(^b-1 \{\
\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.el \}\
\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.\}
.fi
.br
.nr ^b 0
..
.\" # VS - start vertical sidebar
.\" # ^Y = starting y location
.\" # ^v = 1 (for troff; for nroff this doesn't matter)
.de VS
.if !"\\$2"" .br
.mk ^Y
.ie n 'mc \s12\(br\s0
.el .nr ^v 1u
..
.\" # VE - end of vertical sidebar
.de VE
.ie n 'mc
.el \{\
.ev 2
.nf
.ti 0
.mk ^t
\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
.sp -1
.fi
.ev
.\}
.nr ^v 0
..
.\" # Special macro to handle page bottom: finish off current
.\" # box/sidebar if in box/sidebar mode, then invoked standard
.\" # page bottom macro.
.de ^B
.ev 2
'ti 0
'nf
.mk ^t
.if \\n(^b \{\
.\" Draw three-sided box if this is the box's first page,
.\" draw two sides but no top otherwise.
.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.\}
.if \\n(^v \{\
.nr ^x \\n(^tu+1v-\\n(^Yu
\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
.\}
.bp
'fi
.ev
.if \\n(^b \{\
.mk ^y
.nr ^b 2
.\}
.if \\n(^v \{\
.mk ^Y
.\}
..
.\" # DS - begin display
.de DS
.RS
.nf
.sp
..
.\" # DE - end display
.de DE
.fi
.RE
.sp
..
.\" # SO - start of list of standard options
.de SO
'ie '\\$1'' .ds So \\fBoptions\\fR
'el .ds So \\fB\\$1\\fR
.SH "STANDARD OPTIONS"
.LP
.nf
.ta 5.5c 11c
.ft B
..
.\" # SE - end of list of standard options
.de SE
.fi
.ft R
.LP
See the \\*(So manual entry for details on the standard options.
..
.\" # OP - start of full description for a single option
.de OP
.LP
.nf
.ta 4c
Command-Line Name: \\fB\\$1\\fR
Database Name: \\fB\\$2\\fR
Database Class: \\fB\\$3\\fR
.fi
.IP
..
.\" # CS - begin code excerpt
.de CS
.RS
.nf
.ta .25i .5i .75i 1i
..
.\" # CE - end code excerpt
.de CE
.fi
.RE
..
.\" # UL - underline word
.de UL
\\$1\l'|0\(ul'\\$2
..
.\" # QW - apply quotation marks to word
.de QW
.ie '\\*(lq'"' ``\\$1''\\$2
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\$2
..
.\" # PQ - apply parens and quotation marks to word
.de PQ
.ie '\\*(lq'"' (``\\$1''\\$2)\\$3
.\"" fix emacs highlighting
.el (\\*(lq\\$1\\*(rq\\$2)\\$3
..
.\" # QR - quoted range
.de QR
.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
..
.\" # MT - "empty" string
.de MT
.QW ""
..
.BS
.SH NAME
pt::rde \- Parsing Runtime Support, PARAM based
.SH SYNOPSIS
package require \fBTcl 8\&.5 9\fR
.sp
package require \fBpt::rde ?1\&.2?\fR
.sp
package require \fBsnit\fR
.sp
package require \fBstruct::stack 1\&.6\fR
.sp
package require \fBpt::ast 1\&.2\fR
.sp
\fB::pt::rde\fR \fIobjectName\fR
.sp
\fIobjectName\fR \fBdestroy\fR
.sp
\fIobjectName\fR \fBreset\fR \fIchan\fR
.sp
\fIobjectName\fR \fBcomplete\fR
.sp
\fIobjectName\fR \fBchan\fR
.sp
\fIobjectName\fR \fBline\fR
.sp
\fIobjectName\fR \fBcolumn\fR
.sp
\fIobjectName\fR \fBcurrent\fR
.sp
\fIobjectName\fR \fBlocation\fR
.sp
\fIobjectName\fR \fBlocations\fR
.sp
\fIobjectName\fR \fBok\fR
.sp
\fIobjectName\fR \fBvalue\fR
.sp
\fIobjectName\fR \fBerror\fR
.sp
\fIobjectName\fR \fBerrors\fR
.sp
\fIobjectName\fR \fBtokens\fR ?\fIfrom\fR ?\fIto\fR??
.sp
\fIobjectName\fR \fBsymbols\fR
.sp
\fIobjectName\fR \fBknown\fR
.sp
\fIobjectName\fR \fBreducible\fR
.sp
\fIobjectName\fR \fBasts\fR
.sp
\fIobjectName\fR \fBast\fR
.sp
\fIobjectName\fR \fBposition\fR \fIloc\fR
.sp
\fIobjectName\fR \fBi_input_next\fR \fImsg\fR
.sp
\fIobjectName\fR \fBi_test_alnum\fR
.sp
\fIobjectName\fR \fBi_test_alpha\fR
.sp
\fIobjectName\fR \fBi_test_ascii\fR
.sp
\fIobjectName\fR \fBi_test_char\fR \fIchar\fR
.sp
\fIobjectName\fR \fBi_test_ddigit\fR
.sp
\fIobjectName\fR \fBi_test_digit\fR
.sp
\fIobjectName\fR \fBi_test_graph\fR
.sp
\fIobjectName\fR \fBi_test_lower\fR
.sp
\fIobjectName\fR \fBi_test_print\fR
.sp
\fIobjectName\fR \fBi_test_punct\fR
.sp
\fIobjectName\fR \fBi_test_range\fR \fIchars\fR \fIchare\fR
.sp
\fIobjectName\fR \fBi_test_space\fR
.sp
\fIobjectName\fR \fBi_test_upper\fR
.sp
\fIobjectName\fR \fBi_test_wordchar\fR
.sp
\fIobjectName\fR \fBi_test_xdigit\fR
.sp
\fIobjectName\fR \fBi_error_clear\fR
.sp
\fIobjectName\fR \fBi_error_push\fR
.sp
\fIobjectName\fR \fBi_error_pop_merge\fR
.sp
\fIobjectName\fR \fBi_error_nonterminal\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBi_status_ok\fR
.sp
\fIobjectName\fR \fBi_status_fail\fR
.sp
\fIobjectName\fR \fBi_status_negate\fR
.sp
\fIobjectName\fR \fBi_loc_push\fR
.sp
\fIobjectName\fR \fBi_loc_pop_discard\fR
.sp
\fIobjectName\fR \fBi_loc_pop_rewind\fR
.sp
\fIobjectName\fR \fBi:ok_loc_pop_rewind\fR
.sp
\fIobjectName\fR \fBi_loc_pop_rewind/discard\fR
.sp
\fIobjectName\fR \fBi_symbol_restore\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBi_symbol_save\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBi_value_clear\fR
.sp
\fIobjectName\fR \fBi_value_clear/leaf\fR
.sp
\fIobjectName\fR \fBi_value_clear/reduce\fR
.sp
\fIobjectName\fR \fBi:ok_ast_value_push\fR
.sp
\fIobjectName\fR \fBi_ast_push\fR
.sp
\fIobjectName\fR \fBi_ast_pop_rewind\fR
.sp
\fIobjectName\fR \fBi:fail_ast_pop_rewind\fR
.sp
\fIobjectName\fR \fBi_ast_pop_rewind/discard\fR
.sp
\fIobjectName\fR \fBi_ast_pop_discard\fR
.sp
\fIobjectName\fR \fBi_ast_pop_discard/rewind\fR
.sp
\fIobjectName\fR \fBi:ok_continue\fR
.sp
\fIobjectName\fR \fBi:fail_continue\fR
.sp
\fIobjectName\fR \fBi:fail_return\fR
.sp
\fIobjectName\fR \fBi:ok_return\fR
.sp
\fIobjectName\fR \fBsi:void_state_push\fR
.sp
\fIobjectName\fR \fBsi:void2_state_push\fR
.sp
\fIobjectName\fR \fBsi:value_state_push\fR
.sp
\fIobjectName\fR \fBsi:void_state_merge\fR
.sp
\fIobjectName\fR \fBsi:void_state_merge_ok\fR
.sp
\fIobjectName\fR \fBsi:value_state_merge\fR
.sp
\fIobjectName\fR \fBsi:value_notahead_start\fR
.sp
\fIobjectName\fR \fBsi:void_notahead_exit\fR
.sp
\fIobjectName\fR \fBsi:value_notahead_exit\fR
.sp
\fIobjectName\fR \fBsi:kleene_abort\fR
.sp
\fIobjectName\fR \fBsi:kleene_close\fR
.sp
\fIobjectName\fR \fBsi:voidvoid_branch\fR
.sp
\fIobjectName\fR \fBsi:voidvalue_branch\fR
.sp
\fIobjectName\fR \fBsi:valuevoid_branch\fR
.sp
\fIobjectName\fR \fBsi:valuevalue_branch\fR
.sp
\fIobjectName\fR \fBsi:voidvoid_part\fR
.sp
\fIobjectName\fR \fBsi:voidvalue_part\fR
.sp
\fIobjectName\fR \fBsi:valuevalue_part\fR
.sp
\fIobjectName\fR \fBsi:value_symbol_start\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBsi:value_void_symbol_start\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBsi:void_symbol_start\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBsi:void_void_symbol_start\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBsi:reduce_symbol_end\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBsi:void_leaf_symbol_end\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBsi:value_leaf_symbol_end\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBsi:value_clear_symbol_end\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBsi:void_clear_symbol_end\fR \fIsymbol\fR
.sp
\fIobjectName\fR \fBsi:next_char\fR \fItok\fR
.sp
\fIobjectName\fR \fBsi:next_range\fR \fItoks\fR \fItoke\fR
.sp
\fIobjectName\fR \fBsi:next_alnum\fR
.sp
\fIobjectName\fR \fBsi:next_alpha\fR
.sp
\fIobjectName\fR \fBsi:next_ascii\fR
.sp
\fIobjectName\fR \fBsi:next_ddigit\fR
.sp
\fIobjectName\fR \fBsi:next_digit\fR
.sp
\fIobjectName\fR \fBsi:next_graph\fR
.sp
\fIobjectName\fR \fBsi:next_lower\fR
.sp
\fIobjectName\fR \fBsi:next_print\fR
.sp
\fIobjectName\fR \fBsi:next_punct\fR
.sp
\fIobjectName\fR \fBsi:next_space\fR
.sp
\fIobjectName\fR \fBsi:next_upper\fR
.sp
\fIobjectName\fR \fBsi:next_wordchar\fR
.sp
\fIobjectName\fR \fBsi:next_xdigit\fR
.sp
.BE
.SH DESCRIPTION
.PP
Are you lost ?
Do you have trouble understanding this document ?
In that case please read the overview provided by the
\fIIntroduction to Parser Tools\fR\&. This document is the
entrypoint to the whole system the current package is a part of\&.
.PP
This package provides a class whose instances provide the runtime
support for recursive descent parsers with backtracking, as is needed
for the execution of, for example, parsing expression grammars\&. It
implements the \fIPackRat Machine Specification\fR, as such that
document is \fIrequired\fR reading to understand both this manpage,
and the package itself\&. The description below does make numerous
shorthand references to the PARAM's instructions and the various parts
of its architectural state\&.
.PP
The package resides in the Execution section of the Core Layer of
Parser Tools\&.
.PP
IMAGE: arch_core_transform
.PP
.PP
Note: This package not only has the standard Tcl implementation, but
also an accelerator, i\&.e\&. a C implementation, based on Critcl\&.
.PP
.SS "CLASS API"
The package exports the API described here\&.
.TP
\fB::pt::rde\fR \fIobjectName\fR
The command creates a new runtime object for a recursive descent
parser with backtracking and returns the fully qualified name of the
object command as its result\&. The API of this object command is
described in the section \fBObject API\fR\&. It may be used to
invoke various operations on the object\&.
.PP
.SS "OBJECT API"
All objects created by this package provide the following 63 methods
for the manipulation and querying of their state, which is, in essence
the architectural state of a PARAM\&.
.PP
First some general methods and the state accessors\&.
.TP
\fIobjectName\fR \fBdestroy\fR
This method destroys the object, releasing all claimed memory, and
deleting the associated object command\&.
.TP
\fIobjectName\fR \fBreset\fR \fIchan\fR
This method resets the state of the runtme to its defaults, preparing
it for the parsing of the character in the channel \fIchan\fR, which
becomes IN\&.
.sp
Note here that the Parser Tools are based on Tcl 8\&.5+\&. In other words,
the channel argument is not restricted to files, sockets, etc\&. We have
the full power of \fIreflected channels\fR available\&.
.sp
It should also be noted that the parser pulls the characters from the
input stream as it needs them\&. If a parser created by this package has
to be operated in a push aka event-driven manner it will be necessary
to go to Tcl 8\&.6+ and use the \fBcoroutine::auto\fR to wrap it
into a coroutine where \fBread\fR is properly changed for
push-operation\&.
.TP
\fIobjectName\fR \fBcomplete\fR
This method completes parsing, either returning the AST made from the
elements of ARS, or throwing an error containing the current ER\&.
.TP
\fIobjectName\fR \fBchan\fR
This method returns the handle of the channel which is IN\&.
.TP
\fIobjectName\fR \fBline\fR
This method returns the line number for the position IN is currently
at\&. Note that this may not match with the line number for CL, due to
backtracking\&.
.TP
\fIobjectName\fR \fBcolumn\fR
This method returns the column for the position IN is currently
at\&. Note that this may not match with the column for CL, due to
backtracking\&.
.TP
\fIobjectName\fR \fBcurrent\fR
This method returns CC\&.
.TP
\fIobjectName\fR \fBlocation\fR
This method returns CL\&.
.TP
\fIobjectName\fR \fBlocations\fR
This method returns the LS\&. The topmost entry of the stack will be the
first element of the returned list\&.
.TP
\fIobjectName\fR \fBok\fR
This method returns ST\&.
.TP
\fIobjectName\fR \fBvalue\fR
This method returns SV\&.
.TP
\fIobjectName\fR \fBerror\fR
This method returns ER\&. This is either the empty string for an empty
ER, or a list of 2 elements, the location the error is for, and a set
of messages which specify which symbols were expected at the
location\&. The messages are encoded as one of the possible atomic
parsing expressions (special operators, terminal, range, and
nonterminal operator)\&.
.TP
\fIobjectName\fR \fBerrors\fR
This method returns ES\&. The topmost entry of the stack will be the
first element of the returned list\&. Each entry is encoded as described
for \fBerror\fR\&.
.TP
\fIobjectName\fR \fBtokens\fR ?\fIfrom\fR ?\fIto\fR??
This method returns the part of TC for the range of locations of IN
starting at \fIfrom\fR and ending at \fIto\fR\&. If \fIto\fR is not
specified it is taken as identical to \fIfrom\fR\&. If neither argument
is specified the whole of TC is returned\&.
.sp
Each token in the returned list is a list of three elements itself,
containing the character at the location, and the associated line and
column numbers, in this order\&.
.TP
\fIobjectName\fR \fBsymbols\fR
This method returns a dictionary containing NC\&. Keys are two-element
lists containing nonterminal symbol and location, in this order\&. The
values are 4-tuples containing CL, ST, ER, and SV, in this order\&. ER
is encoded as specified for the method \fBerror\fR\&.
.TP
\fIobjectName\fR \fBknown\fR
This method returns a list containing the keys of SC\&. They are
encoded in the same manner as is done by method \fBsymbols\fR\&.
.TP
\fIobjectName\fR \fBreducible\fR
This method returns ARS\&. The topmost entry of the stack will be the
first element of the returned list
.TP
\fIobjectName\fR \fBasts\fR
This method returns AS\&. The topmost entry of the stack will be the
first element of the returned list
.TP
\fIobjectName\fR \fBast\fR
This is a convenience method returning the topmost element of ARS\&.
.TP
\fIobjectName\fR \fBposition\fR \fIloc\fR
This method returns the line and column numbers for the specified
location of IN, assuming that this location has already been reached
during the parsing process\&.
.PP
The following methods implement all PARAM instructions\&. They all have
the prefix "i_"\&.
.PP
The control flow is mainly provided by Tcl's builtin commands, like
\fBif\fR, \fBwhile\fR, etc\&., plus a few guarded variants of PARAM
instructions and Tcl commands\&.\&. That means that these instruction
variants will do nothing if their guard condition is not
fulfilled\&. They can be recognized by the prefix "i:ok_" and "i:fail_",
which denote the value ST has to have for the instruction to execute\&.
.PP
The instructions are listed in the same order they occur in the
\fIPackRat Machine Specification\fR, with the guard variants
listed after their regular implementation, if any, or in their place\&.
.TP
\fIobjectName\fR \fBi_input_next\fR \fImsg\fR
This method implements the PARAM instruction \fBinput_next\fR\&.
.TP
\fIobjectName\fR \fBi_test_alnum\fR
This method implements the PARAM instruction \fBtest_alnum\fR\&.
.TP
\fIobjectName\fR \fBi_test_alpha\fR
This method implements the PARAM instruction \fBtest_alpha\fR\&.
.TP
\fIobjectName\fR \fBi_test_ascii\fR
This method implements the PARAM instruction \fBtest_ascii\fR\&.
.TP
\fIobjectName\fR \fBi_test_char\fR \fIchar\fR
This method implements the PARAM instruction \fBtest_char\fR\&.
.TP
\fIobjectName\fR \fBi_test_ddigit\fR
This method implements the PARAM instruction \fBtest_ddigit\fR\&.
.TP
\fIobjectName\fR \fBi_test_digit\fR
This method implements the PARAM instruction \fBtest_digit\fR\&.
.TP
\fIobjectName\fR \fBi_test_graph\fR
This method implements the PARAM instruction \fBtest_graph\fR\&.
.TP
\fIobjectName\fR \fBi_test_lower\fR
This method implements the PARAM instruction \fBtest_lower\fR\&.
.TP
\fIobjectName\fR \fBi_test_print\fR
This method implements the PARAM instruction \fBtest_print\fR\&.
.TP
\fIobjectName\fR \fBi_test_punct\fR
This method implements the PARAM instruction \fBtest_punct\fR\&.
.TP
\fIobjectName\fR \fBi_test_range\fR \fIchars\fR \fIchare\fR
This method implements the PARAM instruction \fBtest_range\fR\&.
.TP
\fIobjectName\fR \fBi_test_space\fR
This method implements the PARAM instruction \fBtest_space\fR\&.
.TP
\fIobjectName\fR \fBi_test_upper\fR
This method implements the PARAM instruction \fBtest_upper\fR\&.
.TP
\fIobjectName\fR \fBi_test_wordchar\fR
This method implements the PARAM instruction \fBtest_wordchar\fR\&.
.TP
\fIobjectName\fR \fBi_test_xdigit\fR
This method implements the PARAM instruction \fBtest_xdigit\fR\&.
.TP
\fIobjectName\fR \fBi_error_clear\fR
This method implements the PARAM instruction \fBerror_clear\fR\&.
.TP
\fIobjectName\fR \fBi_error_push\fR
This method implements the PARAM instruction \fBerror_push\fR\&.
.TP
\fIobjectName\fR \fBi_error_pop_merge\fR
This method implements the PARAM instruction \fBerror_pop_merge\fR\&.
.TP
\fIobjectName\fR \fBi_error_nonterminal\fR \fIsymbol\fR
This method implements the PARAM instruction \fBerror_nonterminal\fR\&.
.TP
\fIobjectName\fR \fBi_status_ok\fR
This method implements the PARAM instruction \fBstatus_ok\fR\&.
.TP
\fIobjectName\fR \fBi_status_fail\fR
This method implements the PARAM instruction \fBstatus_fail\fR\&.
.TP
\fIobjectName\fR \fBi_status_negate\fR
This method implements the PARAM instruction \fBstatus_negate\fR\&.
.TP
\fIobjectName\fR \fBi_loc_push\fR
This method implements the PARAM instruction \fBloc_push\fR\&.
.TP
\fIobjectName\fR \fBi_loc_pop_discard\fR
This method implements the PARAM instruction \fBloc_pop_discard\fR\&.
.TP
\fIobjectName\fR \fBi_loc_pop_rewind\fR
This method implements the PARAM instruction \fBloc_pop_rewind\fR\&.
.TP
\fIobjectName\fR \fBi:ok_loc_pop_rewind\fR
This guarded method, a variant of \fBi_loc_pop_rewind\fR, executes only
for "ST == ok"\&.
.TP
\fIobjectName\fR \fBi_loc_pop_rewind/discard\fR
This method is a convenient combination of control flow and the two
PARAM instructions \fBloc_pop_rewind\fR and \fBloc_pop_discard\fR\&. The former
is executed for "ST == fail", the latter for "ST == ok"\&.
.TP
\fIobjectName\fR \fBi_symbol_restore\fR \fIsymbol\fR
This method implements the PARAM instruction \fBsymbol_restore\fR\&.
.sp
The boolean result of the check is returned as the result of
the method and can be used with standard Tcl control flow commands\&.
.TP
\fIobjectName\fR \fBi_symbol_save\fR \fIsymbol\fR
This method implements the PARAM instruction \fBsymbol_save\fR\&.
.TP
\fIobjectName\fR \fBi_value_clear\fR
This method implements the PARAM instruction \fBvalue_clear\fR\&.
.TP
\fIobjectName\fR \fBi_value_clear/leaf\fR
This method is a convenient combination of control flow and the two
PARAM instructions \fBvalue_clear\fR and \fBvalue_leaf\fR\&. The former
is executed for "ST == fail", the latter for "ST == ok"\&.
.TP
\fIobjectName\fR \fBi_value_clear/reduce\fR
This method is a convenient combination of control flow and the two
PARAM instructions \fBvalue_clear\fR and \fBvalue_reduce\fR\&. The former
is executed for "ST == fail", the latter for "ST == ok"\&.
.TP
\fIobjectName\fR \fBi:ok_ast_value_push\fR
This method implements a guarded variant of the the PARAM instruction
\fBast_value_push\fR, which executes only for "ST == ok"\&.
.TP
\fIobjectName\fR \fBi_ast_push\fR
This method implements the PARAM instruction \fBast_push\fR\&.
.TP
\fIobjectName\fR \fBi_ast_pop_rewind\fR
This method implements the PARAM instruction \fBast_pop_rewind\fR\&.
.TP
\fIobjectName\fR \fBi:fail_ast_pop_rewind\fR
This guarded method, a variant of \fBi_ast_pop_rewind\fR, executes only
for "ST == fail"\&.
.TP
\fIobjectName\fR \fBi_ast_pop_rewind/discard\fR
This method is a convenient combination of control flow and the two
PARAM instructions \fBast_pop_rewind\fR and \fBast_pop_discard\fR\&. The former
is executed for "ST == fail", the latter for "ST == ok"\&.
.TP
\fIobjectName\fR \fBi_ast_pop_discard\fR
This method implements the PARAM instruction \fBast_pop_discard\fR\&.
.TP
\fIobjectName\fR \fBi_ast_pop_discard/rewind\fR
This method is a convenient combination of control flow and the two
PARAM instructions \fBast_pop_discard\fR and \fBast_pop_rewind\fR\&. The former
is executed for "ST == fail", the latter for "ST == ok"\&.
.TP
\fIobjectName\fR \fBi:ok_continue\fR
This guarded method executes only for "ST == ok"\&. Then it aborts the
current iteration of the innermost loop in the calling Tcl procedure\&.
.TP
\fIobjectName\fR \fBi:fail_continue\fR
This guarded method executes only for "ST == fail"\&. Then it aborts the
current iteration of the innermost loop in the calling Tcl procedure\&.
.TP
\fIobjectName\fR \fBi:fail_return\fR
This guarded method executes only for "ST == fail"\&. Then it aborts the
calling Tcl procedure\&.
.TP
\fIobjectName\fR \fBi:ok_return\fR
This guarded method executes only for "ST == ok"\&. Then it aborts the
calling Tcl procedure\&.
.PP
.PP
The next set of methods are \fIsuper instructions\fR, meaning that
each implements a longer sequence of instructions commonly used in
parsers\&. The combinated instructions of the previous set, i\&.e\&. those
with names matching the pattern "i_*/*", are actually super
instructions as well, albeit with limited scope, handling 2
instructions with their control flow\&. The upcoming set is much broader
in scope, folding as much as six or more PARAM instructions into a
single method call\&.
.PP
In this we can see the reasoning behind their use well:
.IP [1]
By using less instructions the generated parsers become smaller, as
the common parts are now truly part of the common runtime, and not
explicitly written in the parser's code over and over again\&.
.IP [2]
Using less instructions additionally reduces the overhead associated
with calls into the runtime, i\&.e\&. the cost of method dispatch and of
setting up the variable context\&.
.IP [3]
Another effect of the super instructions is that their internals can
be optimized as well, especially regarding control flow, and stack
use, as the runtime internals are accessible to all instructions
folded into the sequence\&.
.PP
.PP
.TP
\fIobjectName\fR \fBsi:void_state_push\fR
This method combines
.CS
i_loc_push
i_error_clear
i_error_push
.CE
.IP
Parsers use it at the beginning of \fIvoid\fR sequences and choices
with a \fIvoid\fR initial branch\&.
.TP
\fIobjectName\fR \fBsi:void2_state_push\fR
This method combines
.CS
i_loc_push
i_error_clear
i_error_push
.CE
.IP
Parsers use it at the beginning of optional and repeated expressions\&.
.TP
\fIobjectName\fR \fBsi:value_state_push\fR
This method combines
.CS
i_ast_push
i_loc_push
i_error_clear
i_error_push
.CE
.IP
Parsers use it at the beginning of sequences generating an AST and
choices with an initial branch generating an AST\&.
.TP
\fIobjectName\fR \fBsi:void_state_merge\fR
This method combines
.CS
i_error_pop_merge
i_loc_pop_rewind/discard
.CE
.IP
Parsers use it at the end of void sequences and choices whose last
branch is void\&.
.TP
\fIobjectName\fR \fBsi:void_state_merge_ok\fR
This method combines
.CS
i_error_pop_merge
i_loc_pop_rewind/discard
i_status_ok
.CE
.IP
Parsers use it at the end of optional expressions
.TP
\fIobjectName\fR \fBsi:value_state_merge\fR
This method combines
.CS
i_error_pop_merge
i_ast_pop_rewind/discard
i_loc_pop_rewind/discard
.CE
.IP
Parsers use it at the end of sequences generating ASTs and choices
whose last branch generates an AST
.TP
\fIobjectName\fR \fBsi:value_notahead_start\fR
This method combines
.CS
i_loc_push
i_ast_push
.CE
.IP
Parsers use it at the beginning of negative lookahead predicates which
generate ASTs\&.
.TP
\fIobjectName\fR \fBsi:void_notahead_exit\fR
This method combines
.CS
i_loc_pop_rewind
i_status_negate
.CE
.IP
Parsers use it at the end of void negative lookahead predicates\&.
.TP
\fIobjectName\fR \fBsi:value_notahead_exit\fR
This method combines
.CS
i_ast_pop_discard/rewind
i_loc_pop_rewind
i_status_negate
.CE
.IP
Parsers use it at the end of negative lookahead predicates which
generate ASTs\&.
.TP
\fIobjectName\fR \fBsi:kleene_abort\fR
This method combines
.CS
i_loc_pop_rewind/discard
i:fail_return
.CE
.IP
Parsers use it to stop a positive repetition when its first, required, expression fails\&.
.TP
\fIobjectName\fR \fBsi:kleene_close\fR
This method combines
.CS
i_error_pop_merge
i_loc_pop_rewind/discard
i:fail_status_ok
i:fail_return
.CE
.IP
Parsers use it at the end of repetitions\&.
.TP
\fIobjectName\fR \fBsi:voidvoid_branch\fR
This method combines
.CS
i_error_pop_merge
i:ok_loc_pop_discard
i:ok_return
i_loc_rewind
i_error_push
.CE
.IP
Parsers use it when transiting between branches of a choice when both are void\&.
.TP
\fIobjectName\fR \fBsi:voidvalue_branch\fR
This method combines
.CS
i_error_pop_merge
i:ok_loc_pop_discard
i:ok_return
i_ast_push
i_loc_rewind
i_error_push
.CE
.IP
Parsers use it when transiting between branches of a choice when the
failing branch is void, and the next to test generates an AST\&.
.TP
\fIobjectName\fR \fBsi:valuevoid_branch\fR
This method combines
.CS
i_error_pop_merge
i_ast_pop_rewind/discard
i:ok_loc_pop_discard
i:ok_return
i_loc_rewind
i_error_push
.CE
.IP
Parsers use it when transiting between branches of a choice when the
failing branch generates an AST, and the next to test is void\&.
.TP
\fIobjectName\fR \fBsi:valuevalue_branch\fR
This method combines
.CS
i_error_pop_merge
i_ast_pop_discard
i:ok_loc_pop_discard
i:ok_return
i_ast_rewind
i_loc_rewind
i_error_push
.CE
.IP
Parsers use it when transiting between branches of a choice when both
generate ASTs\&.
.TP
\fIobjectName\fR \fBsi:voidvoid_part\fR
This method combines
.CS
i_error_pop_merge
i:fail_loc_pop_rewind
i:fail_return
i_error_push
.CE
.IP
Parsers use it when transiting between parts of a sequence and both
are void\&.
.TP
\fIobjectName\fR \fBsi:voidvalue_part\fR
This method combines
.CS
i_error_pop_merge
i:fail_loc_pop_rewind
i:fail_return
i_ast_push
i_error_push
.CE
.IP
Parsers use it when transiting between parts of a sequence and the
sucessfully matched part is void, and after it an AST is generated\&.
.TP
\fIobjectName\fR \fBsi:valuevalue_part\fR
This method combines
.CS
i_error_pop_merge
i:fail_ast_pop_rewind
i:fail_loc_pop_rewind
i:fail_return
i_error_push
.CE
.IP
Parsers use it when transiting between parts of a sequence and both
parts generate ASTs\&.
.TP
\fIobjectName\fR \fBsi:value_symbol_start\fR \fIsymbol\fR
This method combines
.CS
if/found? i_symbol_restore $symbol
i:found:ok_ast_value_push
i:found_return
i_loc_push
i_ast_push
.CE
.IP
Parsers use it at the beginning of a nonterminal symbol generating an
AST, whose right-hand side may have generated an AST as well\&.
.TP
\fIobjectName\fR \fBsi:value_void_symbol_start\fR \fIsymbol\fR
This method combines
.CS
if/found? i_symbol_restore $symbol
i:found:ok_ast_value_push
i:found_return
i_loc_push
i_ast_push
.CE
.IP
Parsers use it at the beginning of a void nonterminal symbol whose
right-hand side may generate an AST\&.
.TP
\fIobjectName\fR \fBsi:void_symbol_start\fR \fIsymbol\fR
This method combines
.CS
if/found? i_symbol_restore $symbol
i:found_return
i_loc_push
i_ast_push
.CE
.IP
Parsers use it at the beginning of a nonterminal symbol generating an
AST whose right-hand side is void\&.
.TP
\fIobjectName\fR \fBsi:void_void_symbol_start\fR \fIsymbol\fR
This method combines
.CS
if/found? i_symbol_restore $symbol
i:found_return
i_loc_push
.CE
.IP
Parsers use it at the beginning of a void nonterminal symbol whose
right-hand side is void as well\&.
.TP
\fIobjectName\fR \fBsi:reduce_symbol_end\fR \fIsymbol\fR
This method combines
.CS
i_value_clear/reduce $symbol
i_symbol_save $symbol
i_error_nonterminal $symbol
i_ast_pop_rewind
i_loc_pop_discard
i:ok_ast_value_push
.CE
.IP
Parsers use it at the end of a non-terminal symbol generating an AST
using the AST generated by the right-hand side as child\&.
.TP
\fIobjectName\fR \fBsi:void_leaf_symbol_end\fR \fIsymbol\fR
This method combines
.CS
i_value_clear/leaf $symbol
i_symbol_save $symbol
i_error_nonterminal $symbol
i_loc_pop_discard
i:ok_ast_value_push
.CE
.IP
Parsers use it at the end of a non-terminal symbol generating an AST
whose right-hand side is void\&.
.TP
\fIobjectName\fR \fBsi:value_leaf_symbol_end\fR \fIsymbol\fR
This method combines
.CS
i_value_clear/leaf $symbol
i_symbol_save $symbol
i_error_nonterminal $symbol
i_loc_pop_discard
i_ast_pop_rewind
i:ok_ast_value_push
.CE
.IP
Parsers use it at the end of a non-terminal symbol generating an AST
discarding the AST generated by the right-hand side\&.
.TP
\fIobjectName\fR \fBsi:value_clear_symbol_end\fR \fIsymbol\fR
This method combines
.CS
i_value_clear
i_symbol_save $symbol
i_error_nonterminal $symbol
i_loc_pop_discard
i_ast_pop_rewind
.CE
.IP
Parsers use it at the end of a void non-terminal symbol, discarding
the AST generated by the right-hand side\&.
.TP
\fIobjectName\fR \fBsi:void_clear_symbol_end\fR \fIsymbol\fR
This method combines
.CS
i_value_clear
i_symbol_save $symbol
i_error_nonterminal $symbol
i_loc_pop_discard
.CE
.IP
Parsers use it at the end of a void non-terminal symbol with a void
right-hand side\&.
.TP
\fIobjectName\fR \fBsi:next_char\fR \fItok\fR
.TP
\fIobjectName\fR \fBsi:next_range\fR \fItoks\fR \fItoke\fR
.TP
\fIobjectName\fR \fBsi:next_alnum\fR
.TP
\fIobjectName\fR \fBsi:next_alpha\fR
.TP
\fIobjectName\fR \fBsi:next_ascii\fR
.TP
\fIobjectName\fR \fBsi:next_ddigit\fR
.TP
\fIobjectName\fR \fBsi:next_digit\fR
.TP
\fIobjectName\fR \fBsi:next_graph\fR
.TP
\fIobjectName\fR \fBsi:next_lower\fR
.TP
\fIobjectName\fR \fBsi:next_print\fR
.TP
\fIobjectName\fR \fBsi:next_punct\fR
.TP
\fIobjectName\fR \fBsi:next_space\fR
.TP
\fIobjectName\fR \fBsi:next_upper\fR
.TP
\fIobjectName\fR \fBsi:next_wordchar\fR
.TP
\fIobjectName\fR \fBsi:next_xdigit\fR
These methods all combine
.CS
i_input_next $msg
i:fail_return
.CE
.IP
with the appropriate \fBi_test_xxx\fR instruction\&. Parsers use them for
handling atomic expressions\&.
.PP
.PP
.SH "BUGS, IDEAS, FEEDBACK"
This document, and the package it describes, will undoubtedly contain
bugs and other problems\&.
Please report such in the category \fIpt\fR of the
\fITcllib Trackers\fR [http://core\&.tcl\&.tk/tcllib/reportlist]\&.
Please also report any ideas for enhancements you may have for either
package and/or documentation\&.
.PP
When proposing code changes, please provide \fIunified diffs\fR,
i\&.e the output of \fBdiff -u\fR\&.
.PP
Note further that \fIattachments\fR are strongly preferred over
inlined patches\&. Attachments can be made by going to the \fBEdit\fR
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar\&.
.SH KEYWORDS
EBNF, LL(k), PEG, TDPL, context-free languages, expression, grammar, matching, parser, parsing expression, parsing expression grammar, push down automaton, recursive descent, state, top-down parsing languages, transducer
.SH CATEGORY
Parsing and Grammars
.SH COPYRIGHT
.nf
Copyright (c) 2009 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
.fi
|