Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Bring examples up to date with latest parser fixes and changes. |
---|---|
Timelines: | family | ancestors | descendants | both | pt-examples |
Files: | files | file ages | folders |
SHA1: |
75d8a9a9c71a194527b1b25d074b7501 |
User & Date: | aku 2014-06-28 21:41:37 |
2014-07-23
| ||
18:26 | Added a markdown syntax gotten from various places. Untested. Likely needs tuning of symbol modes (void, leaf) to generate a nice AST. This is a grammar which is in strong need of lots of comments and explanations to understand what is going on inside. There are predicates all over the place making it quite context-sensitive. The main specification at http://daringfireball.net/projects/markdown/syntax is unfortunately quite informal, i.e. only text. check-in: 0bb9e06e3b user: andreask tags: pt-examples | |
2014-06-28
| ||
21:41 | Bring examples up to date with latest parser fixes and changes. check-in: 75d8a9a9c7 user: aku tags: pt-examples | |
21:18 | pt::parse::peg (C) - Updated with the fixes to the C generator. Updated all testsuite results with the same fixes. Closed-Leaf check-in: af55e30def user: aku tags: pt-work | |
2014-06-25
| ||
00:15 | Filling out more examples: strings, arithmetic expressions, csv check-in: b7a6210953 user: andreask tags: pt-examples | |
Added embedded/man/files/modules/pt/pt_cparam_config_tea.n.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | '\" '\" Generated from file 'pt_cparam_config_tea\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 2009 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net> '\" .TH "pt::cparam::configuration::tea" n 0\&.1 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::cparam::configuration::tea \- C/PARAM, Canned configuration, TEA .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp package require \fBpt::cparam::configuration::tea ?0\&.1?\fR .sp \fB::pt::cparam::configuration::tea\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\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 is an adjunct to \fBpt::peg::to::cparam\fR, to make the use of this highly configurable package easier by providing a canned configuration\&. When applied this configuration causes the package \fBpt::peg::to::cparam\fR to generate plain parser code ready for inclusion into a \fITEA\fR-based C extension\&. .PP It is a supporting package in the Core Layer of Parser Tools\&. .PP IMAGE: arch_core_support .PP .SH API .TP \fB::pt::cparam::configuration::tea\fR \fBdef\fR \fIname\fR \fIpkg\fR \fIversion\fR \fIcmdprefix\fR The command applies the configuration provided by this package to the \fIcmdprefix\fR, causing the creation of \fBtea\fR-based parsers whose class is \fIname\fR, in package \fIpkg\fR with \fIversion\fR\&. .sp The use of a command prefix as API allows application of the configuration to not only \fBpt::peg::to::cparam\fR (\fBpt::peg::to::cparam configure\fR), but also export manager instances and PEG containers (\fB$export configuration set\fR and \fB[$container exporter] configuration set\fR respectively)\&. .sp Or anything other command prefix accepting two arguments, option and value\&. .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\&. .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 |
Changes to embedded/man/index.n.
︙ | ︙ | |||
1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ | |||
10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP | > > > | 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 | pt .TP \fBfiles/modules/pt/pt_astree\&.n\fR pt::ast .TP \fBfiles/modules/pt/pt_cparam_config_critcl\&.n\fR pt::cparam::configuration::critcl .TP \fBfiles/modules/pt/pt_cparam_config_tea\&.n\fR pt::cparam::configuration::tea .TP \fBfiles/modules/pt/pt_json_language\&.n\fR pt::json_language .TP \fBfiles/modules/pt/pt_param\&.n\fR pt::param .TP |
︙ | ︙ |
Changes to embedded/man/toc.n.
︙ | ︙ | |||
944 945 946 947 948 949 950 951 952 953 954 955 956 957 | .TP \fBpt::ast\fR \fIfiles/modules/pt/pt_astree\&.n\fR: Abstract Syntax Tree Serialization .TP \fBpt::cparam::configuration::critcl\fR \fIfiles/modules/pt/pt_cparam_config_critcl\&.n\fR: C/PARAM, Canned configuration, Critcl .TP \fBpt::json_language\fR \fIfiles/modules/pt/pt_json_language\&.n\fR: The JSON Grammar Exchange Format .TP \fBpt::param\fR \fIfiles/modules/pt/pt_param\&.n\fR: PackRat Machine Specification .TP \fBpt::pe\fR | > > > | 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | .TP \fBpt::ast\fR \fIfiles/modules/pt/pt_astree\&.n\fR: Abstract Syntax Tree Serialization .TP \fBpt::cparam::configuration::critcl\fR \fIfiles/modules/pt/pt_cparam_config_critcl\&.n\fR: C/PARAM, Canned configuration, Critcl .TP \fBpt::cparam::configuration::tea\fR \fIfiles/modules/pt/pt_cparam_config_tea\&.n\fR: C/PARAM, Canned configuration, TEA .TP \fBpt::json_language\fR \fIfiles/modules/pt/pt_json_language\&.n\fR: The JSON Grammar Exchange Format .TP \fBpt::param\fR \fIfiles/modules/pt/pt_param\&.n\fR: PackRat Machine Specification .TP \fBpt::pe\fR |
︙ | ︙ |
Changes to embedded/www/index.html.
︙ | ︙ | |||
746 747 748 749 750 751 752 | <td class="#idxleft" width="35%"><a name="key23"> context-free grammar </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key4"> context-free languages </a></td> <td class="#idxright" width="65%"> | | | 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | <td class="#idxleft" width="35%"><a name="key23"> context-free grammar </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key4"> context-free languages </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key95"> control </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/control/control.html"> control </a> · <a href="tcllib/files/modules/term/term.html"> term </a> · <a href="tcllib/files/modules/term/ansi_code.html"> term::ansi::code </a> · <a href="tcllib/files/modules/term/ansi_cattr.html"> term::ansi::code::attr </a> · <a href="tcllib/files/modules/term/ansi_cctrl.html"> term::ansi::code::ctrl </a> · <a href="tcllib/files/modules/term/ansi_cmacros.html"> term::ansi::code::macros </a> · <a href="tcllib/files/modules/term/ansi_ctrlu.html"> term::ansi::ctrl::unix </a> · <a href="tcllib/files/modules/term/ansi_send.html"> term::ansi::send </a> · <a href="tcllib/files/modules/term/imenu.html"> term::interact::menu </a> · <a href="tcllib/files/modules/term/ipager.html"> term::interact::pager </a> · <a href="tcllib/files/modules/term/receive.html"> term::receive </a> · <a href="tcllib/files/modules/term/term_bind.html"> term::receive::bind </a> · <a href="tcllib/files/modules/term/term_send.html"> term::send </a> </td></tr> <tr class="#idxeven" valign=top> |
︙ | ︙ | |||
1212 1213 1214 1215 1216 1217 1218 | <td class="#idxleft" width="35%"><a name="key816"> earley </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_aycock/aycock.html"> grammar::aycock </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key3"> EBNF </a></td> <td class="#idxright" width="65%"> | | | 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 | <td class="#idxleft" width="35%"><a name="key816"> earley </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_aycock/aycock.html"> grammar::aycock </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key3"> EBNF </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key496"> eccentricity </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/struct/graphops.html"> struct::graph::op </a> </td></tr> <tr class="#idxeven" valign=top> |
︙ | ︙ | |||
1352 1353 1354 1355 1356 1357 1358 | <td class="#idxleft" width="35%"><a name="key256"> export </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/doctools2base/html_cssdefaults.html"> doctools::html::cssdefaults </a> · <a href="tcllib/files/modules/doctools2idx/idx_export.html"> doctools::idx::export </a> · <a href="tcllib/files/modules/doctools2idx/export_docidx.html"> doctools::idx::export::docidx </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_html.html"> doctools::idx::export::html </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_json.html"> doctools::idx::export::json </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_nroff.html"> doctools::idx::export::nroff </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_text.html"> doctools::idx::export::text </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_wiki.html"> doctools::idx::export::wiki </a> · <a href="tcllib/files/modules/doctools2base/nroff_manmacros.html"> doctools::nroff::man_macros </a> · <a href="tcllib/files/modules/doctools2toc/toc_export.html"> doctools::toc::export </a> · <a href="tcllib/files/modules/doctools2toc/export_doctoc.html"> doctools::toc::export::doctoc </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_html.html"> doctools::toc::export::html </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_json.html"> doctools::toc::export::json </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_nroff.html"> doctools::toc::export::nroff </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_text.html"> doctools::toc::export::text </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_wiki.html"> doctools::toc::export::wiki </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key0"> expression </a></td> <td class="#idxright" width="65%"> | | | 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 | <td class="#idxleft" width="35%"><a name="key256"> export </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/doctools2base/html_cssdefaults.html"> doctools::html::cssdefaults </a> · <a href="tcllib/files/modules/doctools2idx/idx_export.html"> doctools::idx::export </a> · <a href="tcllib/files/modules/doctools2idx/export_docidx.html"> doctools::idx::export::docidx </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_html.html"> doctools::idx::export::html </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_json.html"> doctools::idx::export::json </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_nroff.html"> doctools::idx::export::nroff </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_text.html"> doctools::idx::export::text </a> · <a href="tcllib/files/modules/doctools2idx/idx_export_wiki.html"> doctools::idx::export::wiki </a> · <a href="tcllib/files/modules/doctools2base/nroff_manmacros.html"> doctools::nroff::man_macros </a> · <a href="tcllib/files/modules/doctools2toc/toc_export.html"> doctools::toc::export </a> · <a href="tcllib/files/modules/doctools2toc/export_doctoc.html"> doctools::toc::export::doctoc </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_html.html"> doctools::toc::export::html </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_json.html"> doctools::toc::export::json </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_nroff.html"> doctools::toc::export::nroff </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_text.html"> doctools::toc::export::text </a> · <a href="tcllib/files/modules/doctools2toc/toc_export_wiki.html"> doctools::toc::export::wiki </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key0"> expression </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key87"> extended namespace </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/namespacex/namespacex.html"> namespacex </a> </td></tr> <tr class="#idxheader"><th colspan="2"> |
︙ | ︙ | |||
1623 1624 1625 1626 1627 1628 1629 | <td class="#idxleft" width="35%"><a name="key662"> gpx </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/gpx/gpx.html"> gpx </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key11"> grammar </a></td> <td class="#idxright" width="65%"> | | | 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 | <td class="#idxleft" width="35%"><a name="key662"> gpx </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/gpx/gpx.html"> gpx </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key11"> grammar </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_aycock/aycock.html"> grammar::aycock </a> · <a href="tcllib/files/modules/grammar_fa/fa.html"> grammar::fa </a> · <a href="tcllib/files/modules/grammar_fa/dacceptor.html"> grammar::fa::dacceptor </a> · <a href="tcllib/files/modules/grammar_fa/dexec.html"> grammar::fa::dexec </a> · <a href="tcllib/files/modules/grammar_fa/faop.html"> grammar::fa::op </a> · <a href="tcllib/files/modules/grammar_me/me_cpu.html"> grammar::me::cpu </a> · <a href="tcllib/files/modules/grammar_me/me_cpucore.html"> grammar::me::cpu::core </a> · <a href="tcllib/files/modules/grammar_me/gasm.html"> grammar::me::cpu::gasm </a> · <a href="tcllib/files/modules/grammar_me/me_tcl.html"> grammar::me::tcl </a> · <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_me/me_vm.html"> grammar::me_vm </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key301"> graph </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/gasm.html"> grammar::me::cpu::gasm </a> · <a href="tcllib/files/modules/struct/graph.html"> struct::graph </a> · <a href="tcllib/files/modules/struct/graphops.html"> struct::graph::op </a> · <a href="tcllib/files/modules/struct/graph1.html"> struct::graph_v1 </a> · <a href="tcllib/files/modules/struct/queue.html"> struct::queue </a> · <a href="tcllib/files/modules/struct/stack.html"> struct::stack </a> </td></tr> <tr class="#idxodd" valign=top> |
︙ | ︙ | |||
2123 2124 2125 2126 2127 2128 2129 | <td class="#idxleft" width="35%"><a name="key432"> literate programming </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/docstrip/docstrip.html"> docstrip </a> · <a href="tcllib/files/modules/docstrip/docstrip_util.html"> docstrip_util </a> · <a href="tcllib/files/apps/tcldocstrip.html"> tcldocstrip </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key15"> LL(k) </a></td> <td class="#idxright" width="65%"> | | | 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 | <td class="#idxleft" width="35%"><a name="key432"> literate programming </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/docstrip/docstrip.html"> docstrip </a> · <a href="tcllib/files/modules/docstrip/docstrip_util.html"> docstrip_util </a> · <a href="tcllib/files/apps/tcldocstrip.html"> tcldocstrip </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key15"> LL(k) </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key477"> local searching </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/struct/graphops.html"> struct::graph::op </a> </td></tr> <tr class="#idxeven" valign=top> |
︙ | ︙ | |||
2226 2227 2228 2229 2230 2231 2232 | <td class="#idxleft" width="35%"><a name="key663"> MasterCard </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/valtype/cc_mastercard.html"> valtype::creditcard::mastercard </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key5"> matching </a></td> <td class="#idxright" width="65%"> | | | 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 | <td class="#idxleft" width="35%"><a name="key663"> MasterCard </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/valtype/cc_mastercard.html"> valtype::creditcard::mastercard </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key5"> matching </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> · <a href="tcllib/files/modules/struct/graphops.html"> struct::graph::op </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key71"> math </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/math/math.html"> math </a> · <a href="tcllib/files/modules/math/bigfloat.html"> math::bigfloat </a> · <a href="tcllib/files/modules/math/bignum.html"> math::bignum </a> · <a href="tcllib/files/modules/math/calculus.html"> math::calculus </a> · <a href="tcllib/files/modules/math/qcomplex.html"> math::complexnumbers </a> · <a href="tcllib/files/modules/math/constants.html"> math::constants </a> · <a href="tcllib/files/modules/math/decimal.html"> math::decimal </a> · <a href="tcllib/files/modules/math/fuzzy.html"> math::fuzzy </a> · <a href="tcllib/files/modules/math/math_geometry.html"> math::geometry </a> · <a href="tcllib/files/modules/math/interpolate.html"> math::interpolate </a> · <a href="tcllib/files/modules/math/linalg.html"> math::linearalgebra </a> · <a href="tcllib/files/modules/math/optimize.html"> math::optimize </a> · <a href="tcllib/files/modules/math/polynomials.html"> math::polynomials </a> · <a href="tcllib/files/modules/math/rational_funcs.html"> math::rationalfunctions </a> · <a href="tcllib/files/modules/math/special.html"> math::special </a> · <a href="tcllib/files/modules/simulation/annealing.html"> simulation::annealing </a> · <a href="tcllib/files/modules/simulation/montecarlo.html"> simulation::montecarlo </a> · <a href="tcllib/files/modules/simulation/simulation_random.html"> simulation::random </a> </td></tr> <tr class="#idxeven" valign=top> |
︙ | ︙ | |||
2630 2631 2632 2633 2634 2635 2636 | <td class="#idxleft" width="35%"><a name="key399"> parameter entry form </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/tepam/tepam_introduction.html"> tepam </a> · <a href="tcllib/files/modules/tepam/tepam_argument_dialogbox.html"> tepam::argument_dialogbox </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key9"> parser </a></td> <td class="#idxright" width="65%"> | | | | | 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 | <td class="#idxleft" width="35%"><a name="key399"> parameter entry form </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/tepam/tepam_introduction.html"> tepam </a> · <a href="tcllib/files/modules/tepam/tepam_argument_dialogbox.html"> tepam::argument_dialogbox </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key9"> parser </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/doctools2idx/idx_parse.html"> doctools::idx::parse </a> · <a href="tcllib/files/modules/doctools2base/tcl_parse.html"> doctools::tcl::parse </a> · <a href="tcllib/files/modules/doctools2toc/toc_parse.html"> doctools::toc::parse </a> · <a href="tcllib/files/modules/grammar_aycock/aycock.html"> grammar::aycock </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> · <a href="tcllib/files/modules/amazon-s3/xsxp.html"> xsxp </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key187"> parser generator </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/apps/page.html"> page </a> · <a href="tcllib/files/modules/page/page_intro.html"> page_intro </a> · <a href="tcllib/files/modules/page/page_pluginmgr.html"> page_pluginmgr </a> · <a href="tcllib/files/modules/page/page_util_flow.html"> page_util_flow </a> · <a href="tcllib/files/modules/page/page_util_norm_lemon.html"> page_util_norm_lemon </a> · <a href="tcllib/files/modules/page/page_util_norm_peg.html"> page_util_norm_peg </a> · <a href="tcllib/files/modules/page/page_util_peg.html"> page_util_peg </a> · <a href="tcllib/files/modules/page/page_util_quote.html"> page_util_quote </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key26"> parsing </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/bench/bench_read.html"> bench::in </a> · <a href="tcllib/files/modules/bibtex/bibtex.html"> bibtex </a> · <a href="tcllib/files/modules/doctools2idx/idx_introduction.html"> doctools2idx_introduction </a> · <a href="tcllib/files/modules/doctools2toc/toc_introduction.html"> doctools2toc_introduction </a> · <a href="tcllib/files/modules/doctools2idx/idx_container.html"> doctools::idx </a> · <a href="tcllib/files/modules/doctools2idx/idx_import.html"> doctools::idx::import </a> · <a href="tcllib/files/modules/doctools2toc/toc_container.html"> doctools::toc </a> · <a href="tcllib/files/modules/doctools2toc/toc_import.html"> doctools::toc::import </a> · <a href="tcllib/files/modules/grammar_aycock/aycock.html"> grammar::aycock </a> · <a href="tcllib/files/modules/grammar_fa/fa.html"> grammar::fa </a> · <a href="tcllib/files/modules/grammar_fa/dacceptor.html"> grammar::fa::dacceptor </a> · <a href="tcllib/files/modules/grammar_fa/dexec.html"> grammar::fa::dexec </a> · <a href="tcllib/files/modules/grammar_fa/faop.html"> grammar::fa::op </a> · <a href="tcllib/files/modules/grammar_me/me_cpu.html"> grammar::me::cpu </a> · <a href="tcllib/files/modules/grammar_me/me_cpucore.html"> grammar::me::cpu::core </a> · <a href="tcllib/files/modules/grammar_me/gasm.html"> grammar::me::cpu::gasm </a> · <a href="tcllib/files/modules/grammar_me/me_tcl.html"> grammar::me::tcl </a> · <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_me/me_vm.html"> grammar::me_vm </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/modules/htmlparse/htmlparse.html"> htmlparse </a> · <a href="tcllib/files/modules/yaml/huddle.html"> huddle </a> · <a href="tcllib/files/modules/string/token_shell.html"> string::token::shell </a> · <a href="tcllib/files/modules/yaml/yaml.html"> yaml </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key8"> parsing expression </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key14"> parsing expression grammar </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/modules/page/page_util_peg.html"> page_util_peg </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key587"> partial application </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/lambda/lambda.html"> lambda </a> </td></tr> <tr class="#idxodd" valign=top> |
︙ | ︙ | |||
2690 2691 2692 2693 2694 2695 2696 | <td class="#idxleft" width="35%"><a name="key629"> patching </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/rcs/rcs.html"> rcs </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key6"> PEG </a></td> <td class="#idxright" width="65%"> | | | 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 | <td class="#idxleft" width="35%"><a name="key629"> patching </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/rcs/rcs.html"> rcs </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key6"> PEG </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/page/page_util_norm_peg.html"> page_util_norm_peg </a> · <a href="tcllib/files/modules/page/page_util_peg.html"> page_util_peg </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key100"> performance </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/bench/bench.html"> bench </a> · <a href="tcllib/files/modules/bench/bench_read.html"> bench::in </a> · <a href="tcllib/files/modules/bench/bench_wcsv.html"> bench::out::csv </a> · <a href="tcllib/files/modules/bench/bench_wtext.html"> bench::out::text </a> · <a href="tcllib/files/modules/bench/bench_intro.html"> bench_intro </a> · <a href="tcllib/files/modules/bench/bench_lang_intro.html"> bench_lang_intro </a> · <a href="tcllib/files/modules/bench/bench_lang_spec.html"> bench_lang_spec </a> · <a href="tcllib/files/modules/profiler/profiler.html"> profiler </a> </td></tr> <tr class="#idxodd" valign=top> |
︙ | ︙ | |||
2860 2861 2862 2863 2864 2865 2866 | <td class="#idxleft" width="35%"><a name="key674"> publisher </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/hook/hook.html"> hook </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key1"> push down automaton </a></td> <td class="#idxright" width="65%"> | | | 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 | <td class="#idxleft" width="35%"><a name="key674"> publisher </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/hook/hook.html"> hook </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key1"> push down automaton </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxheader"><th colspan="2"> <a name="c20">Keywords: Q</a> </th></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key50"> queue </a></td> <td class="#idxright" width="65%"> |
︙ | ︙ | |||
2956 2957 2958 2959 2960 2961 2962 | <td class="#idxleft" width="35%"><a name="key303"> record </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/struct/queue.html"> struct::queue </a> · <a href="tcllib/files/modules/struct/record.html"> struct::record </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key10"> recursive descent </a></td> <td class="#idxright" width="65%"> | | | 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 | <td class="#idxleft" width="35%"><a name="key303"> record </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/struct/queue.html"> struct::queue </a> · <a href="tcllib/files/modules/struct/record.html"> struct::record </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key10"> recursive descent </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key215"> reduce </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/generator/generator.html"> generator </a> · <a href="tcllib/files/modules/struct/struct_list.html"> struct::list </a> </td></tr> <tr class="#idxodd" valign=top> |
︙ | ︙ | |||
3499 3500 3501 3502 3503 3504 3505 | <td class="#idxleft" width="35%"><a name="key818"> standard io </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/virtchannel_base/std.html"> tcl::chan::std </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key2"> state </a></td> <td class="#idxright" width="65%"> | | | 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 | <td class="#idxleft" width="35%"><a name="key818"> standard io </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/virtchannel_base/std.html"> tcl::chan::std </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key2"> state </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_fa/fa.html"> grammar::fa </a> · <a href="tcllib/files/modules/grammar_fa/dacceptor.html"> grammar::fa::dacceptor </a> · <a href="tcllib/files/modules/grammar_fa/dexec.html"> grammar::fa::dexec </a> · <a href="tcllib/files/modules/grammar_fa/faop.html"> grammar::fa::op </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key84"> state (de)serialization </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/namespacex/namespacex.html"> namespacex </a> </td></tr> <tr class="#idxodd" valign=top> |
︙ | ︙ | |||
3707 3708 3709 3710 3711 3712 3713 | <td class="#idxleft" width="35%"><a name="key108"> TCLPARAM </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key7"> TDPL </a></td> <td class="#idxright" width="65%"> | | | 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 | <td class="#idxleft" width="35%"><a name="key108"> TCLPARAM </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key7"> TDPL </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key311"> temp file </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/fileutil/fileutil.html"> fileutil </a> </td></tr> <tr class="#idxeven" valign=top> |
︙ | ︙ | |||
3887 3888 3889 3890 3891 3892 3893 | <td class="#idxleft" width="35%"><a name="key688"> tokenization </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/string/token.html"> string::token </a> · <a href="tcllib/files/modules/string/token_shell.html"> string::token::shell </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key13"> top-down parsing languages </a></td> <td class="#idxright" width="65%"> | | | 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 | <td class="#idxleft" width="35%"><a name="key688"> tokenization </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/string/token.html"> string::token </a> · <a href="tcllib/files/modules/string/token_shell.html"> string::token::shell </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key13"> top-down parsing languages </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key386"> torrent </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/bee/bee.html"> bee </a> </td></tr> <tr class="#idxeven" valign=top> |
︙ | ︙ | |||
3912 3913 3914 3915 3916 3917 3918 | <td class="#idxleft" width="35%"><a name="key74"> trace </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/debug/debug.html"> debug </a> · <a href="tcllib/files/modules/debug/debug_caller.html"> debug::caller </a> · <a href="tcllib/files/modules/debug/debug_heartbeat.html"> debug::heartbeat </a> · <a href="tcllib/files/modules/debug/debug_timestamp.html"> debug::timestamp </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key12"> transducer </a></td> <td class="#idxright" width="65%"> | | | 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 | <td class="#idxleft" width="35%"><a name="key74"> trace </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/debug/debug.html"> debug </a> · <a href="tcllib/files/modules/debug/debug_caller.html"> debug::caller </a> · <a href="tcllib/files/modules/debug/debug_heartbeat.html"> debug::heartbeat </a> · <a href="tcllib/files/modules/debug/debug_timestamp.html"> debug::timestamp </a> </td></tr> <tr class="#idxodd" valign=top> <td class="#idxleft" width="35%"><a name="key12"> transducer </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/grammar_aycock/aycock.html"> grammar::aycock </a> · <a href="tcllib/files/modules/grammar_fa/fa.html"> grammar::fa </a> · <a href="tcllib/files/modules/grammar_fa/dacceptor.html"> grammar::fa::dacceptor </a> · <a href="tcllib/files/modules/grammar_fa/dexec.html"> grammar::fa::dexec </a> · <a href="tcllib/files/modules/grammar_fa/faop.html"> grammar::fa::op </a> · <a href="tcllib/files/modules/grammar_me/me_intro.html"> grammar::me_intro </a> · <a href="tcllib/files/modules/grammar_peg/peg.html"> grammar::peg </a> · <a href="tcllib/files/modules/grammar_peg/peg_interp.html"> grammar::peg::interp </a> · <a href="tcllib/files/apps/pt.html"> pt </a> · <a href="tcllib/files/modules/pt/pt_astree.html"> pt::ast </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html"> pt::cparam::configuration::critcl </a> · <a href="tcllib/files/modules/pt/pt_cparam_config_tea.html"> pt::cparam::configuration::tea </a> · <a href="tcllib/files/modules/pt/pt_json_language.html"> pt::json_language </a> · <a href="tcllib/files/modules/pt/pt_param.html"> pt::param </a> · <a href="tcllib/files/modules/pt/pt_pexpression.html"> pt::pe </a> · <a href="tcllib/files/modules/pt/pt_pexpr_op.html"> pt::pe::op </a> · <a href="tcllib/files/modules/pt/pt_pegrammar.html"> pt::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_container.html"> pt::peg::container </a> · <a href="tcllib/files/modules/pt/pt_peg_container_peg.html"> pt::peg::container::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_export.html"> pt::peg::export </a> · <a href="tcllib/files/modules/pt/pt_peg_export_container.html"> pt::peg::export::container </a> · <a href="tcllib/files/modules/pt/pt_peg_export_json.html"> pt::peg::export::json </a> · <a href="tcllib/files/modules/pt/pt_peg_export_peg.html"> pt::peg::export::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_from_container.html"> pt::peg::from::container </a> · <a href="tcllib/files/modules/pt/pt_peg_from_json.html"> pt::peg::from::json </a> · <a href="tcllib/files/modules/pt/pt_peg_from_peg.html"> pt::peg::from::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_import.html"> pt::peg::import </a> · <a href="tcllib/files/modules/pt/pt_peg_import_container.html"> pt::peg::import::container </a> · <a href="tcllib/files/modules/pt/pt_peg_import_json.html"> pt::peg::import::json </a> · <a href="tcllib/files/modules/pt/pt_peg_import_peg.html"> pt::peg::import::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_interp.html"> pt::peg::interp </a> · <a href="tcllib/files/modules/pt/pt_peg_to_container.html"> pt::peg::to::container </a> · <a href="tcllib/files/modules/pt/pt_peg_to_cparam.html"> pt::peg::to::cparam </a> · <a href="tcllib/files/modules/pt/pt_peg_to_json.html"> pt::peg::to::json </a> · <a href="tcllib/files/modules/pt/pt_peg_to_param.html"> pt::peg::to::param </a> · <a href="tcllib/files/modules/pt/pt_peg_to_peg.html"> pt::peg::to::peg </a> · <a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html"> pt::peg::to::tclparam </a> · <a href="tcllib/files/modules/pt/pt_peg_language.html"> pt::peg_language </a> · <a href="tcllib/files/modules/pt/pt_peg_introduction.html"> pt::pegrammar </a> · <a href="tcllib/files/modules/pt/pt_pgen.html"> pt::pgen </a> · <a href="tcllib/files/modules/pt/pt_rdengine.html"> pt::rde </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html"> pt::tclparam::configuration::snit </a> · <a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html"> pt::tclparam::configuration::tcloo </a> · <a href="tcllib/files/modules/pt/pt_util.html"> pt::util </a> · <a href="tcllib/files/modules/pt/pt_to_api.html"> pt_export_api </a> · <a href="tcllib/files/modules/pt/pt_from_api.html"> pt_import_api </a> · <a href="tcllib/files/modules/pt/pt_introduction.html"> pt_introduction </a> · <a href="tcllib/files/modules/pt/pt_parse_peg.html"> pt_parse_peg </a> · <a href="tcllib/files/modules/pt/pt_parser_api.html"> pt_parser_api </a> · <a href="tcllib/files/modules/pt/pt_peg_op.html"> pt_peg_op </a> </td></tr> <tr class="#idxeven" valign=top> <td class="#idxleft" width="35%"><a name="key62"> transfer </a></td> <td class="#idxright" width="65%"> <a href="tcllib/files/modules/transfer/connect.html"> transfer::connect </a> · <a href="tcllib/files/modules/transfer/copyops.html"> transfer::copy </a> · <a href="tcllib/files/modules/transfer/tqueue.html"> transfer::copy::queue </a> · <a href="tcllib/files/modules/transfer/ddest.html"> transfer::data::destination </a> · <a href="tcllib/files/modules/transfer/dsource.html"> transfer::data::source </a> · <a href="tcllib/files/modules/transfer/receiver.html"> transfer::receiver </a> · <a href="tcllib/files/modules/transfer/transmitter.html"> transfer::transmitter </a> </td></tr> <tr class="#idxodd" valign=top> |
︙ | ︙ |
Added embedded/www/tcllib/files/modules/pt/pt_cparam_config_tea.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | <html><head> <title>pt::cparam::configuration::tea - Parser Tools</title> <style type="text/css"><!-- HTML { background: #FFFFFF; color: black; } BODY { background: #FFFFFF; color: black; } DIV.doctools { margin-left: 10%; margin-right: 10%; } DIV.doctools H1,DIV.doctools H2 { margin-left: -5%; } H1, H2, H3, H4 { margin-top: 1em; font-family: sans-serif; font-size: large; color: #005A9C; background: transparent; text-align: left; } H1.title { text-align: center; } UL,OL { margin-right: 0em; margin-top: 3pt; margin-bottom: 3pt; } UL LI { list-style: disc; } OL LI { list-style: decimal; } DT { padding-top: 1ex; } UL.toc,UL.toc UL, UL.toc UL UL { font: normal 12pt/14pt sans-serif; list-style: none; } LI.section, LI.subsection { list-style: none; margin-left: 0em; text-indent: 0em; padding: 0em; } PRE { display: block; font-family: monospace; white-space: pre; margin: 0%; padding-top: 0.5ex; padding-bottom: 0.5ex; padding-left: 1ex; padding-right: 1ex; width: 100%; } PRE.example { color: black; background: #f5dcb3; border: 1px solid black; } UL.requirements LI, UL.syntax LI { list-style: none; margin-left: 0em; text-indent: 0em; padding: 0em; } DIV.synopsis { color: black; background: #80ffff; border: 1px solid black; font-family: serif; margin-top: 1em; margin-bottom: 1em; } UL.syntax { margin-top: 1em; border-top: 1px solid black; } UL.requirements { margin-bottom: 1em; border-bottom: 1px solid black; } --></style> </head> <! -- Generated from file 'pt_cparam_config_tea.man' by tcllib/doctools with format 'html' --> <! -- Copyright © 2009 Andreas Kupries <[email protected]> --> <! -- CVS: $Id$ pt::cparam::configuration::tea.n --> <body><div class="doctools"> <hr> [ <a href="../../../../../../../../home">Tcllib Home</a> | <a href="../../../../toc.html">Main Table Of Contents</a> | <a href="../../../toc.html">Table Of Contents</a> | <a href="../../../../index.html">Keyword Index</a> | <a href="../../../../toc0.html">Categories</a> | <a href="../../../../toc1.html">Modules</a> | <a href="../../../../toc2.html">Applications</a> ] <hr> <h1 class="title">pt::cparam::configuration::tea(n) 0.1 tcllib "Parser Tools"</h1> <div id="name" class="section"><h2><a name="name">Name</a></h2> <p>pt::cparam::configuration::tea - C/PARAM, Canned configuration, TEA</p> </div> <div id="toc" class="section"><h2><a name="toc">Table Of Contents</a></h2> <ul class="toc"> <li class="section"><a href="#toc">Table Of Contents</a></li> <li class="section"><a href="#synopsis">Synopsis</a></li> <li class="section"><a href="#section1">Description</a></li> <li class="section"><a href="#section2">API</a></li> <li class="section"><a href="#section3">Bugs, Ideas, Feedback</a></li> <li class="section"><a href="#keywords">Keywords</a></li> <li class="section"><a href="#category">Category</a></li> <li class="section"><a href="#copyright">Copyright</a></li> </ul> </div> <div id="synopsis" class="section"><h2><a name="synopsis">Synopsis</a></h2> <div class="synopsis"> <ul class="requirements"> <li>package require <b class="pkgname">Tcl 8.5</b></li> <li>package require <b class="pkgname">pt::cparam::configuration::tea <span class="opt">?0.1?</span></b></li> </ul> <ul class="syntax"> <li><a href="#1"><b class="cmd">::pt::cparam::configuration::tea</b> <b class="method">def</b> <i class="arg">name</i> <i class="arg">pkg</i> <i class="arg">version</i> <i class="arg">cmdprefix</i></a></li> </ul> </div> </div> <div id="section1" class="section"><h2><a name="section1">Description</a></h2> <p>Are you lost ? Do you have trouble understanding this document ? In that case please read the overview provided by the <i class="term"><a href="pt_introduction.html">Introduction to Parser Tools</a></i>. This document is the entrypoint to the whole system the current package is a part of.</p> <p>This package is an adjunct to <b class="package"><a href="pt_peg_to_cparam.html">pt::peg::to::cparam</a></b>, to make the use of this highly configurable package easier by providing a canned configuration. When applied this configuration causes the package <b class="package"><a href="pt_peg_to_cparam.html">pt::peg::to::cparam</a></b> to generate plain parser code ready for inclusion into a <i class="term">TEA</i>-based C extension.</p> <p>It is a supporting package in the Core Layer of Parser Tools.</p> <p><img alt="arch_core_support" src="../../../../image/arch_core_support.png"></p> </div> <div id="section2" class="section"><h2><a name="section2">API</a></h2> <dl class="definitions"> <dt><a name="1"><b class="cmd">::pt::cparam::configuration::tea</b> <b class="method">def</b> <i class="arg">name</i> <i class="arg">pkg</i> <i class="arg">version</i> <i class="arg">cmdprefix</i></a></dt> <dd><p>The command applies the configuration provided by this package to the <i class="arg">cmdprefix</i>, causing the creation of <b class="package">tea</b>-based parsers whose class is <i class="arg">name</i>, in package <i class="arg">pkg</i> with <i class="arg">version</i>.</p> <p>The use of a command prefix as API allows application of the configuration to not only <b class="package"><a href="pt_peg_to_cparam.html">pt::peg::to::cparam</a></b> (<b class="cmd">pt::peg::to::cparam configure</b>), but also export manager instances and PEG containers (<b class="cmd">$export configuration set</b> and <b class="cmd">[$container exporter] configuration set</b> respectively).</p> <p>Or anything other command prefix accepting two arguments, option and value.</p></dd> </dl> </div> <div id="section3" class="section"><h2><a name="section3">Bugs, Ideas, Feedback</a></h2> <p>This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category <em>pt</em> of the <a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>. Please also report any ideas for enhancements you may have for either package and/or documentation.</p> </div> <div id="keywords" class="section"><h2><a name="keywords">Keywords</a></h2> <p><a href="../../../../index.html#key3">EBNF</a>, <a href="../../../../index.html#key15">LL(k)</a>, <a href="../../../../index.html#key6">PEG</a>, <a href="../../../../index.html#key7">TDPL</a>, <a href="../../../../index.html#key4">context-free languages</a>, <a href="../../../../index.html#key0">expression</a>, <a href="../../../../index.html#key11">grammar</a>, <a href="../../../../index.html#key5">matching</a>, <a href="../../../../index.html#key9">parser</a>, <a href="../../../../index.html#key8">parsing expression</a>, <a href="../../../../index.html#key14">parsing expression grammar</a>, <a href="../../../../index.html#key1">push down automaton</a>, <a href="../../../../index.html#key10">recursive descent</a>, <a href="../../../../index.html#key2">state</a>, <a href="../../../../index.html#key13">top-down parsing languages</a>, <a href="../../../../index.html#key12">transducer</a></p> </div> <div id="category" class="section"><h2><a name="category">Category</a></h2> <p>Parsing and Grammars</p> </div> <div id="copyright" class="section"><h2><a name="copyright">Copyright</a></h2> <p>Copyright © 2009 Andreas Kupries <[email protected]></p> </div> </div></body></html> |
Changes to embedded/www/tcllib/toc.html.
︙ | ︙ | |||
913 914 915 916 917 918 919 920 921 922 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_cparam_config_tea.html">pt::cparam::configuration::tea</a></td> <td class="#tocright">C/PARAM, Canned configuration, TEA</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_param.html">pt::param</a></td> <td class="#tocright">PackRat Machine Specification</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_pexpression.html">pt::pe</a></td> <td class="#tocright">Parsing Expression Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_pexpr_op.html">pt::pe::op</a></td> <td class="#tocright">Parsing Expression Utilities</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_pegrammar.html">pt::peg</a></td> <td class="#tocright">Parsing Expression Grammar Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_container.html">pt::peg::container</a></td> <td class="#tocright">PEG Storage</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_container_peg.html">pt::peg::container::peg</a></td> <td class="#tocright">PEG Storage. Canned PEG grammar specification</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_export.html">pt::peg::export</a></td> <td class="#tocright">PEG Export</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_export_container.html">pt::peg::export::container</a></td> <td class="#tocright">PEG Export Plugin. Write CONTAINER format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_export_json.html">pt::peg::export::json</a></td> <td class="#tocright">PEG Export Plugin. Write JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_export_peg.html">pt::peg::export::peg</a></td> <td class="#tocright">PEG Export Plugin. Write PEG format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_from_container.html">pt::peg::from::container</a></td> <td class="#tocright">PEG Conversion. From CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_from_json.html">pt::peg::from::json</a></td> <td class="#tocright">PEG Conversion. Read JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_from_peg.html">pt::peg::from::peg</a></td> <td class="#tocright">PEG Conversion. Read PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_import.html">pt::peg::import</a></td> <td class="#tocright">PEG Import</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_import_container.html">pt::peg::import::container</a></td> <td class="#tocright">PEG Import Plugin. From CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_import_json.html">pt::peg::import::json</a></td> <td class="#tocright">PEG Import Plugin. Read JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_import_peg.html">pt::peg::import::peg</a></td> <td class="#tocright">PEG Import Plugin. Read PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_interp.html">pt::peg::interp</a></td> <td class="#tocright">Interpreter for parsing expression grammars</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_to_container.html">pt::peg::to::container</a></td> <td class="#tocright">PEG Conversion. Write CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_to_cparam.html">pt::peg::to::cparam</a></td> <td class="#tocright">PEG Conversion. Write CPARAM format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_to_json.html">pt::peg::to::json</a></td> <td class="#tocright">PEG Conversion. Write JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_to_param.html">pt::peg::to::param</a></td> <td class="#tocright">PEG Conversion. Write PARAM format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_to_peg.html">pt::peg::to::peg</a></td> <td class="#tocright">PEG Conversion. Write PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_to_tclparam.html">pt::peg::to::tclparam</a></td> <td class="#tocright">PEG Conversion. Write TCLPARAM format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_language.html">pt::peg_language</a></td> <td class="#tocright">PEG Language Tutorial</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_introduction.html">pt::pegrammar</a></td> <td class="#tocright">Introduction to Parsing Expression Grammars</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_pgen.html">pt::pgen</a></td> <td class="#tocright">Parser Generator</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_rdengine.html">pt::rde</a></td> <td class="#tocright">Parsing Runtime Support, PARAM based</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_tclparam_config_snit.html">pt::tclparam::configuration::snit</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Snit</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_tclparam_config_tcloo.html">pt::tclparam::configuration::tcloo</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Tcloo</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_util.html">pt::util</a></td> <td class="#tocright">General utilities</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_to_api.html">pt_export_api</a></td> <td class="#tocright">Parser Tools Export API</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_from_api.html">pt_import_api</a></td> <td class="#tocright">Parser Tools Import API</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_introduction.html">pt_introduction</a></td> <td class="#tocright">Introduction to Parser Tools</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_parse_peg.html">pt_parse_peg</a></td> <td class="#tocright">Parser Tools PEG Parser</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/pt/pt_parser_api.html">pt_parser_api</a></td> <td class="#tocright">Parser API</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/pt/pt_peg_op.html">pt_peg_op</a></td> <td class="#tocright">Parser Tools PE Grammar Utility Operations</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/rc4/rc4.html">rc4</a></td> <td class="#tocright">Implementation of the RC4 stream cipher</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/rcs/rcs.html">rcs</a></td> <td class="#tocright">RCS low level utilities</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/report/report.html">report</a></td> <td class="#tocright">Create and manipulate report objects</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/rest/rest.html">rest</a></td> <td class="#tocright">define REST web APIs and call them inline or asychronously</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/ripemd/ripemd128.html">ripemd128</a></td> <td class="#tocright">RIPEMD-128 Message-Digest Algorithm</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/ripemd/ripemd160.html">ripemd160</a></td> <td class="#tocright">RIPEMD-160 Message-Digest Algorithm</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/amazon-s3/S3.html">S3</a></td> <td class="#tocright">Amazon S3 Web Service Interface</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/sasl/sasl.html">SASL</a></td> <td class="#tocright">Implementation of SASL mechanisms for Tcl</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/sasl/ntlm.html">SASL::NTLM</a></td> <td class="#tocright">Implementation of SASL NTLM mechanism for Tcl</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/sasl/scram.html">SASL::SCRAM</a></td> <td class="#tocright">Implementation of SASL SCRAM mechanism for Tcl</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/sasl/gtoken.html">SASL::XGoogleToken</a></td> <td class="#tocright">Implementation of SASL NTLM mechanism for Tcl</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/sha1/sha1.html">sha1</a></td> <td class="#tocright">SHA1 Message-Digest Algorithm</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/sha1/sha256.html">sha256</a></td> <td class="#tocright">SHA256 Message-Digest Algorithm</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/simulation/annealing.html">simulation::annealing</a></td> <td class="#tocright">Simulated annealing</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/simulation/montecarlo.html">simulation::montecarlo</a></td> <td class="#tocright">Monte Carlo simulations</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/simulation/simulation_random.html">simulation::random</a></td> <td class="#tocright">Pseudo-random number generators</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/mime/smtp.html">smtp</a></td> <td class="#tocright">Client-side tcl implementation of the smtp protocol</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/smtpd/smtpd.html">smtpd</a></td> <td class="#tocright">Tcl SMTP server implementation</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/snit/snit.html">snit</a></td> <td class="#tocright">Snit's Not Incr Tcl</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/snit/snitfaq.html">snitfaq</a></td> <td class="#tocright">Snit Frequently Asked Questions</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/soundex/soundex.html">soundex</a></td> <td class="#tocright">Soundex</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/stooop/stooop.html">stooop</a></td> <td class="#tocright">Object oriented extension.</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/string/token.html">string::token</a></td> <td class="#tocright">Regex based iterative lexing</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/string/token_shell.html">string::token::shell</a></td> <td class="#tocright">Parsing of shell command line</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/stringprep/stringprep.html">stringprep</a></td> <td class="#tocright">Implementation of stringprep</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/stringprep/stringprep_data.html">stringprep::data</a></td> <td class="#tocright">stringprep data tables, generated, internal</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/struct/disjointset.html">struct::disjointset</a></td> <td class="#tocright">Disjoint set data structure</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/struct/graph.html">struct::graph</a></td> <td class="#tocright">Create and manipulate directed graph objects</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/struct/graphops.html">struct::graph::op</a></td> <td class="#tocright">Operation for (un)directed graph objects</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/struct/graph1.html">struct::graph_v1</a></td> <td class="#tocright">Create and manipulate directed graph objects</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/struct/struct_list.html">struct::list</a></td> <td class="#tocright">Procedures for manipulating lists</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/struct/matrix.html">struct::matrix</a></td> <td class="#tocright">Create and manipulate matrix objects</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/struct/matrix1.html">struct::matrix_v1</a></td> <td class="#tocright">Create and manipulate matrix objects</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/struct/pool.html">struct::pool</a></td> <td class="#tocright">Create and manipulate pool objects (of discrete items)</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/struct/prioqueue.html">struct::prioqueue</a></td> <td class="#tocright">Create and manipulate prioqueue objects</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/struct/queue.html">struct::queue</a></td> <td class="#tocright">Create and manipulate queue objects</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/struct/record.html">struct::record</a></td> <td class="#tocright">Define and create records (similar to 'C' structures)</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/struct/struct_set.html">struct::set</a></td> <td class="#tocright">Procedures for manipulating sets</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/struct/skiplist.html">struct::skiplist</a></td> <td class="#tocright">Create and manipulate skiplists</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/struct/stack.html">struct::stack</a></td> <td class="#tocright">Create and manipulate stack objects</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/struct/struct_tree.html">struct::tree</a></td> <td class="#tocright">Create and manipulate tree objects</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/struct/struct_tree1.html">struct::tree_v1</a></td> <td class="#tocright">Create and manipulate tree objects</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/crc/sum.html">sum</a></td> <td class="#tocright">Calculate a sum(1) compatible checksum</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/stooop/switched.html">switched</a></td> <td class="#tocright">switch/option management.</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/tar/tar.html">tar</a></td> <td class="#tocright">Tar file creation, extraction & manipulation</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/cat.html">tcl::chan::cat</a></td> <td class="#tocright">Concatenation channel</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_core/core.html">tcl::chan::core</a></td> <td class="#tocright">Basic reflected/virtual channel support</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_core/events.html">tcl::chan::events</a></td> <td class="#tocright">Event support for reflected/virtual channels</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/facade.html">tcl::chan::facade</a></td> <td class="#tocright">Facade channel</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/tcllib_fifo.html">tcl::chan::fifo</a></td> <td class="#tocright">In-memory fifo channel</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/tcllib_fifo2.html">tcl::chan::fifo2</a></td> <td class="#tocright">In-memory interconnected fifo channels</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/halfpipe.html">tcl::chan::halfpipe</a></td> <td class="#tocright">In-memory channel, half of a fifo2</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/tcllib_memchan.html">tcl::chan::memchan</a></td> <td class="#tocright">In-memory channel</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/tcllib_null.html">tcl::chan::null</a></td> <td class="#tocright">Null channel</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/nullzero.html">tcl::chan::nullzero</a></td> <td class="#tocright">Null/Zero channel combination</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/tcllib_random.html">tcl::chan::random</a></td> <td class="#tocright">Random channel</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/std.html">tcl::chan::std</a></td> <td class="#tocright">Standard I/O, unification of stdin and stdout</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/tcllib_string.html">tcl::chan::string</a></td> <td class="#tocright">Read-only in-memory channel</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/textwindow.html">tcl::chan::textwindow</a></td> <td class="#tocright">Textwindow channel</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/tcllib_variable.html">tcl::chan::variable</a></td> <td class="#tocright">In-memory channel using variable for storage</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/tcllib_zero.html">tcl::chan::zero</a></td> <td class="#tocright">Zero channel</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_base/randseed.html">tcl::randomseed</a></td> <td class="#tocright">Utilities for random channels</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/adler32.html">tcl::transform::adler32</a></td> <td class="#tocright">Adler32 transformation</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/vt_base64.html">tcl::transform::base64</a></td> <td class="#tocright">Base64 encoding transformation</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_core/transformcore.html">tcl::transform::core</a></td> <td class="#tocright">Basic reflected/virtual channel transform support</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/vt_counter.html">tcl::transform::counter</a></td> <td class="#tocright">Counter transformation</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/vt_crc32.html">tcl::transform::crc32</a></td> <td class="#tocright">Crc32 transformation</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/hex.html">tcl::transform::hex</a></td> <td class="#tocright">Hexadecimal encoding transformation</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/identity.html">tcl::transform::identity</a></td> <td class="#tocright">Identity transformation</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/limitsize.html">tcl::transform::limitsize</a></td> <td class="#tocright">limiting input</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/observe.html">tcl::transform::observe</a></td> <td class="#tocright">Observer transformation, stream copy</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/vt_otp.html">tcl::transform::otp</a></td> <td class="#tocright">Encryption via one-time pad</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/rot.html">tcl::transform::rot</a></td> <td class="#tocright">rot-encryption</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/spacer.html">tcl::transform::spacer</a></td> <td class="#tocright">Space insertation and removal</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/virtchannel_transform/tcllib_zlib.html">tcl::transform::zlib</a></td> <td class="#tocright">zlib (de)compression</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/des/tcldesjr.html">tcldes</a></td> <td class="#tocright">Implementation of the DES and triple-DES ciphers</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/des/tcldes.html">tcldes</a></td> <td class="#tocright">Implementation of the DES and triple-DES ciphers</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/apps/tcldocstrip.html">tcldocstrip</a></td> <td class="#tocright">Tcl-based Docstrip Processor</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/dns/tcllib_ip.html">tcllib_ip</a></td> <td class="#tocright">IPv4 and IPv6 address manipulation</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/math/machineparameters.html">tclrep/machineparameters</a></td> <td class="#tocright">Compute double precision machine parameters.</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/tepam/tepam_introduction.html">tepam</a></td> <td class="#tocright">An introduction into TEPAM, Tcl's Enhanced Procedure and Argument Manager</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/tepam/tepam_argument_dialogbox.html">tepam::argument_dialogbox</a></td> <td class="#tocright">TEPAM argument_dialogbox, reference manual</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/tepam/tepam_doc_gen.html">tepam::doc_gen</a></td> <td class="#tocright">TEPAM DOC Generation, reference manual</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/tepam/tepam_procedure.html">tepam::procedure</a></td> <td class="#tocright">TEPAM procedure, reference manual</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/term/term.html">term</a></td> <td class="#tocright">General terminal control</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/term/ansi_code.html">term::ansi::code</a></td> <td class="#tocright">Helper for control sequences</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/term/ansi_cattr.html">term::ansi::code::attr</a></td> <td class="#tocright">ANSI attribute sequences</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/term/ansi_cctrl.html">term::ansi::code::ctrl</a></td> <td class="#tocright">ANSI control sequences</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/term/ansi_cmacros.html">term::ansi::code::macros</a></td> <td class="#tocright">Macro sequences</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/term/ansi_ctrlu.html">term::ansi::ctrl::unix</a></td> <td class="#tocright">Control operations and queries</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/term/ansi_send.html">term::ansi::send</a></td> <td class="#tocright">Output of ANSI control sequences to terminals</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/term/imenu.html">term::interact::menu</a></td> <td class="#tocright">Terminal widget, menu</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/term/ipager.html">term::interact::pager</a></td> <td class="#tocright">Terminal widget, paging</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/term/receive.html">term::receive</a></td> <td class="#tocright">General input from terminals</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/term/term_bind.html">term::receive::bind</a></td> <td class="#tocright">Keyboard dispatch from terminals</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/term/term_send.html">term::send</a></td> <td class="#tocright">General output to terminals</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/textutil/textutil.html">textutil</a></td> <td class="#tocright">Procedures to manipulate texts and strings.</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/textutil/adjust.html">textutil::adjust</a></td> <td class="#tocright">Procedures to adjust, indent, and undent paragraphs</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/textutil/expander.html">textutil::expander</a></td> <td class="#tocright">Procedures to process templates and expand text.</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/textutil/repeat.html">textutil::repeat</a></td> <td class="#tocright">Procedures to repeat strings.</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/textutil/textutil_split.html">textutil::split</a></td> <td class="#tocright">Procedures to split texts</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/textutil/textutil_string.html">textutil::string</a></td> <td class="#tocright">Procedures to manipulate texts and strings.</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/textutil/tabify.html">textutil::tabify</a></td> <td class="#tocright">Procedures to (un)tabify strings</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/textutil/trim.html">textutil::trim</a></td> <td class="#tocright">Procedures to trim strings</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/tie/tie_std.html">tie</a></td> <td class="#tocright">Array persistence, standard data sources</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/tie/tie.html">tie</a></td> <td class="#tocright">Array persistence</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/tiff/tiff.html">tiff</a></td> <td class="#tocright">TIFF reading, writing, and querying and manipulation of meta data</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/transfer/connect.html">transfer::connect</a></td> <td class="#tocright">Connection setup</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/transfer/copyops.html">transfer::copy</a></td> <td class="#tocright">Data transfer foundation</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/transfer/tqueue.html">transfer::copy::queue</a></td> <td class="#tocright">Queued transfers</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/transfer/ddest.html">transfer::data::destination</a></td> <td class="#tocright">Data destination</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/transfer/dsource.html">transfer::data::source</a></td> <td class="#tocright">Data source</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/transfer/receiver.html">transfer::receiver</a></td> <td class="#tocright">Data source</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/transfer/transmitter.html">transfer::transmitter</a></td> <td class="#tocright">Data source</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/treeql/treeql.html">treeql</a></td> <td class="#tocright">Query tree objects</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/try/tcllib_try.html">try</a></td> <td class="#tocright">try - Trap and process errors and exceptions</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/uev/uevent.html">uevent</a></td> <td class="#tocright">User events</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/uev/uevent_onidle.html">uevent::onidle</a></td> <td class="#tocright">Request merging and deferal to idle time</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/stringprep/unicode.html">unicode</a></td> <td class="#tocright">Implementation of Unicode normalization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/stringprep/unicode_data.html">unicode::data</a></td> <td class="#tocright">unicode data tables, generated, internal</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/units/units.html">units</a></td> <td class="#tocright">unit conversion</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/uri/uri.html">uri</a></td> <td class="#tocright">URI utilities</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/uri/urn-scheme.html">uri_urn</a></td> <td class="#tocright">URI utilities, URN scheme</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/base64/uuencode.html">uuencode</a></td> <td class="#tocright">UU-encode/decode binary data</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/uuid/uuid.html">uuid</a></td> <td class="#tocright">UUID generation and comparison</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/valtype/valtype_common.html">valtype::common</a></td> <td class="#tocright">Validation, common code</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/valtype/cc_amex.html">valtype::creditcard::amex</a></td> <td class="#tocright">Validation for AMEX creditcard number</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/valtype/cc_discover.html">valtype::creditcard::discover</a></td> <td class="#tocright">Validation for Discover creditcard number</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/valtype/cc_mastercard.html">valtype::creditcard::mastercard</a></td> <td class="#tocright">Validation for Mastercard creditcard number</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/valtype/cc_visa.html">valtype::creditcard::visa</a></td> <td class="#tocright">Validation for VISA creditcard number</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/valtype/ean13.html">valtype::gs1::ean13</a></td> <td class="#tocright">Validation for EAN13</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/valtype/iban.html">valtype::iban</a></td> <td class="#tocright">Validation for IBAN</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/valtype/imei.html">valtype::imei</a></td> <td class="#tocright">Validation for IMEI</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/valtype/isbn.html">valtype::isbn</a></td> <td class="#tocright">Validation for ISBN</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/valtype/luhn.html">valtype::luhn</a></td> <td class="#tocright">Validation for plain number with a LUHN checkdigit</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/valtype/luhn5.html">valtype::luhn5</a></td> <td class="#tocright">Validation for plain number with a LUHN5 checkdigit</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/valtype/usnpi.html">valtype::usnpi</a></td> <td class="#tocright">Validation for USNPI</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/valtype/verhoeff.html">valtype::verhoeff</a></td> <td class="#tocright">Validation for plain number with a VERHOEFF checkdigit</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/websocket/websocket.html">websocket</a></td> <td class="#tocright">Tcl implementation of the websocket protocol</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/wip/wip.html">wip</a></td> <td class="#tocright">Word Interpreter</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/amazon-s3/xsxp.html">xsxp</a></td> <td class="#tocright">eXtremely Simple Xml Parser</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/yaml/yaml.html">yaml</a></td> <td class="#tocright">YAML Format Encoder/Decoder</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/base64/yencode.html">yencode</a></td> <td class="#tocright">Y-encode/decode binary data</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="files/modules/zip/decode.html">zipfile::decode</a></td> <td class="#tocright">Access to zip archives</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="files/modules/zip/encode.html">zipfile::encode</a></td> <td class="#tocright">Generation of zip archives</td> </tr> </table> </dl><hr></body></html> |
Changes to embedded/www/toc.html.
︙ | ︙ | |||
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_tea.html">pt::cparam::configuration::tea</a></td> <td class="#tocright">C/PARAM, Canned configuration, TEA</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_param.html">pt::param</a></td> <td class="#tocright">PackRat Machine Specification</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pexpression.html">pt::pe</a></td> <td class="#tocright">Parsing Expression Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pexpr_op.html">pt::pe::op</a></td> <td class="#tocright">Parsing Expression Utilities</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pegrammar.html">pt::peg</a></td> <td class="#tocright">Parsing Expression Grammar Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_container.html">pt::peg::container</a></td> <td class="#tocright">PEG Storage</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_container_peg.html">pt::peg::container::peg</a></td> <td class="#tocright">PEG Storage. Canned PEG grammar specification</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export.html">pt::peg::export</a></td> <td class="#tocright">PEG Export</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_container.html">pt::peg::export::container</a></td> <td class="#tocright">PEG Export Plugin. Write CONTAINER format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_json.html">pt::peg::export::json</a></td> <td class="#tocright">PEG Export Plugin. Write JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_peg.html">pt::peg::export::peg</a></td> <td class="#tocright">PEG Export Plugin. Write PEG format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_container.html">pt::peg::from::container</a></td> <td class="#tocright">PEG Conversion. From CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_json.html">pt::peg::from::json</a></td> <td class="#tocright">PEG Conversion. Read JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_peg.html">pt::peg::from::peg</a></td> <td class="#tocright">PEG Conversion. Read PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import.html">pt::peg::import</a></td> <td class="#tocright">PEG Import</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_container.html">pt::peg::import::container</a></td> <td class="#tocright">PEG Import Plugin. From CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_json.html">pt::peg::import::json</a></td> <td class="#tocright">PEG Import Plugin. Read JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_peg.html">pt::peg::import::peg</a></td> <td class="#tocright">PEG Import Plugin. Read PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_interp.html">pt::peg::interp</a></td> <td class="#tocright">Interpreter for parsing expression grammars</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_container.html">pt::peg::to::container</a></td> <td class="#tocright">PEG Conversion. Write CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_cparam.html">pt::peg::to::cparam</a></td> <td class="#tocright">PEG Conversion. Write CPARAM format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_json.html">pt::peg::to::json</a></td> <td class="#tocright">PEG Conversion. Write JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_param.html">pt::peg::to::param</a></td> <td class="#tocright">PEG Conversion. Write PARAM format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_peg.html">pt::peg::to::peg</a></td> <td class="#tocright">PEG Conversion. Write PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html">pt::peg::to::tclparam</a></td> <td class="#tocright">PEG Conversion. Write TCLPARAM format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_language.html">pt::peg_language</a></td> <td class="#tocright">PEG Language Tutorial</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_introduction.html">pt::pegrammar</a></td> <td class="#tocright">Introduction to Parsing Expression Grammars</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pgen.html">pt::pgen</a></td> <td class="#tocright">Parser Generator</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_rdengine.html">pt::rde</a></td> <td class="#tocright">Parsing Runtime Support, PARAM based</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html">pt::tclparam::configuration::snit</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Snit</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html">pt::tclparam::configuration::tcloo</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Tcloo</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_util.html">pt::util</a></td> <td class="#tocright">General utilities</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_to_api.html">pt_export_api</a></td> <td class="#tocright">Parser Tools Export API</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_from_api.html">pt_import_api</a></td> <td class="#tocright">Parser Tools Import API</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_introduction.html">pt_introduction</a></td> <td class="#tocright">Introduction to Parser Tools</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_parse_peg.html">pt_parse_peg</a></td> <td class="#tocright">Parser Tools PEG Parser</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_parser_api.html">pt_parser_api</a></td> <td class="#tocright">Parser API</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_op.html">pt_peg_op</a></td> <td class="#tocright">Parser Tools PE Grammar Utility Operations</td> </tr> </table></dl> <dl><dt>Procedures, arguments, parameters, options<dd> <table class="#toc"> <tr class="#toceven" > |
︙ | ︙ | |||
2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_tea.html">pt::cparam::configuration::tea</a></td> <td class="#tocright">C/PARAM, Canned configuration, TEA</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_param.html">pt::param</a></td> <td class="#tocright">PackRat Machine Specification</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pexpression.html">pt::pe</a></td> <td class="#tocright">Parsing Expression Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pexpr_op.html">pt::pe::op</a></td> <td class="#tocright">Parsing Expression Utilities</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pegrammar.html">pt::peg</a></td> <td class="#tocright">Parsing Expression Grammar Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_container.html">pt::peg::container</a></td> <td class="#tocright">PEG Storage</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_container_peg.html">pt::peg::container::peg</a></td> <td class="#tocright">PEG Storage. Canned PEG grammar specification</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export.html">pt::peg::export</a></td> <td class="#tocright">PEG Export</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_container.html">pt::peg::export::container</a></td> <td class="#tocright">PEG Export Plugin. Write CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_json.html">pt::peg::export::json</a></td> <td class="#tocright">PEG Export Plugin. Write JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_peg.html">pt::peg::export::peg</a></td> <td class="#tocright">PEG Export Plugin. Write PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_container.html">pt::peg::from::container</a></td> <td class="#tocright">PEG Conversion. From CONTAINER format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_json.html">pt::peg::from::json</a></td> <td class="#tocright">PEG Conversion. Read JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_peg.html">pt::peg::from::peg</a></td> <td class="#tocright">PEG Conversion. Read PEG format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import.html">pt::peg::import</a></td> <td class="#tocright">PEG Import</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_container.html">pt::peg::import::container</a></td> <td class="#tocright">PEG Import Plugin. From CONTAINER format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_json.html">pt::peg::import::json</a></td> <td class="#tocright">PEG Import Plugin. Read JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_peg.html">pt::peg::import::peg</a></td> <td class="#tocright">PEG Import Plugin. Read PEG format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_interp.html">pt::peg::interp</a></td> <td class="#tocright">Interpreter for parsing expression grammars</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_container.html">pt::peg::to::container</a></td> <td class="#tocright">PEG Conversion. Write CONTAINER format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_cparam.html">pt::peg::to::cparam</a></td> <td class="#tocright">PEG Conversion. Write CPARAM format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_json.html">pt::peg::to::json</a></td> <td class="#tocright">PEG Conversion. Write JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_param.html">pt::peg::to::param</a></td> <td class="#tocright">PEG Conversion. Write PARAM format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_peg.html">pt::peg::to::peg</a></td> <td class="#tocright">PEG Conversion. Write PEG format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html">pt::peg::to::tclparam</a></td> <td class="#tocright">PEG Conversion. Write TCLPARAM format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_language.html">pt::peg_language</a></td> <td class="#tocright">PEG Language Tutorial</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_introduction.html">pt::pegrammar</a></td> <td class="#tocright">Introduction to Parsing Expression Grammars</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pgen.html">pt::pgen</a></td> <td class="#tocright">Parser Generator</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_rdengine.html">pt::rde</a></td> <td class="#tocright">Parsing Runtime Support, PARAM based</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html">pt::tclparam::configuration::snit</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Snit</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html">pt::tclparam::configuration::tcloo</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Tcloo</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_util.html">pt::util</a></td> <td class="#tocright">General utilities</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_to_api.html">pt_export_api</a></td> <td class="#tocright">Parser Tools Export API</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_from_api.html">pt_import_api</a></td> <td class="#tocright">Parser Tools Import API</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_introduction.html">pt_introduction</a></td> <td class="#tocright">Introduction to Parser Tools</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_parse_peg.html">pt_parse_peg</a></td> <td class="#tocright">Parser Tools PEG Parser</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_parser_api.html">pt_parser_api</a></td> <td class="#tocright">Parser API</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_op.html">pt_peg_op</a></td> <td class="#tocright">Parser Tools PE Grammar Utility Operations</td> </tr> </table></dl> <dl><dt>rc4<dd> <table class="#toc"> <tr class="#toceven" > |
︙ | ︙ |
Changes to embedded/www/toc0.html.
︙ | ︙ | |||
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_tea.html">pt::cparam::configuration::tea</a></td> <td class="#tocright">C/PARAM, Canned configuration, TEA</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_param.html">pt::param</a></td> <td class="#tocright">PackRat Machine Specification</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pexpression.html">pt::pe</a></td> <td class="#tocright">Parsing Expression Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pexpr_op.html">pt::pe::op</a></td> <td class="#tocright">Parsing Expression Utilities</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pegrammar.html">pt::peg</a></td> <td class="#tocright">Parsing Expression Grammar Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_container.html">pt::peg::container</a></td> <td class="#tocright">PEG Storage</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_container_peg.html">pt::peg::container::peg</a></td> <td class="#tocright">PEG Storage. Canned PEG grammar specification</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export.html">pt::peg::export</a></td> <td class="#tocright">PEG Export</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_container.html">pt::peg::export::container</a></td> <td class="#tocright">PEG Export Plugin. Write CONTAINER format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_json.html">pt::peg::export::json</a></td> <td class="#tocright">PEG Export Plugin. Write JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_peg.html">pt::peg::export::peg</a></td> <td class="#tocright">PEG Export Plugin. Write PEG format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_container.html">pt::peg::from::container</a></td> <td class="#tocright">PEG Conversion. From CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_json.html">pt::peg::from::json</a></td> <td class="#tocright">PEG Conversion. Read JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_peg.html">pt::peg::from::peg</a></td> <td class="#tocright">PEG Conversion. Read PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import.html">pt::peg::import</a></td> <td class="#tocright">PEG Import</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_container.html">pt::peg::import::container</a></td> <td class="#tocright">PEG Import Plugin. From CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_json.html">pt::peg::import::json</a></td> <td class="#tocright">PEG Import Plugin. Read JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_peg.html">pt::peg::import::peg</a></td> <td class="#tocright">PEG Import Plugin. Read PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_interp.html">pt::peg::interp</a></td> <td class="#tocright">Interpreter for parsing expression grammars</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_container.html">pt::peg::to::container</a></td> <td class="#tocright">PEG Conversion. Write CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_cparam.html">pt::peg::to::cparam</a></td> <td class="#tocright">PEG Conversion. Write CPARAM format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_json.html">pt::peg::to::json</a></td> <td class="#tocright">PEG Conversion. Write JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_param.html">pt::peg::to::param</a></td> <td class="#tocright">PEG Conversion. Write PARAM format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_peg.html">pt::peg::to::peg</a></td> <td class="#tocright">PEG Conversion. Write PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html">pt::peg::to::tclparam</a></td> <td class="#tocright">PEG Conversion. Write TCLPARAM format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_language.html">pt::peg_language</a></td> <td class="#tocright">PEG Language Tutorial</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_introduction.html">pt::pegrammar</a></td> <td class="#tocright">Introduction to Parsing Expression Grammars</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pgen.html">pt::pgen</a></td> <td class="#tocright">Parser Generator</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_rdengine.html">pt::rde</a></td> <td class="#tocright">Parsing Runtime Support, PARAM based</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html">pt::tclparam::configuration::snit</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Snit</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html">pt::tclparam::configuration::tcloo</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Tcloo</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_util.html">pt::util</a></td> <td class="#tocright">General utilities</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_to_api.html">pt_export_api</a></td> <td class="#tocright">Parser Tools Export API</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_from_api.html">pt_import_api</a></td> <td class="#tocright">Parser Tools Import API</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_introduction.html">pt_introduction</a></td> <td class="#tocright">Introduction to Parser Tools</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_parse_peg.html">pt_parse_peg</a></td> <td class="#tocright">Parser Tools PEG Parser</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_parser_api.html">pt_parser_api</a></td> <td class="#tocright">Parser API</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_op.html">pt_peg_op</a></td> <td class="#tocright">Parser Tools PE Grammar Utility Operations</td> </tr> </table></dl> <dl><dt>Procedures, arguments, parameters, options<dd> <table class="#toc"> <tr class="#toceven" > |
︙ | ︙ |
Changes to embedded/www/toc1.html.
︙ | ︙ | |||
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 | <td class="#tocright">Abstract Syntax Tree Serialization</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_critcl.html">pt::cparam::configuration::critcl</a></td> <td class="#tocright">C/PARAM, Canned configuration, Critcl</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_cparam_config_tea.html">pt::cparam::configuration::tea</a></td> <td class="#tocright">C/PARAM, Canned configuration, TEA</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_json_language.html">pt::json_language</a></td> <td class="#tocright">The JSON Grammar Exchange Format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_param.html">pt::param</a></td> <td class="#tocright">PackRat Machine Specification</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pexpression.html">pt::pe</a></td> <td class="#tocright">Parsing Expression Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pexpr_op.html">pt::pe::op</a></td> <td class="#tocright">Parsing Expression Utilities</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pegrammar.html">pt::peg</a></td> <td class="#tocright">Parsing Expression Grammar Serialization</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_container.html">pt::peg::container</a></td> <td class="#tocright">PEG Storage</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_container_peg.html">pt::peg::container::peg</a></td> <td class="#tocright">PEG Storage. Canned PEG grammar specification</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export.html">pt::peg::export</a></td> <td class="#tocright">PEG Export</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_container.html">pt::peg::export::container</a></td> <td class="#tocright">PEG Export Plugin. Write CONTAINER format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_json.html">pt::peg::export::json</a></td> <td class="#tocright">PEG Export Plugin. Write JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_export_peg.html">pt::peg::export::peg</a></td> <td class="#tocright">PEG Export Plugin. Write PEG format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_container.html">pt::peg::from::container</a></td> <td class="#tocright">PEG Conversion. From CONTAINER format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_json.html">pt::peg::from::json</a></td> <td class="#tocright">PEG Conversion. Read JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_from_peg.html">pt::peg::from::peg</a></td> <td class="#tocright">PEG Conversion. Read PEG format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import.html">pt::peg::import</a></td> <td class="#tocright">PEG Import</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_container.html">pt::peg::import::container</a></td> <td class="#tocright">PEG Import Plugin. From CONTAINER format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_json.html">pt::peg::import::json</a></td> <td class="#tocright">PEG Import Plugin. Read JSON format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_import_peg.html">pt::peg::import::peg</a></td> <td class="#tocright">PEG Import Plugin. Read PEG format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_interp.html">pt::peg::interp</a></td> <td class="#tocright">Interpreter for parsing expression grammars</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_container.html">pt::peg::to::container</a></td> <td class="#tocright">PEG Conversion. Write CONTAINER format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_cparam.html">pt::peg::to::cparam</a></td> <td class="#tocright">PEG Conversion. Write CPARAM format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_json.html">pt::peg::to::json</a></td> <td class="#tocright">PEG Conversion. Write JSON format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_param.html">pt::peg::to::param</a></td> <td class="#tocright">PEG Conversion. Write PARAM format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_peg.html">pt::peg::to::peg</a></td> <td class="#tocright">PEG Conversion. Write PEG format</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_to_tclparam.html">pt::peg::to::tclparam</a></td> <td class="#tocright">PEG Conversion. Write TCLPARAM format</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_language.html">pt::peg_language</a></td> <td class="#tocright">PEG Language Tutorial</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_introduction.html">pt::pegrammar</a></td> <td class="#tocright">Introduction to Parsing Expression Grammars</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_pgen.html">pt::pgen</a></td> <td class="#tocright">Parser Generator</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_rdengine.html">pt::rde</a></td> <td class="#tocright">Parsing Runtime Support, PARAM based</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_tclparam_config_snit.html">pt::tclparam::configuration::snit</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Snit</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_tclparam_config_tcloo.html">pt::tclparam::configuration::tcloo</a></td> <td class="#tocright">Tcl/PARAM, Canned configuration, Tcloo</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_util.html">pt::util</a></td> <td class="#tocright">General utilities</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_to_api.html">pt_export_api</a></td> <td class="#tocright">Parser Tools Export API</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_from_api.html">pt_import_api</a></td> <td class="#tocright">Parser Tools Import API</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_introduction.html">pt_introduction</a></td> <td class="#tocright">Introduction to Parser Tools</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_parse_peg.html">pt_parse_peg</a></td> <td class="#tocright">Parser Tools PEG Parser</td> </tr> <tr class="#tocodd" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_parser_api.html">pt_parser_api</a></td> <td class="#tocright">Parser API</td> </tr> <tr class="#toceven" > <td class="#tocleft" ><a href="tcllib/files/modules/pt/pt_peg_op.html">pt_peg_op</a></td> <td class="#tocright">Parser Tools PE Grammar Utility Operations</td> </tr> </table></dl> <dl><dt>rc4<dd> <table class="#toc"> <tr class="#toceven" > |
︙ | ︙ |
Changes to modules/pt/char.tcl.
︙ | ︙ | |||
53 54 55 56 57 58 59 | return [format %c 0x$hcode] } return $ch } | > > | | < < < | > > > > | < | < | < | < > > | < < | < | < | < > > | > | > | > > | > | < | | | > | < | | | | > > > | | | > | | > | | | | > > > > > | < < < > | | < | < | > | | < < < | < < < < < < < < | > > | < | | | > > > > > > > > > > | < > > > > > > | > > | < < | < | 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 | return [format %c 0x$hcode] } return $ch } # ### ### ### ######### ######### ######### proc ::char::quote::tcl {ch args} { Arg Tcl $ch {*}$args } proc ::char::quote::Tcl {ch} { # Input: A single character # Output: A string representing the input. # Properties of the output: # (1) Contains only ASCII characters (7bit Unicode subset). # (2) When embedded in a ""-quoted Tcl string in a piece of Tcl # code the Tcl parser will regenerate the input character. # Special character? switch -exact -- $ch { "\n" {return "\\n"} "\r" {return "\\r"} "\t" {return "\\t"} "\\" - "\;" - " " - "\"" - "(" - ")" - "\{" - "\}" - "\[" - "\]" { # Quote space and all the brackets as well, using octal, # for easy impure list-ness. scan $ch %c chcode return \\[format %o $chcode] } } scan $ch %c chcode # Control character? if {[::string is control -strict $ch]} { return \\[format %o $chcode] } # Unicode beyond 7bit ASCII? if {$chcode > 127} { return \\u[format %04x $chcode] } # Regular character: Is its own representation. return $ch } # ### ### ### ######### ######### ######### proc ::char::quote::string {ch args} { Arg String $ch {*}$args } proc ::char::quote::String {ch} { # Input: A single character # Output: A string representing the input # Properties of the output # (1) Human-readable, for use in error messages, or comments. # (1a) Uses only printable characters. # (2) NO particular properties with regard to C or Tcl parsers. scan $ch %c chcode # Map the ascii control characters to proper names. if {($chcode <= 32) || ($chcode == 127)} { variable strmap return [dict get $strmap $chcode] } # Printable ascii characters represent themselves. if {$chcode < 128} { return $ch } # Unicode characters. Mostly represent themselves, except if # control or not printable. Then they are represented by their # codepoint. # Control characters: Octal if {[::string is control -strict $ch] || ![::string is print -strict $ch]} { return <U+[format %04x $chcode]> } return $ch } namespace eval ::char::quote { variable strmap { 0 <NUL> 8 <BS> 16 <DLE> 24 <CAN> 32 <SPACE> 1 <SOH> 9 <TAB> 17 <DC1> 25 <EM> 127 <DEL> 2 <STX> 10 <LF> 18 <DC2> 26 <SUB> 3 <ETX> 11 <VTAB> 19 <DC3> 27 <ESC> 4 <EOT> 12 <FF> 20 <DC4> 28 <FS> 5 <ENQ> 13 <CR> 21 <NAK> 29 <GS> 6 <ACK> 14 <SO> 22 <SYN> 30 <RS> 7 <BEL> 15 <SI> 23 <ETB> 31 <US> } } # ### ### ### ######### ######### ######### proc ::char::quote::cstring {ch args} { Arg CString $ch {*}$args } proc ::char::quote::CString {ch} { # Input: A single character # Output: A string representing the input. # Properties of the output: # (1) Contains only ASCII characters (7bit Unicode subset). # (2) When embedded in a ""-quoted C string in a piece of # C code the C parser will regenerate the input character # in UTF-8 encoding. # Special characters (named). switch -exact -- $ch { "\n" {return "\\n"} "\r" {return "\\r"} "\t" {return "\\t"} "\"" - "\\" { return \\$ch } "\{" - "\}" { # The generated C code containing the result of this # transform may be embedded in Tcl code (Brace-quoted), # i.e. like for a critcl-based package. To avoid tripping # the Tcl parser with unbalanced braces we sacrifice # readability of the generated code a bit and insert # braces in their octal form. scan $ch %c chcode return \\[format %o $chcode] } } scan $ch %c chcode # Control characters: Octal if {[::string is control -strict $ch]} { return \\[format %o $chcode] } # Beyond 7-bit ASCII: Unicode if {$chcode > 127} { # Recode the character into the sequence of utf-8 bytes and # convert each to octal. foreach x [split [encoding convertto utf-8 $ch] {}] { scan $x %c x append res \\[format %o $x] } return $res } # Regular character: Is its own representation. return $ch } # ### ### ### ######### ######### ######### proc ::char::quote::comment {ch args} { Arg Comment $ch {*}$args } proc ::char::quote::Comment {ch} { # Converts a Tcl character (internal representation) into a string # which is accepted by the Tcl parser when used within a Tcl # comment. |
︙ | ︙ | |||
241 242 243 244 245 246 247 248 249 250 251 | return \\u[format %04x $chcode] } # Regular character: Is its own representation. return $ch } # ### ### ### ######### ######### ######### ## Ready | > > > > > > > > > > > > > > > > > > > > > > > > | < | 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 | return \\u[format %04x $chcode] } # Regular character: Is its own representation. return $ch } # ### ### ### ######### ######### ######### ## Internal. Argument processing helper proc ::char::quote::Arg {cmdpfx str args} { # single argument => treat as string, # process all characters separately. # return transformed string. if {![llength $args]} { set r {} foreach c [split $str {}] { append r [uplevel 1 [linsert $cmdpfx end $c]] } return $r } # multiple arguments => process each like a single argument, and # return list of transform results. set args [linsert $args 0 $str] foreach str $args { lappend res [uplevel 1 [list Arg $cmdpfx $str]] } return $res } # ### ### ### ######### ######### ######### ## Ready package provide char 1.0.1 |
Added modules/pt/char.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | # -*- tcl -*- # char.test: tests for the char package. # # Copyright (c) 2014 by Andreas Kupries <[email protected]> # All rights reserved. # # RCS: @(#) $Id: char.test,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ # ------------------------------------------------------------------------- source [file join \ [file dirname [file dirname [file join [pwd] [info script]]]] \ devtools testutilities.tcl] testsNeedTcl 8.5 testsNeedTcltest 2.0 support { } testing { useLocal char.tcl char } # ------------------------------------------------------------------------- set mytestdir tests/data # ------------------------------------------------------------------------- source [localPath tests/char.tests] #---------------------------------------------------------------------- unset mytestdir testsuiteCleanup return |
Changes to modules/pt/pkgIndex.tcl.
1 2 3 | if {![package vsatisfies [package provide Tcl] 8.5]} return # General utilities. | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | if {![package vsatisfies [package provide Tcl] 8.5]} return # General utilities. package ifneeded char 1.0.1 [list source [file join $dir char.tcl]] package ifneeded configuration 1 [list source [file join $dir configuration.tcl]] package ifneeded paths 1 [list source [file join $dir paths.tcl]] package ifneeded text::write 1 [list source [file join $dir text_write.tcl]] # AST support package ifneeded pt::ast 1.1 [list source [file join $dir pt_astree.tcl]] # General parser support. Currently only conversion of structured # syntax errors (or parts thereof) into a human-readable form. package ifneeded pt::util 1 [list source [file join $dir pt_util.tcl]] # Parsing Expression support package ifneeded pt::pe 1.0.2 [list source [file join $dir pt_pexpression.tcl]] package ifneeded pt::pe::op 1 [list source [file join $dir pt_pexpr_op.tcl]] # Parsing Expression Grammar support. package ifneeded pt::peg 1 [list source [file join $dir pt_pegrammar.tcl]] package ifneeded pt::peg::container 1 [list source [file join $dir pt_peg_container.tcl]] package ifneeded pt::peg::interp 1.0.1 [list source [file join $dir pt_peg_interp.tcl]] package ifneeded pt::peg::op 1.0.1 [list source [file join $dir pt_peg_op.tcl]] |
︙ | ︙ | |||
36 37 38 39 40 41 42 | # Import plugins, connecting manager to the core conversion packages. package ifneeded pt::peg::import::json 1 [list source [file join $dir pt_peg_import_json.tcl]] package ifneeded pt::peg::import::peg 1 [list source [file join $dir pt_peg_import_peg.tcl]] # Export core functionality: Conversion from PEG to a specific format. package ifneeded pt::peg::to::container 1 [list source [file join $dir pt_peg_to_container.tcl]] | | | | > | 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 | # Import plugins, connecting manager to the core conversion packages. package ifneeded pt::peg::import::json 1 [list source [file join $dir pt_peg_import_json.tcl]] package ifneeded pt::peg::import::peg 1 [list source [file join $dir pt_peg_import_peg.tcl]] # Export core functionality: Conversion from PEG to a specific format. package ifneeded pt::peg::to::container 1 [list source [file join $dir pt_peg_to_container.tcl]] package ifneeded pt::peg::to::cparam 1.1.3 [list source [file join $dir pt_peg_to_cparam.tcl]] package ifneeded pt::peg::to::json 1 [list source [file join $dir pt_peg_to_json.tcl]] package ifneeded pt::peg::to::param 1.0.1 [list source [file join $dir pt_peg_to_param.tcl]] package ifneeded pt::peg::to::peg 1.0.2 [list source [file join $dir pt_peg_to_peg.tcl]] package ifneeded pt::peg::to::tclparam 1.0.2 [list source [file join $dir pt_peg_to_tclparam.tcl]] # Import core functionality: Conversion from a specific format to PEG. package ifneeded pt::peg::from::json 1 [list source [file join $dir pt_peg_from_json.tcl]] package ifneeded pt::peg::from::peg 1.0.3 [list source [file join $dir pt_peg_from_peg.tcl]] # PARAM runtime. package ifneeded pt::rde 1.0.3 [list source [file join $dir pt_rdengine.tcl]] package ifneeded pt::rde::oo 1.0.3 [list source [file join $dir pt_rdengine_oo.tcl]] # PEG grammar specification, as CONTAINER package ifneeded pt::peg::container::peg 1 [list source [file join $dir pt_peg_container_peg.tcl]] # */PARAM support (canned configurations). package ifneeded pt::cparam::configuration::critcl 1.0.2 [list source [file join $dir pt_cparam_config_critcl.tcl]] package ifneeded pt::cparam::configuration::tea 0.1 [list source [file join $dir pt_cparam_config_tea.tcl]] package ifneeded pt::tclparam::configuration::snit 1.0.2 [list source [file join $dir pt_tclparam_config_snit.tcl]] package ifneeded pt::tclparam::configuration::tcloo 1.0.4 [list source [file join $dir pt_tclparam_config_tcloo.tcl]] # Parser generator core. package ifneeded pt::pgen 1.0.3 [list source [file join $dir pt_pgen.tcl]] |
Changes to modules/pt/pt_cparam_config_critcl.tcl.
1 2 3 4 5 6 7 8 9 | # -*- tcl -*- # Copyright (c) 2009-2014 Andreas Kupries <[email protected]> # Canned configuration for the converter to C/PARAM representation, # causing generation of a proper critcl-based parser. # The requirements of the embedded template are not our requirements. # @mdgen NODEP: critcl | > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | # -*- tcl -*- # Copyright (c) 2009-2014 Andreas Kupries <[email protected]> # TODO: Refactor this and pt::cparam::configuration::critcl to avoid # TODO: duplication of the supporting code (creation of the RDE # TODO: amalgamation, basic C template). # Canned configuration for the converter to C/PARAM representation, # causing generation of a proper critcl-based parser. # The requirements of the embedded template are not our requirements. # @mdgen NODEP: critcl |
︙ | ︙ | |||
159 160 161 162 163 164 165 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "@@CTAIL@@%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Added modules/pt/pt_cparam_config_tea.man.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | [vset VERSION 0.1] [comment {-*- text -*- doctools manpage}] [manpage_begin pt::cparam::configuration::tea n [vset VERSION]] [include include/module.inc] [titledesc {C/PARAM, Canned configuration, TEA}] [require pt::cparam::configuration::tea [opt [vset VERSION]]] [description] [include include/ref_intro.inc] This package is an adjunct to [package pt::peg::to::cparam], to make the use of this highly configurable package easier by providing a canned configuration. When applied this configuration causes the package [package pt::peg::to::cparam] to generate plain parser code ready for inclusion into a [term TEA]-based C extension. [para] It is a supporting package in the Core Layer of Parser Tools. [para][image arch_core_support][para] [section API] [list_begin definitions] [call [cmd ::pt::cparam::configuration::tea] [method def] \ [arg name] [arg pkg] [arg version] [arg cmdprefix]] The command applies the configuration provided by this package to the [arg cmdprefix], causing the creation of [package tea]-based parsers whose class is [arg name], in package [arg pkg] with [arg version]. [para] The use of a command prefix as API allows application of the configuration to not only [package pt::peg::to::cparam] ([cmd {pt::peg::to::cparam configure}]), but also export manager instances and PEG containers ([cmd {$export configuration set}] and [cmd {[$container exporter] configuration set}] respectively). [para] Or anything other command prefix accepting two arguments, option and value. [list_end] [include include/feedback.inc] [manpage_end] |
Added modules/pt/pt_cparam_config_tea.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | # -*- tcl -*- # Copyright (c) 2014 Christian Gollwitzer <[email protected]> # TODO: Refactor this and pt::cparam::configuration::critcl to avoid # TODO: duplication of the supporting code (creation of the RDE # TODO: amalgamation, basic C template). # Canned configuration for the converter to C/PARAM representation, # causing generation of a C-based parser which can be plugged into a # TEA-based C extension. The supporting files, i.e. configure.in, # Makefile.in, etc. still have to be written separately, and manually. # The generated file can easily be compiled with a single # # gcc -dynamiclib -o <parser>.dylib <parser>.c -DUSE_TCL_STUBS -ltclstub8.5 # # or similar, or included in a larger package, if added to the source # files and by invoking the <parser>_Init() function within the init # function of the main package. # # TODO: Put the above note/semi-example into the manpage for this generator. # # ## ### ##### ######## ############# ##################### ## Requirements package require Tcl 8.5 ; # Required runtime. # # ## ### ##### ######## ############# ##################### ## namespace eval ::pt::cparam::configuration::tea { namespace export def namespace ensemble create # @mdgen OWNER: rde_critcl/util.* # @mdgen OWNER: rde_critcl/stack.* # @mdgen OWNER: rde_critcl/tc.* # @mdgen OWNER: rde_critcl/param.* # Access to the rde_critcl files forming the low-level runtime variable selfdir [file dirname [file normalize [info script]]] } # # ## ### ##### ######## ############# ## Public API # Check that the proposed serialization of an abstract syntax tree is # indeed such. proc ::pt::cparam::configuration::tea::def {class pkg version cmd} { # TODO :: See if we can consolidate the API for converters, # TODO :: plugins, export manager, and container in some way. # TODO :: Container may make exporter manager available through # TODO :: public method. # class = The namespace/prefix for the generated commands. # pkg = The name of the generated package / parser. # version = The version of the generated package / parser. if {[string first :: $class] < 0} { set cheader $class set ctrailer $class } else { set cheader [namespace qualifier $class] set ctrailer [namespace tail $class] } set pkghead [string range $pkg 0 0] set pkgtail [string range $pkg 1 end] set pkglowcase "[string toupper $pkghead][string tolower $pkgtail]" lappend map @@RUNTIME@@ [GetRuntime] lappend map @@PKG@@ $pkg lappend map @@PKGLOWCASE@@ $pkglowcase lappend map @@VERSION@@ $version lappend map @@CLASS@@ $class lappend map @@CHEAD@@ $cheader lappend map @@CTAIL@@ $ctrailer lappend map \n\t \n ;# undent the template {*}$cmd -main MAIN {*}$cmd -indent 8 {*}$cmd -template [string trim \ [string map $map { /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** @name@ ** ** Generated from file @file@ ** for user @user@ ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static @@RUNTIME@@ @code@ /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/@@PKG@@/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "@@CTAIL@@%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int @@PKGLOWCASE@@_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "@@CLASS@@", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "@@PKG@@", "0.1"); return TCL_OK; } }]] return } proc ::pt::cparam::configuration::tea::GetRuntime {} { # This is the C code for the RDE, i.e. the implementation of # pt::rde. Only the low-level engine is imported, the Tcl # interface layer is ignored. This generated parser provides its # own layer for that. # We are inlining the code (making the functions static) to # prevent any conflict with the support for pt::rde, should both # be put into the same shared library. variable selfdir set code {} foreach f { rde_critcl/util.h rde_critcl/stack.h rde_critcl/tc.h rde_critcl/param.h rde_critcl/util.c rde_critcl/stack.c rde_critcl/tc.c rde_critcl/param.c } { # Load C code. set c [open $selfdir/$f] set d [read $c] close $c # Strip include directives and anything explicitly excluded. set skip 0 set n {} foreach l [split $d \n] { if {[string match {*#include*} $l]} { continue } if {[string match {*SKIP START*} $l]} { set skip 1 continue } if {[string match {*SKIP END*} $l]} { set skip 0 continue } if {$skip} continue lappend n $l } set d [join $n \n] # Strip comments, trailing whitespace, empty lines. set d [regsub -all {/\*.*?\*/} $d {}] set d [regsub -all {//.*?\n} $d {}] set d [regsub -all {[ ]+$} $d {}] while {1} { set n [string map [list \n\n \n] $d] if {$n eq $d} break set d $n } # Indent code. lappend code "#line 1 \"$f\"" foreach l [split $d \n] { if {$l ne ""} { set l \t$l } lappend code $l } } #lappend code "#line x \"X\"" return [join $code \n] } # # ## ### ##### ######## ############# namespace eval ::pt::cparam::configuration::tea {} # # ## ### ##### ######## ############# ##################### ## Ready package provide pt::cparam::configuration::tea 0.1 return |
Added modules/pt/pt_cparam_config_tea.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | # -*- tcl -*- # pt_cparam_config_critcl.test: tests for the pt::peg::to::cparam # converter package configured for critcl. # # Copyright (c) 2009 by Andreas Kupries <[email protected]> # All rights reserved. # # RCS: @(#) $Id: pt_cparam_config_critcl.test,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ # ------------------------------------------------------------------------- source [file join \ [file dirname [file dirname [file join [pwd] [info script]]]] \ devtools testutilities.tcl] testsNeedTcl 8.5 testsNeedTcltest 2 support { useAccel [useTcllibC] struct/sets.tcl struct::set ; # used by pt::pe::op, TestAccelInit struct::set ; # however not by the # # commands used here. use fileutil/fileutil.tcl fileutil ;# tests/common use textutil/adjust.tcl textutil::adjust useLocal pt_pexpression.tcl pt::pe useLocal pt_pexpr_op.tcl pt::pe::op useLocal pt_pegrammar.tcl pt::peg useLocal text_write.tcl text::write useLocal char.tcl char useLocal pt_peg_to_cparam.tcl pt::peg::to::cparam source [localPath tests/common] } testing { useLocal pt_cparam_config_tea.tcl pt::cparam::configuration::tea } set mytestdir tests/data # ------------------------------------------------------------------------- source [localPath tests/pt_cparam_config_tea.tests] # ------------------------------------------------------------------------- TestAccelExit struct::set testsuiteCleanup return |
Changes to modules/pt/pt_parse_peg_c.tcl.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1897 1898 1899 1900 1901 1902 1903 | /* 26 = */ "str <ascii>", /* 27 = */ "n ASCII", /* 28 = */ "ASCII", /* 29 = */ "n Attribute", /* 30 = */ "Attribute", /* 31 = */ "n Char", /* 32 = */ "Char", | | | | | | | | | 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 | /* 26 = */ "str <ascii>", /* 27 = */ "n ASCII", /* 28 = */ "ASCII", /* 29 = */ "n Attribute", /* 30 = */ "Attribute", /* 31 = */ "n Char", /* 32 = */ "Char", /* 33 = */ "t \\\\", /* 34 = */ ".. 0 2", /* 35 = */ ".. 0 7", /* 36 = */ "n CharOctalFull", /* 37 = */ "CharOctalFull", /* 38 = */ "n CharOctalPart", /* 39 = */ "CharOctalPart", /* 40 = */ "cl nrt'\\\"\\[\\]\\\\", /* 41 = */ "n CharSpecial", /* 42 = */ "CharSpecial", /* 43 = */ "dot", /* 44 = */ "n CharUnescaped", /* 45 = */ "CharUnescaped", /* 46 = */ "str \173\\u\175", /* 47 = */ "n CharUnicode", /* 48 = */ "CharUnicode", /* 49 = */ "n Class", /* 50 = */ "Class", /* 51 = */ "t )", /* 52 = */ "n CLOSE", /* 53 = */ "CLOSE", /* 54 = */ "t \\]", /* 55 = */ "n CLOSEB", /* 56 = */ "CLOSEB", /* 57 = */ "t :", /* 58 = */ "n COLON", /* 59 = */ "COLON", /* 60 = */ "t #", /* 61 = */ "n COMMENT", /* 62 = */ "COMMENT", /* 63 = */ "str <control>", /* 64 = */ "n CONTROL", /* 65 = */ "CONTROL", /* 66 = */ "t \173\"\175", /* 67 = */ "n DAPOSTROPH", /* 68 = */ "DAPOSTROPH", /* 69 = */ "str <ddigit>", /* 70 = */ "n DDIGIT", /* 71 = */ "DDIGIT", /* 72 = */ "n Definition", /* 73 = */ "Definition", /* 74 = */ "str <digit>", /* 75 = */ "n DIGIT", /* 76 = */ "DIGIT", /* 77 = */ "t .", /* 78 = */ "n DOT", /* 79 = */ "DOT", /* 80 = */ "n EOF", /* 81 = */ "EOF", /* 82 = */ "cl \173\n\r\175", /* 83 = */ "n EOL", /* 84 = */ "EOL", /* 85 = */ "n Expression", /* 86 = */ "Expression", /* 87 = */ "str END", /* 88 = */ "n Final", /* 89 = */ "Final", |
︙ | ︙ | |||
1980 1981 1982 1983 1984 1985 1986 | /* 109 = */ "Literal", /* 110 = */ "str <lower>", /* 111 = */ "n LOWER", /* 112 = */ "LOWER", /* 113 = */ "t !", /* 114 = */ "n NOT", /* 115 = */ "NOT", | | | | 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 | /* 109 = */ "Literal", /* 110 = */ "str <lower>", /* 111 = */ "n LOWER", /* 112 = */ "LOWER", /* 113 = */ "t !", /* 114 = */ "n NOT", /* 115 = */ "NOT", /* 116 = */ "t (", /* 117 = */ "n OPEN", /* 118 = */ "OPEN", /* 119 = */ "t \173[\175", /* 120 = */ "n OPENB", /* 121 = */ "OPENB", /* 122 = */ "str PEG", /* 123 = */ "n PEG", /* 124 = */ "PEG", /* 125 = */ "t +", /* 126 = */ "n PLUS", |
︙ | ︙ | |||
2007 2008 2009 2010 2011 2012 2013 | /* 136 = */ "n PUNCT", /* 137 = */ "PUNCT", /* 138 = */ "t ?", /* 139 = */ "n QUESTION", /* 140 = */ "QUESTION", /* 141 = */ "n Range", /* 142 = */ "Range", | | | 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 | /* 136 = */ "n PUNCT", /* 137 = */ "PUNCT", /* 138 = */ "t ?", /* 139 = */ "n QUESTION", /* 140 = */ "QUESTION", /* 141 = */ "n Range", /* 142 = */ "Range", /* 143 = */ "t \173;\175", /* 144 = */ "n SEMICOLON", /* 145 = */ "SEMICOLON", /* 146 = */ "n Sequence", /* 147 = */ "Sequence", /* 148 = */ "t /", /* 149 = */ "n SLASH", /* 150 = */ "SLASH", |
︙ | ︙ | |||
2320 2321 2322 2323 2324 2325 2326 | * '\' * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (p); | | | 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 | * '\' * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "2", 34); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "7", 35); rde_param_i_state_merge_void (p); |
︙ | ︙ | |||
2360 2361 2362 2363 2364 2365 2366 | * '\' * range (0 .. 7) * ? * range (0 .. 7) */ rde_param_i_state_push_void (p); | | | 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 | * '\' * range (0 .. 7) * ? * range (0 .. 7) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; optional_50 (p); rde_param_i_state_merge_void (p); return; } |
︙ | ︙ | |||
2406 2407 2408 2409 2410 2411 2412 | /* * x * '\' * [nrt'\"[]\] */ rde_param_i_state_push_void (p); | | | | 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 | /* * x * '\' * [nrt'\"[]\] */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_class (p, "nrt'\"[]\\", 40); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'CharUnescaped' */ |
︙ | ︙ | |||
2454 2455 2456 2457 2458 2459 2460 | static void notahead_61 (RDE_PARAM p) { /* * ! * '\' */ rde_param_i_loc_push (p); | | | 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 | static void notahead_61 (RDE_PARAM p) { /* * ! * '\' */ rde_param_i_loc_push (p); rde_param_i_next_char (p, "\\", 33); rde_param_i_notahead_exit (p); return; } /* * leaf Symbol 'CharUnicode' */ |
︙ | ︙ | |||
2500 2501 2502 2503 2504 2505 2506 | * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_void (p); | | | 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 | * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "\\u", 46); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_80 (p); rde_param_i_state_merge_void (p); return; } |
︙ | ︙ | |||
2707 2708 2709 2710 2711 2712 2713 | /* * x * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (p); | | | | 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 | /* * x * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, ")", 51); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'CLOSEB' */ static void sym_CLOSEB (RDE_PARAM p) { /* * ']' */ if (rde_param_i_symbol_void_start (p, 56)) return ; rde_param_i_next_char (p, "]", 54); rde_param_i_symbol_done_void (p, 56, 55); return; } /* * void Symbol 'COLON' */ |
︙ | ︙ | |||
2892 2893 2894 2895 2896 2897 2898 | static void sym_DAPOSTROPH (RDE_PARAM p) { /* * '\"' */ if (rde_param_i_symbol_void_start (p, 68)) return ; | | | 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 | static void sym_DAPOSTROPH (RDE_PARAM p) { /* * '\"' */ if (rde_param_i_symbol_void_start (p, 68)) return ; rde_param_i_next_char (p, "\"", 66); rde_param_i_symbol_done_void (p, 68, 67); return; } /* * leaf Symbol 'DDIGIT' */ |
︙ | ︙ | |||
3808 3809 3810 3811 3812 3813 3814 | /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (p); | | | | 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 | /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "(", 116); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'OPENB' */ static void sym_OPENB (RDE_PARAM p) { /* * '[' */ if (rde_param_i_symbol_void_start (p, 121)) return ; rde_param_i_next_char (p, "[", 119); rde_param_i_symbol_done_void (p, 121, 120); return; } /* * void Symbol 'PEG' */ |
︙ | ︙ | |||
4286 4287 4288 4289 4290 4291 4292 | /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (p); | | | 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 | /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, ";", 143); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* |
︙ | ︙ | |||
4745 4746 4747 4748 4749 4750 4751 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "peg%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/pt_peg_to_cparam.tcl.
︙ | ︙ | |||
37 38 39 40 41 42 43 | namespace ensemble create } # ### ### ### ######### ######### ######### ## API. proc ::pt::peg::to::cparam::reset {} { | > | | | | | | | | | | | | | | > > > | > | > | 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 | namespace ensemble create } # ### ### ### ######### ######### ######### ## API. proc ::pt::peg::to::cparam::reset {} { variable insertcmd {} ; # -insert-command (hook) variable template @code@ ; # -template variable name a_pe_grammar ; # -name variable file unknown ; # -file variable user unknown ; # -user variable self {} ; # -self-command variable ns {} ; # -namespace variable def static ; # -fun-qualifier variable main __main ; # -main variable indent 0 ; # -indent variable comments 1 ; # -comments variable prelude {} ; # -prelude variable statedecl {RDE_PARAM p} ; # -state-decl variable stateref {p} ; # -state-ref variable strings p_string ; # -string-varname return } proc ::pt::peg::to::cparam::configure {args} { variable template variable name variable file variable user variable self variable ns variable def variable main variable omap variable indent variable insertcmd variable comments variable prelude variable statedecl variable stateref variable strings if {[llength $args] == 0} { return [list \ -comments $comments \ -file $file \ -fun-qualifier $def \ -indent $indent \ -insert-command $insertcmd \ -main $main \ -name $name \ -namespace $ns \ -self-command $self \ -state-decl $statedecl \ -state-ref $stateref \ -string-varname $strings \ -template $template \ -user $user \ ] } elseif {[llength $args] == 1} { lassign $args option set variable [string range $option 1 end] if {[info exists omap($variable)]} { return [set $omap($variable)] } else { # TODO: compute this string dynamically. return -code error "Expected one of -comments, -file, -fun-qualifier, -indent, -insert-cmd, -main, -name, -namespace, -self-command, -state-decl, -state-ref, -string-varname, -template, or -user, got \"$option\"" } } elseif {[llength $args] % 2 == 0} { foreach {option value} $args { set variable [string range $option 1 end] if {![info exists omap($variable)]} { # TODO: compute this string dynamically. return -code error "Expected one of -comments, -file, -fun-qualifier, -indent, -insert-cmd, -main, -name, -namespace, -self-command, -state-decl, -state-ref, -string-varname, -template, or -user, got \"$option\"" } } foreach {option value} $args { set variable $omap([string range $option 1 end]) switch -exact -- $variable { template { if {$value eq {}} { return -code error "Expected template, got the empty string" } } indent { if {![string is integer -strict $value] || ($value < 0)} { return -code error "Expected int > 0, got \"$value\"" } } comments { if {![string is boolean -strict $value]} { return -code error "Expected boolean, got \"$value\"" } } insert-cmd - statedecl - stateref - strings - self - def - ns - main - |
︙ | ︙ | |||
149 150 151 152 153 154 155 156 157 158 159 160 161 162 | variable file variable user variable self variable ns variable def variable main variable indent variable prelude variable statedecl variable stateref variable strings Op::Asm::Setup | > | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | variable file variable user variable self variable ns variable def variable main variable indent variable insertcmd variable prelude variable statedecl variable stateref variable strings Op::Asm::Setup |
︙ | ︙ | |||
260 261 262 263 264 265 266 | if {$indent} { set code [Indent $code $indent] } set xprelude $prelude ; if {$xprelude ne {}} { set xprelude " $xprelude" } set xself $self ; if {$xself ne {}} { append xself { } } | > > | > | > > | | | | | | > | > > | | | | | | | | > < | | > | | 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 | if {$indent} { set code [Indent $code $indent] } set xprelude $prelude ; if {$xprelude ne {}} { set xprelude " $xprelude" } set xself $self ; if {$xself ne {}} { append xself { } } # I. run code through the insertcmd hook (if specified) to prepare it for embedding if {[llength $insertcmd]} { set code [{*}$insertcmd $code] } # II. Phase 1 merge of code into the template. # (Placeholders only in the template) lappend map @user@ $user lappend map @format@ C/PARAM lappend map @file@ $file lappend map @name@ $name lappend map @code@ $code set code [string map $map $template] unset map # III. Phase 2 merge of code into the template. # (Placeholders in generated code, and template). lappend map @statedecl@ $statedecl lappend map @stateref@ $stateref lappend map @strings@ $strings lappend map { @prelude@} $xprelude lappend map {@self@ } $xself lappend map @def@ $def lappend map @ns@ $ns lappend map @main@ $main set code [string map $map $code] return $code # ### ### ### ######### ######### ######### } # ### ### ### ######### ######### ######### ## Internals proc ::pt::peg::to::cparam::Indent {text n} { set b [string repeat { } $n] return $b[join [split $text \n] \n$b] } proc ::pt::peg::to::cparam::Expression {expression modes} { return [pt::pe bottomup \ [list [namespace current]::Op $modes] \ $expression] } proc ::pt::peg::to::cparam::Symbol {symbol mode rhs modes} { set expression [Expression $rhs $modes] text::write clear Op::Asm::Header "$mode Symbol '$symbol'" text::write store FUN_HEADER Op::Asm::Start Op::Asm::ReExpression $symbol Op::Asm::GenAST $expression Op::Asm::PE $rhs set gen [dict get $result gen] Op::Asm::Function sym_$symbol { # Message is Tcl list. Quote for C embedding. set msg [Op::Asm::String [char quote cstring [list n $symbol]]] # Quote for C embedding. set symbol [Op::Asm::String [char quote cstring $symbol]] # We have six possibilites for the combination of AST node # generation by the rhs and AST generation by the symbol. Two # of these (leaf/0, value/0 coincide, leaving 5). This # controls the use of AS/ARS instructions. switch -exact -- $mode/$gen { |
︙ | ︙ | |||
554 555 556 557 558 559 560 | }] } proc ::pt::peg::to::cparam::Op::t {modes char} { Asm::Start Asm::ReTerminal t $char Asm::Direct { | | | > > | | | | | > > | > | | | | | | > | > > | | > | > > | | 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 | }] } proc ::pt::peg::to::cparam::Op::t {modes char} { Asm::Start Asm::ReTerminal t $char Asm::Direct { # Message is Tcl list. Quote for C embedding. set msg [Asm::String [char quote cstring [list t $char]]] # Quote for C embedding. set char [char quote cstring $char] #Asm::Ins input_next $msg #Asm::CStmt if (!rde_param_query_st(@stateref@)) return #Asm::Ins test_char \"$char\" $msg Asm::Ins next_char \"$char\" $msg } Asm::Done } proc ::pt::peg::to::cparam::Op::.. {modes chs che} { Asm::Start Asm::ReTerminal .. $chs $che Asm::Direct { # Message is Tcl list. Quote for C embedding. set msg [Asm::String [char quote cstring [list .. $chs $che]]] # Quote for C embedding set chs [char quote cstring $chs] set che [char quote cstring $che] #Asm::Ins input_next $msg #Asm::CStmt if (!rde_param_query_st(@stateref@)) return #Asm::Ins test_range \"$chs\" \"$che\" $msg Asm::Ins next_range \"$chs\" \"$che\" $msg } Asm::Done } proc ::pt::peg::to::cparam::Op::str {modes args} { Asm::Start Asm::ReTerminal str {*}$args Asm::Direct { set str [join $args {}] # Message is Tcl list. Quote for C embedding. set msg [Asm::String [char quote cstring [list str $str]]] # Quote for C embedding set str [char quote cstring $str] # Without fusing this would be rendered as a sequence of # characters, with associated stack churn for each # character/part (See Op::x, void/all). Asm::Ins next_str \"$str\" $msg } Asm::Done } proc ::pt::peg::to::cparam::Op::cl {modes args} { # rorc = Range-OR-Char-List Asm::Start Asm::ReTerminal cl {*}$args Asm::Direct { # Without fusing this would be rendered as a choice of # characters, with associated stack churn for each # character/branch (See Op::/, void/all). set cl [join [Ranges {*}$args] {}] # Message is Tcl list. Quote for C embedding. set msg [Asm::String [char quote cstring [list cl $cl]]] # Quote for C embedding set cl [char quote cstring $cl] Asm::Ins next_class \"$cl\" $msg } Asm::Done } proc ::pt::peg::to::cparam::Op::Ranges {args} { set res {} foreach rorc $args { lappend res [Range $rorc] } |
︙ | ︙ | |||
644 645 646 647 648 649 650 | set res {} for {set i $s} {$i <= $e} {incr i} { append res [format %c $i] } return $res } else { | | | 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | set res {} for {set i $s} {$i <= $e} {incr i} { append res [format %c $i] } return $res } else { return $rorc ;#[char quote tcl $rorc] } } proc ::pt::peg::to::cparam::Op::n {modes symbol} { # symbol mode determines AST generation # void => non-generative, # leaf/value => generative. |
︙ | ︙ | |||
1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 | # Map from option name (without leading dash) to the name of the # variable used to store setting. variable omap ; array set omap { comments comments file file fun-qualifier def indent indent main main name name namespace ns prelude prelude self-command self state-decl statedecl state-ref stateref string-varname strings template template user user } variable comments 1 variable self {} variable ns {} variable def static variable main __main variable indent 0 variable prelude {} variable statedecl {RDE_PARAM p} variable stateref p variable strings p_string | > > | > | | | | 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 | # Map from option name (without leading dash) to the name of the # variable used to store setting. variable omap ; array set omap { comments comments file file fun-qualifier def indent indent insert-cmd insertcmd main main name name namespace ns prelude prelude self-command self state-decl statedecl state-ref stateref string-varname strings template template user user } variable insertcmd {} variable comments 1 variable self {} variable ns {} variable def static variable main __main variable indent 0 variable prelude {} variable statedecl {RDE_PARAM p} variable stateref p variable strings p_string variable template @code@ ; # A string. Together with the # insertcmd (if any) it specifies # how to embed the generated code # into a larger framework (the # template). variable name a_pe_grammar ; # String. Name of the grammar. variable file unknown ; # String. Name of the file or # other entity the grammar came # from. variable user unknown ; # String. Name of the user on # which behalf the conversion has # been invoked. } # ### ### ### ######### ######### ######### ## Ready package provide pt::peg::to::cparam 1.1.3 return |
Changes to modules/pt/pt_peg_to_param.tcl.
1 2 3 4 | # peg_to_param.tcl -- # # Conversion of PEG to PARAM assembler. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 | # peg_to_param.tcl -- # # Conversion of PEG to PARAM assembler. # # Copyright (c) 2009-2014 Andreas Kupries <[email protected]> # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: pt_peg_to_param.tcl,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $ # This package takes the canonical serialization of a parsing |
︙ | ︙ | |||
368 369 370 371 372 373 374 | proc ::pt::peg::to::param::Op::t {modes char} { variable ::pt::peg::to::param::inline Asm::Start Asm::ReTerminal t $char if {$inline} { Asm::Direct { | | | | | | | | 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 | proc ::pt::peg::to::param::Op::t {modes char} { variable ::pt::peg::to::param::inline Asm::Start Asm::ReTerminal t $char if {$inline} { Asm::Direct { set c [char quote string $char] Asm::Ins input_next "\"t $c\"" Asm::Ins ok! test_char \"$c\" } } else { Asm::Function [Asm::NewBlock char ] { set c [char quote string $char] Asm::Ins input_next "\"t $c\"" Asm::Ins ok! test_char \"$c\" } } Asm::Done } proc ::pt::peg::to::param::Op::.. {modes chstart chend} { variable ::pt::peg::to::param::inline Asm::Start Asm::ReTerminal .. $chstart $chend if {$inline} { Asm::Direct { set s [char quote string $chstart] set e [char quote string $chend] Asm::Ins input_next "\".. $s $e\"" Asm::Ins ok! test_range \"$s\" \"$e\" } } else { Asm::Function [Asm::NewBlock range] { set s [char quote string $chstart] set e [char quote string $chend] Asm::Ins input_next "\".. $s $e\"" Asm::Ins ok! test_range \"$s\" \"$e\" } } Asm::Done } |
︙ | ︙ | |||
1021 1022 1023 1024 1025 1026 1027 | # which behalf the conversion has # been invoked. } # ### ### ### ######### ######### ######### ## Ready | | | 1021 1022 1023 1024 1025 1026 1027 1028 1029 | # which behalf the conversion has # been invoked. } # ### ### ### ######### ######### ######### ## Ready package provide pt::peg::to::param 1.0.1 return |
Changes to modules/pt/pt_peg_to_tclparam.tcl.
︙ | ︙ | |||
421 422 423 424 425 426 427 | }] } proc ::pt::peg::to::tclparam::Op::t {modes char} { Asm::Start Asm::ReTerminal t $char Asm::Direct { | | | | | | | | | | | | < < > > > | > > > > > > > | 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 | }] } proc ::pt::peg::to::tclparam::Op::t {modes char} { Asm::Start Asm::ReTerminal t $char Asm::Direct { set char [char quote tcl $char] #Asm::Ins i_input_next "\{t $char\}" #Asm::Ins i:fail_return #Asm::Ins i_test_char $char Asm::Ins si:next_char $char } Asm::Done } proc ::pt::peg::to::tclparam::Op::.. {modes chs che} { Asm::Start Asm::ReTerminal .. $chs $che Asm::Direct { set chs [char quote tcl $chs] set che [char quote tcl $che] #Asm::Ins i_input_next "\{.. $chs $che\}" #Asm::Ins i:fail_return #Asm::Ins i_test_range $chs $che Asm::Ins si:next_range $chs $che } Asm::Done } proc ::pt::peg::to::tclparam::Op::str {modes args} { Asm::Start Asm::ReTerminal str {*}$args Asm::Direct { # Without fusing this would be rendered as a sequence of # characters, with associated stack churn for each character/part # (See Op::x, void/all). set str [join $args {}] set str [char quote tcl $str] Asm::Ins si:next_str $str } Asm::Done } proc ::pt::peg::to::tclparam::Op::cl {modes args} { # rorc = Range-OR-Char-List Asm::Start Asm::ReTerminal cl {*}$args Asm::Direct { # Without fusing this would be rendered as a choice of # characters, with associated stack churn for each # character/branch (See Op::/, void/all). set cl [join [Ranges {*}$args] {}] set cl [char quote tcl $cl] Asm::Ins si:next_class $cl } Asm::Done } proc ::pt::peg::to::tclparam::Op::Ranges {args} { set res {} foreach rorc $args { lappend res [Range $rorc] } return $res } proc ::pt::peg::to::tclparam::Op::Range {rorc} { # See also pt::peg::to::peg # We use string ops here to distinguish terminals and ranges. The # input can be a single char, not a list, and further the char may # not be a proper list. Example: double-apostroph. |
︙ | ︙ | |||
503 504 505 506 507 508 509 | set res {} for {set i $s} {$i <= $e} {incr i} { append res [format %c $i] } return $res } else { | | | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | set res {} for {set i $s} {$i <= $e} {incr i} { append res [format %c $i] } return $res } else { return $rorc ;#[char quote tcl $rorc] } } proc ::pt::peg::to::tclparam::Op::n {modes symbol} { # symbol mode determines AST generation # void => non-generative, # leaf/value => generative. |
︙ | ︙ | |||
1257 1258 1259 1260 1261 1262 1263 | # which behalf the conversion has # been invoked. } # ### ### ### ######### ######### ######### ## Ready | | | 1265 1266 1267 1268 1269 1270 1271 1272 1273 | # which behalf the conversion has # been invoked. } # ### ### ### ######### ######### ######### ## Ready package provide pt::peg::to::tclparam 1.0.2 return |
Changes to modules/pt/pt_pexpression.tcl.
︙ | ︙ | |||
18 19 20 21 22 23 24 | verify verify-as-canonical canonicalize \ bottomup topdown print equal \ \ epsilon dot alnum alpha ascii digit graph lower printable \ control punct space upper wordchar xdigit ddigit \ nonterminal optional repeat0 repeat1 ahead notahead \ choice sequence \ | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | verify verify-as-canonical canonicalize \ bottomup topdown print equal \ \ epsilon dot alnum alpha ascii digit graph lower printable \ control punct space upper wordchar xdigit ddigit \ nonterminal optional repeat0 repeat1 ahead notahead \ choice sequence \ terminal range class str namespace ensemble create } # # ## ### ##### ######## ############# ## Public API |
︙ | ︙ | |||
238 239 240 241 242 243 244 | proc ::pt::pe::repeat1 {pe} { list + $pe } proc ::pt::pe::ahead {pe} { list & $pe } proc ::pt::pe::notahead {pe} { list ! $pe } proc ::pt::pe::choice {pe args} { linsert $args 0 / $pe } proc ::pt::pe::sequence {pe args} { linsert $args 0 x $pe } | | > > | > > > > > > > > > > > > > > | 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 | proc ::pt::pe::repeat1 {pe} { list + $pe } proc ::pt::pe::ahead {pe} { list & $pe } proc ::pt::pe::notahead {pe} { list ! $pe } proc ::pt::pe::choice {pe args} { linsert $args 0 / $pe } proc ::pt::pe::sequence {pe args} { linsert $args 0 x $pe } proc ::pt::pe::terminal {t} { list t $t } proc ::pt::pe::range {ta tb} { if {$ta eq $tb} { list t $ta } else { list .. $ta $tb } } proc ::pt::pe::class {set} { if {[string length $set] > 1} { list cl $set } else { list t $set } } proc ::pt::pe::str {str} { if {[string length $str] > 1} { list str $str } else { list t $str } } namespace eval ::pt::pe { # # ## ### ##### ######## ############# ## Strings for error messages. variable ourprefix "error in serialization:" |
︙ | ︙ | |||
297 298 299 300 301 302 303 | ## # # ## ### ##### ######## ############# } # # ## ### ##### ######## ############# ##################### ## Ready | | | 313 314 315 316 317 318 319 320 321 | ## # # ## ### ##### ######## ############# } # # ## ### ##### ######## ############# ##################### ## Ready package provide pt::pe 1.0.2 return |
Changes to modules/pt/pt_pgen.tcl.
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | package require pt::peg::to::peg ; # package require pt::peg::to::param ; # PARAM assembly, raw package require pt::peg::to::tclparam ; # PARAM assembly, embedded into Tcl package require pt::peg::to::cparam ; # PARAM assembly, embedded into C package require pt::tclparam::configuration::snit 1.0.2 ; # PARAM/Tcl, snit::type package require pt::tclparam::configuration::tcloo 1.0.4 ; # PARAM/Tcl, TclOO class package require pt::cparam::configuration::critcl 1.0.2 ; # PARAM/C, in critcl # ### ### ### ######### ######### ######### ## Implementation namespace eval ::pt::pgen { namespace export json peg serial namespace ensemble create | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | package require pt::peg::to::peg ; # package require pt::peg::to::param ; # PARAM assembly, raw package require pt::peg::to::tclparam ; # PARAM assembly, embedded into Tcl package require pt::peg::to::cparam ; # PARAM assembly, embedded into C package require pt::tclparam::configuration::snit 1.0.2 ; # PARAM/Tcl, snit::type package require pt::tclparam::configuration::tcloo 1.0.4 ; # PARAM/Tcl, TclOO class package require pt::cparam::configuration::critcl 1.0.2 ; # PARAM/C, in critcl package require pt::cparam::configuration::tea ; # PARAM/C, in TEA # ### ### ### ######### ######### ######### ## Implementation namespace eval ::pt::pgen { namespace export json peg serial namespace ensemble create |
︙ | ︙ | |||
51 52 53 54 55 56 57 | return [Write {*}$args [pt::peg::from::peg convert $input]] } # # ## ### ##### ######## ############# ## Internals - Generating the parser. namespace eval ::pt::pgen::Write { | | | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | return [Write {*}$args [pt::peg::from::peg convert $input]] } # # ## ### ##### ######## ############# ## Internals - Generating the parser. namespace eval ::pt::pgen::Write { namespace export json peg container param snit oo critcl c tea namespace ensemble create } proc ::pt::pgen::Write::json {args} { # args = (option value)... grammar pt::peg::to::json configure {*}[lrange $args 0 end-1] return [pt::peg::to::json convert [lindex $args end]] |
︙ | ︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 | pt::tclparam::configuration::tcloo def \ $class $package $version \ {pt::peg::to::tclparam configure} return [pt::peg::to::tclparam convert [lindex $args end]] } proc ::pt::pgen::Write::critcl {args} { # args = (option value)... grammar # Class -> touches/defines variable 'class' # Package -> touches/defines variable 'package' # Version -> touches/defines variable 'version' pt::peg::to::cparam configure {*}[Package [Version [Class [lrange $args 0 end-1]]]] | > > > > > > > > > > > > > > > | 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 | pt::tclparam::configuration::tcloo def \ $class $package $version \ {pt::peg::to::tclparam configure} return [pt::peg::to::tclparam convert [lindex $args end]] } proc ::pt::pgen::Write::tea {args} { # args = (option value)... grammar # Class -> touches/defines variable 'class' # Package -> touches/defines variable 'package' # Version -> touches/defines variable 'version' pt::peg::to::cparam configure {*}[Package [Version [Class [lrange $args 0 end-1]]]] ClassPackageDefaults pt::cparam::configuration::tea def \ $class $package $version \ {pt::peg::to::cparam configure} return [pt::peg::to::cparam convert [lindex $args end]] } proc ::pt::pgen::Write::critcl {args} { # args = (option value)... grammar # Class -> touches/defines variable 'class' # Package -> touches/defines variable 'package' # Version -> touches/defines variable 'version' pt::peg::to::cparam configure {*}[Package [Version [Class [lrange $args 0 end-1]]]] |
︙ | ︙ |
Changes to modules/pt/pt_pgen.test.
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | support { useAccel [useTcllibC] struct/stack.tcl struct::stack ; # User: pt::rde TestAccelInit struct::stack ; # (tcl) useAccel [useTcllibC] struct/sets.tcl struct::set TestAccelInit struct::set use snit/snit.tcl snit use fileutil/fileutil.tcl fileutil ;# tests/common use textutil/adjust.tcl textutil::adjust useLocal pt_astree.tcl pt::ast useLocal pt_pexpression.tcl pt::pe useLocal pt_pexpr_op.tcl pt::pe::op useLocal pt_pegrammar.tcl pt::peg useLocal pt_peg_container.tcl pt::peg::container useAccel [useTcllibC] pt/pt_rdengine.tcl pt::rde ; # User: pt::parse::peg | > > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | support { useAccel [useTcllibC] struct/stack.tcl struct::stack ; # User: pt::rde TestAccelInit struct::stack ; # (tcl) useAccel [useTcllibC] struct/sets.tcl struct::set TestAccelInit struct::set if {![package vsatisfies [package present Tcl] 8.6]} { # Pull in try emulation for 8.5. Tcl 8.6 has it builtin. use try/try.tcl try } use snit/snit.tcl snit use fileutil/fileutil.tcl fileutil ;# tests/common use textutil/adjust.tcl textutil::adjust useLocal pt_util.tcl pt::util useLocal pt_astree.tcl pt::ast useLocal pt_pexpression.tcl pt::pe useLocal pt_pexpr_op.tcl pt::pe::op useLocal pt_pegrammar.tcl pt::peg useLocal pt_peg_container.tcl pt::peg::container useAccel [useTcllibC] pt/pt_rdengine.tcl pt::rde ; # User: pt::parse::peg |
︙ | ︙ | |||
67 68 69 70 71 72 73 74 75 76 77 78 79 80 | } testing { useLocal pt_pgen.tcl pt::pgen ;# Generator } set mytestdir tests/data # ------------------------------------------------------------------------- # While some of the C pieces are usually not required at runtime (like # C stack when RDE is also C), we are calling on the parser generator # here, which still may use a different implementation. So, no # shurtcuts, and full 16x expansion (2^4). TestAccelDo struct::set setimpl { | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | } testing { useLocal pt_pgen.tcl pt::pgen ;# Generator } set mytestdir tests/data # Table of test cases ... # Id PEG InText Error detail Readable char set chars {} lappend chars 0 \{ \{ [list t \{] \{ lappend chars 1 \[ \[ [list t \[] \[ lappend chars 2 \" \" [list t \"] \" lappend chars 3 \\033 \033 [list t \33] <ESC> lappend chars 4 \\n \n [list t \n] <LF> lappend chars 5 \\r \r [list t \r] <CR> lappend chars 6 \\t \t [list t \t] <TAB> # \b, \f, \v - Extend PEG grammar to recognize. Also \e = \33 lappend chars 7 \\010 \b [list t \b] <BS> lappend chars 8 \\014 \f [list t \f] <FF> lappend chars 9 \\013 \v [list t \v] <VTAB> lappend chars 10 \\007 \a [list t \a] <BEL> lappend chars 11 { } { } [list t { }] <SPACE> lappend chars 12 \\\\ \\ [list t \\] \\ # math symbol, circled asterix lappend chars 13 \\u229b \u229b [list t \u229b] \u229b # test all control characters ... (and DEL) # more characters: above ascii = unicode BMP. # Grammar for all test cases below, with the actual character mapped # in (replacing @). set gtemplate "PEG a_pe_grammar ('@') END;" set etemplate "Parse error at position 0 (Line 0, column 0).\n... X ...\n ^\nExpected one of\n* The character '@'\n" # ------------------------------------------------------------------------- # While some of the C pieces are usually not required at runtime (like # C stack when RDE is also C), we are calling on the parser generator # here, which still may use a different implementation. So, no # shurtcuts, and full 16x expansion (2^4). TestAccelDo struct::set setimpl { |
︙ | ︙ |
Changes to modules/pt/pt_rdengine_c.tcl.
︙ | ︙ | |||
72 73 74 75 76 77 78 | paramg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) paramg); } paramg->counter ++; | | | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | paramg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) paramg); } paramg->counter ++; sprintf (paramg->buf, "rde%ld", paramg->counter); return paramg->buf; #undef KEY } static void PARAMdeleteCmd (ClientData clientData) |
︙ | ︙ |
Changes to modules/pt/pt_rdengine_tcl.tcl.
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## Requisites package require Tcl 8.5 package require snit package require struct::stack 1.5 ; # Requiring peekr, getr, trim* methods package require pt::ast package require pt::pe # # ## ### ##### ######## ############# ##################### ## Implementation snit::type ::pt::rde_tcl { # # ## ### ##### ######## ############# ##################### | > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ## Requisites package require Tcl 8.5 package require snit package require struct::stack 1.5 ; # Requiring peekr, getr, trim* methods package require pt::ast package require pt::pe package require char ; # quoting # # ## ### ##### ######## ############# ##################### ## Implementation snit::type ::pt::rde_tcl { # # ## ### ##### ######## ############# ##################### |
︙ | ︙ | |||
585 586 587 588 589 590 591 | $mystackerr push $myerror return } # - -- --- ----- -------- ------------- --------------------- method si:next_str {tok} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_str ($tok)" | | | | | | | | | | | 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 | $mystackerr push $myerror return } # - -- --- ----- -------- ------------- --------------------- method si:next_str {tok} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_str ($tok)" # String = sequence of characters. # No need for all the intermediate stack churn. set n [string length $tok] set last [expr {$myloc + $n}] set max [string length $mytoken] incr myloc if {($last >= $max) && ![ExtendTCN [expr {$last - $max + 1}]]} { set myok 0 set myerror [list $myloc [list [pt::pe str $tok]]] # i:fail_return return } set lex [string range $mytoken $myloc $last] set mycurrent [string index $mytoken $last] # ATTENTION: The error output of this instruction is different # from a regular sequence of si:next_char instructions. The # error location will be the start of the string token we # wanted to match, and the message will contain the entire # string token. In the regular sequence we would see the exact # point of the mismatch instead, with the message containing # the expected character. set myok [expr {$tok eq $lex}] if {$myok} { set myloc $last set myerror {} } else { set myerror [list $myloc [list [pt::pe str $tok]]] incr myloc -1 } return } method si:next_class {tok} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_class ($tok)" # Class = Choice of characters. No need for stack churn. # i_input_next "\{t $c\}" # i:fail_return # i_test_<user class> incr myloc if {($myloc >= [string length $mytoken]) && ![ExtendTC]} { set myok 0 set myerror [list $myloc [list [pt::pe class $tok]]] # i:fail_return return } set mycurrent [string index $mytoken $myloc] # Note what is needle versus hay. The token, i.e. the string # of allowed characters is the hay in which the current # character is looked, making it the needle. set myok [expr {[string first $mycurrent $tok] >= 0}] if {$myok} { set myerror {} } else { set myerror [list $myloc [list [pt::pe class $tok]]] incr myloc -1 } return } method si:next_char {tok} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_char ($tok)" # i_input_next "\{t $c\}" # i:fail_return # i_test_char $c incr myloc if {($myloc >= [string length $mytoken]) && ![ExtendTC]} { set myok 0 set myerror [list $myloc [list [pt::pe terminal $tok]]] # i:fail_return return } set mycurrent [string index $mytoken $myloc] set myok [expr {$tok eq $mycurrent}] if {$myok} { set myerror {} } else { set myerror [list $myloc [list [pt::pe terminal $tok]]] incr myloc -1 } return } method si:next_range {toks toke} { ; #TRACE puts "[format %8d [incr count]] RDE si:next_range ($toks $toke)" #Asm::Ins i_input_next "\{.. $s $e\}" #Asm::Ins i:fail_return #Asm::Ins i_test_range $s $e incr myloc if {($myloc >= [string length $mytoken]) && ![ExtendTC]} { set myok 0 set myerror [list $myloc [list [pt::pe range $toks $toke]]] # i:fail_return return } set mycurrent [string index $mytoken $myloc] set myok [expr { ([string compare $toks $mycurrent] <= 0) && |
︙ | ︙ |
Changes to modules/pt/pt_util.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # -*- tcl -*- # Copyright (c) 2014 Andreas Kupries <[email protected]> # Utility commands for parser syntax errors. # # ## ### ##### ######## ############# ##################### ## Requirements package require Tcl 8.5 ; # Required runtime. # # ## ### ##### ######## ############# ##################### ## namespace eval ::pt::util { namespace export error2readable error2position error2text namespace ensemble create } # # ## ### ##### ######## ############# ## Public API proc ::pt::util::error2readable {error text} { lassign $error _ location msgs | > > > | 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 | # -*- tcl -*- # Copyright (c) 2014 Andreas Kupries <[email protected]> # Utility commands for parser syntax errors. # # ## ### ##### ######## ############# ##################### ## Requirements package require Tcl 8.5 ; # Required runtime. package require char # # ## ### ##### ######## ############# ##################### ## namespace eval ::pt::util { namespace export error2readable error2position error2text namespace ensemble create namespace import ::char::quote } # # ## ### ##### ######## ############# ## Public API proc ::pt::util::error2readable {error text} { lassign $error _ location msgs |
︙ | ︙ | |||
79 80 81 82 83 84 85 | set line [llength $lines] set col [string length [lindex $lines end]] return [list $line $col] } proc ::pt::util::Readables {msgs} { | > > > > > | > > > | > | | < | > > > > > > > > > > > | > > > | > > > | > | > > > | 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 | set line [llength $lines] set col [string length [lindex $lines end]] return [list $line $col] } proc ::pt::util::Readables {msgs} { set cl {} set r {} foreach pe $msgs { switch -exact -- [lindex $pe 0] { t { # Fuse to multiple 't'-tags into a single 'cl'-tag. lappend cl [lindex $pe 1] } cl { # Fuse multiple 'cl'-tags into one. foreach c [split $details] { lappend cl $c } } default { lappend r [Readable $pe] } } } if {[set n [llength $cl]]} { if {$n > 1} { lappend r [Readable [list cl [join [lsort -dict $cl] {}]]] } else { lappend r [Readable [list t [lindex $cl 0]]] } } return [lsort -dict $r] } proc ::pt::util::Readable {pe} { set details [lassign $pe tag] switch -exact -- $tag { t { set details [quote string {*}$details] set m "The character '$details'" } n { set m "The symbol $details" } .. { set details [quote string {*}$details] set m "A character in range '[join $details '-']'" } str { set details [join [quote string {*}[split $details {}]] {}] set m "A string \"$details\"" } cl { set details [join [quote string {*}[split $details {}]] {}] set m "A character in set \{$details\}" } alpha { set m "A unicode alphabetical character" } alnum { set m "A unicode alphanumerical character" } ascii { set m "An ascii character" } digit { set m "A unicode digit character" } graph { set m "A unicode printing character, but not space" } lower { set m "A unicode lower-case alphabetical character" } print { set m "A unicode printing character, including space" } |
︙ | ︙ |
Changes to modules/pt/rde_critcl/m.c.
︙ | ︙ | |||
15 16 17 18 19 20 21 | int param_AMARKED (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde amarked * [0] [1] */ | | | | | 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 | int param_AMARKED (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde amarked * [0] [1] */ long int mc, i; void** mv; Tcl_Obj** ov; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } rde_param_query_amark (p->p, &mc, &mv); ov = NALLOC (mc, Tcl_Obj*); for (i=0; i < mc; i++) { ov [i] = Tcl_NewIntObj ((long int) mv [i]); } Tcl_SetObjResult (interp, Tcl_NewListObj (mc, ov)); ckfree ((char*) ov); |
︙ | ︙ | |||
276 277 278 279 280 281 282 | param_LMARKED (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde lmarked * [0] [1] */ long int lc, i; | | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | param_LMARKED (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde lmarked * [0] [1] */ long int lc, i; void** lv; Tcl_Obj** ov; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } |
︙ | ︙ | |||
399 400 401 402 403 404 405 | for(he = Tcl_FirstHashEntry(nc, &hs); he != NULL; he = Tcl_NextHashEntry(&hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; | | | | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | for(he = Tcl_FirstHashEntry(nc, &hs); he != NULL; he = Tcl_NextHashEntry(&hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; long int loc = (long int) Tcl_GetHashKey (nc, he); kv [0] = Tcl_NewIntObj (loc); tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { long int symid = (long int) Tcl_GetHashKey (tablePtr, hec); const char* sym = rde_param_query_string (p->p, symid); kv [1] = Tcl_NewStringObj (sym,-1); Tcl_ListObjAppendElement (interp, res, Tcl_NewListObj (2, kv)); } |
︙ | ︙ | |||
451 452 453 454 455 456 457 | for(he = Tcl_FirstHashEntry(nc, &hs); he != NULL; he = Tcl_NextHashEntry(&hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; | | | | 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 | for(he = Tcl_FirstHashEntry(nc, &hs); he != NULL; he = Tcl_NextHashEntry(&hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; long int loc = (long int) Tcl_GetHashKey (nc, he); kv [0] = Tcl_NewIntObj (loc); tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); long int symid = (long int) Tcl_GetHashKey (tablePtr, hec); const char* sym = rde_param_query_string (p->p, symid); kv [1] = Tcl_NewStringObj (sym,-1); vv [0] = Tcl_NewIntObj (scs->CL); vv [1] = Tcl_NewIntObj (scs->ST); vv [2] = rde_param_query_er_tcl (p->p, scs->ER); |
︙ | ︙ | |||
728 729 730 731 732 733 734 | int param_I_er_nt (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde i_error_nonterminal SYMBOL * [0] [1] [2] */ | | | | 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 | int param_I_er_nt (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde i_error_nonterminal SYMBOL * [0] [1] [2] */ long int sym; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* * interning: n + space + symbol * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ sym = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, sym); return TCL_OK; } int param_I_er_popmerge (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) |
︙ | ︙ | |||
1085 1086 1087 1088 1089 1090 1091 | int param_I_symbol_restore (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde i_symbol_restore SYMBOL * [0] [1] [2] */ | > | | 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 | int param_I_symbol_restore (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde i_symbol_restore SYMBOL * [0] [1] [2] */ long int sym; int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
1112 1113 1114 1115 1116 1117 1118 | int param_I_symbol_save (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde i_symbol_save SYMBOL * [0] [1] [2] */ | | | 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | int param_I_symbol_save (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde i_symbol_save SYMBOL * [0] [1] [2] */ long int sym; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
1146 1147 1148 1149 1150 1151 1152 | Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } if (!rde_param_query_st (p->p)) { rde_param_i_value_clear (p->p); } else { | | | 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } if (!rde_param_query_st (p->p)) { rde_param_i_value_clear (p->p); } else { long int sym; /* * We cannot save the interned string id in the Tcl_Obj*, because this * is already taken by the argument of param_I_er_nt aka * i_error_nonterminal, due to literal sharing in procedure bodies. */ |
︙ | ︙ | |||
1193 1194 1195 1196 1197 1198 1199 | Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } if (!rde_param_query_st (p->p)) { rde_param_i_value_clear (p->p); } else { | | | 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 | Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } if (!rde_param_query_st (p->p)) { rde_param_i_value_clear (p->p); } else { long int sym; /* * We cannot save the interned string id in the Tcl_Obj*, because this * is already taken by the argument of param_I_er_nt aka * i_error_nonterminal, due to literal sharing in procedure bodies. */ |
︙ | ︙ | |||
1215 1216 1217 1218 1219 1220 1221 | int param_I_input_next (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde i_input_next MSG * [0] [1] [2] */ | | | | 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 | int param_I_input_next (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde i_input_next MSG * [0] [1] [2] */ long int msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "msg"); return TCL_ERROR; } /* * interning: msg as is. Already has PE operator in the message. */ msg = rde_ot_intern0 (p, objv [2]); rde_param_i_input_next (p->p, msg); return TCL_OK; } int param_I_test_alnum (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) |
︙ | ︙ | |||
1286 1287 1288 1289 1290 1291 1292 | return TCL_OK; } int param_I_test_char (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { | | | | 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | return TCL_OK; } int param_I_test_char (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { long int msg; char* ch; /* Syntax: rde i_test_char CHAR * [0] [1] [2] */ if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "tok"); return TCL_ERROR; } /* * interning: t + space + char */ ch = Tcl_GetString (objv [2]); msg = rde_ot_intern1 (p, "t", objv [2]); rde_param_i_test_char (p->p, ch, msg); return TCL_OK; } int param_I_test_control (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) |
︙ | ︙ | |||
1431 1432 1433 1434 1435 1436 1437 | return TCL_OK; } int param_I_test_range (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { | | | | 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 | return TCL_OK; } int param_I_test_range (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { long int msg; char* chs; char* che; /* Syntax: rde i_test_range START END * [0] [1] [2] [3] */ if (objc != 4) { Tcl_WrongNumArgs (interp, 2, objv, "toks toke"); return TCL_ERROR; } /* * interning: .. + space + char + space + char */ chs = Tcl_GetString (objv [2]); che = Tcl_GetString (objv [3]); msg = rde_ot_intern2 (p, "..", objv [2], objv[3]); rde_param_i_test_range (p->p, chs, che, msg); return TCL_OK; } int |
︙ | ︙ | |||
1778 1779 1780 1781 1782 1783 1784 | return TCL_OK; } int param_SI_next_char (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { | | | | | | | 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 | return TCL_OK; } int param_SI_next_char (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { long int msg; char* ch; /* Syntax: rde i_next_char CHAR * [0] [1] [2] */ if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "tok"); return TCL_ERROR; } /* * interning: t + space + char */ ch = Tcl_GetString (objv [2]); msg = rde_ot_intern1 (p, "t", objv [2]); rde_param_i_input_next (p->p, msg); if (rde_param_query_st (p->p)) { rde_param_i_test_char (p->p, ch, msg); } return TCL_OK; } int param_SI_next_range (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { long int msg; char* chs; char* che; /* Syntax: rde i_next_range START END * [0] [1] [2] [3] */ if (objc != 4) { Tcl_WrongNumArgs (interp, 2, objv, "toks toke"); return TCL_ERROR; } /* * interning: .. + space + char + space + char */ chs = Tcl_GetString (objv [2]); che = Tcl_GetString (objv [3]); msg = rde_ot_intern2 (p, "..", objv [2], objv[3]); rde_param_i_input_next (p->p, msg); if (rde_param_query_st (p->p)) { rde_param_i_test_range (p->p, chs, che, msg); } return TCL_OK; } int param_SI_next_alnum (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_alnum * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "alnum"); |
︙ | ︙ | |||
1865 1866 1867 1868 1869 1870 1871 | int param_SI_next_alpha (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_alpha * [0] [1] */ | | | 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 | int param_SI_next_alpha (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_alpha * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "alpha"); |
︙ | ︙ | |||
1888 1889 1890 1891 1892 1893 1894 | int param_SI_next_ascii (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_ascii * [0] [1] */ | | | 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 | int param_SI_next_ascii (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_ascii * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "ascii"); |
︙ | ︙ | |||
1911 1912 1913 1914 1915 1916 1917 | int param_SI_next_control (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_control * [0] [1] */ | | | 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 | int param_SI_next_control (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_control * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "control"); |
︙ | ︙ | |||
1934 1935 1936 1937 1938 1939 1940 | int param_SI_next_ddigit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_ddigit * [0] [1] */ | | | 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 | int param_SI_next_ddigit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_ddigit * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "ddigit"); |
︙ | ︙ | |||
1957 1958 1959 1960 1961 1962 1963 | int param_SI_next_digit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_digit * [0] [1] */ | | | 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 | int param_SI_next_digit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_digit * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "digit"); |
︙ | ︙ | |||
1980 1981 1982 1983 1984 1985 1986 | int param_SI_next_graph (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_graph * [0] [1] */ | | | 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 | int param_SI_next_graph (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_graph * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "graph"); |
︙ | ︙ | |||
2003 2004 2005 2006 2007 2008 2009 | int param_SI_next_lower (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_lower * [0] [1] */ | | | 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 | int param_SI_next_lower (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_lower * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "lower"); |
︙ | ︙ | |||
2026 2027 2028 2029 2030 2031 2032 | int param_SI_next_print (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_print * [0] [1] */ | | | 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 | int param_SI_next_print (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_print * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "print"); |
︙ | ︙ | |||
2049 2050 2051 2052 2053 2054 2055 | int param_SI_next_punct (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_punct * [0] [1] */ | | | 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 | int param_SI_next_punct (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_punct * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "punct"); |
︙ | ︙ | |||
2072 2073 2074 2075 2076 2077 2078 | int param_SI_next_space (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_space * [0] [1] */ | | | 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 | int param_SI_next_space (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_space * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "space"); |
︙ | ︙ | |||
2095 2096 2097 2098 2099 2100 2101 | int param_SI_next_upper (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_upper * [0] [1] */ | | | 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 | int param_SI_next_upper (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_upper * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "upper"); |
︙ | ︙ | |||
2118 2119 2120 2121 2122 2123 2124 | int param_SI_next_wordchar (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_wordchar * [0] [1] */ | | | 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 | int param_SI_next_wordchar (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_wordchar * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "wordchar"); |
︙ | ︙ | |||
2141 2142 2143 2144 2145 2146 2147 | int param_SI_next_xdigit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_xdigit * [0] [1] */ | | | 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 | int param_SI_next_xdigit (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:next_xdigit * [0] [1] */ long int msg; if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } msg = param_intern (p, "xdigit"); |
︙ | ︙ | |||
2308 2309 2310 2311 2312 2313 2314 | int param_SI_value_symbol_start (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:value_symbol_start SYMBOL * [0] [1] [2] */ | > | | 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 | int param_SI_value_symbol_start (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:value_symbol_start SYMBOL * [0] [1] [2] */ long int sym; int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
2343 2344 2345 2346 2347 2348 2349 | int param_SI_value_void_symbol_start (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:value_void_symbol_start SYMBOL * [0] [1] [2] */ | > | | 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 | int param_SI_value_void_symbol_start (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:value_void_symbol_start SYMBOL * [0] [1] [2] */ long int sym; int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
2375 2376 2377 2378 2379 2380 2381 | int param_SI_void_symbol_start (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:void_symbol_start SYMBOL * [0] [1] [2] */ | > | | 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 | int param_SI_void_symbol_start (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:void_symbol_start SYMBOL * [0] [1] [2] */ long int sym; int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
2409 2410 2411 2412 2413 2414 2415 | int param_SI_void_void_symbol_start (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:void_void_symbol_start SYMBOL * [0] [1] [2] */ | > | | 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 | int param_SI_void_void_symbol_start (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:void_void_symbol_start SYMBOL * [0] [1] [2] */ long int sym; int found; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
2440 2441 2442 2443 2444 2445 2446 | int param_SI_reduce_symbol_end (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:reduce_symbol_end SYMBOL * [0] [1] [2] */ | | | 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 | int param_SI_reduce_symbol_end (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:reduce_symbol_end SYMBOL * [0] [1] [2] */ long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
2472 2473 2474 2475 2476 2477 2478 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ | | | | 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_ast_pop_rewind (p->p); rde_param_i_loc_pop_discard (p->p); if (rde_param_query_st (p->p)) { rde_param_i_ast_value_push (p->p); } return TCL_OK; } int param_SI_void_leaf_symbol_end (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:void_leaf_symbol_end SYMBOL * [0] [1] [2] */ long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
2524 2525 2526 2527 2528 2529 2530 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ | | | | 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_loc_pop_discard (p->p); if (rde_param_query_st (p->p)) { rde_param_i_ast_value_push (p->p); } return TCL_OK; } int param_SI_value_leaf_symbol_end (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:value_leaf_symbol_end SYMBOL * [0] [1] [2] */ long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
2575 2576 2577 2578 2579 2580 2581 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ | | | | 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_ast_pop_rewind (p->p); rde_param_i_loc_pop_discard (p->p); if (rde_param_query_st (p->p)) { rde_param_i_ast_value_push (p->p); } return TCL_OK; } int param_SI_value_clear_symbol_end (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:value_clear_symbol_end SYMBOL * [0] [1] [2] */ long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
2622 2623 2624 2625 2626 2627 2628 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ | | | | 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_ast_pop_rewind (p->p); rde_param_i_loc_pop_discard (p->p); return TCL_OK; } int param_SI_void_clear_symbol_end (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { /* Syntax: rde si:void_clear_symbol_end SYMBOL * [0] [1] [2] */ long int sym, msg; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "symbol"); return TCL_ERROR; } /* |
︙ | ︙ | |||
2665 2666 2667 2668 2669 2670 2671 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ | | > | | > | | | 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 | * * The obj literal here is very likely shared with the arguments of * i_symbol_save/restore, and i_value_leaf/reduce, and derivatives. This * here is the only point between these where we save the string id in the * Tcl_Obj*. */ msg = rde_ot_intern1 (p, "n", objv [2]); rde_param_i_error_nonterminal (p->p, msg); rde_param_i_loc_pop_discard (p->p); return TCL_OK; } int param_SI_next_str (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { long int msg; int len, i; char* str; /* Syntax: rde i_next_char CHAR * [0] [1] [2] */ if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "tok"); return TCL_ERROR; } /* * interning: str + space + char */ str = Tcl_GetStringFromObj (objv [2], &len); msg = rde_ot_intern1 (p, "str", objv [2]); rde_param_i_next_str (p->p, str, msg); return TCL_OK; } int param_SI_next_class (RDE_STATE p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { long int msg; int len, i; char* class; /* Syntax: rde i_next_char CHAR * [0] [1] [2] */ if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "tok"); return TCL_ERROR; } /* * interning: cl + space + char */ class = Tcl_GetStringFromObj (objv [2], &len); msg = rde_ot_intern1 (p, "cl", objv [2]); rde_param_i_next_class (p->p, class, msg); return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to modules/pt/rde_critcl/ot.c.
︙ | ︙ | |||
21 22 23 24 25 26 27 | static Tcl_ObjType ot_type = { "tcllib/pt::rde/critcl", ot_free_rep, ot_dup_rep, ot_string_rep, ot_from_any }; | | > > > > | > > > > | > > > > | > > > > > > > > > | > | > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < | < | < < < < < < < < < < | < < < | < < < < < < | < | < < | < < < < < < | < | < < < < < < < < < < > > > > > > > > > | 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 | static Tcl_ObjType ot_type = { "tcllib/pt::rde/critcl", ot_free_rep, ot_dup_rep, ot_string_rep, ot_from_any }; static int IsCached (RDE_STATE p, Tcl_Obj* obj, long int* id); static long int Make (RDE_STATE p, Tcl_Obj* obj, const char* str); /* * = = == === ===== ======== ============= ===================== */ long int rde_ot_intern0 (RDE_STATE p, Tcl_Obj* detail) { long int id; TRACE (("rde_ot_intern0 (%p, %p = '%s')", p, detail, Tcl_GetString(detail))); if (IsCached (p, detail, &id)) { return id; } TRACE (("INTERNALIZE")); return Make (p, detail, Tcl_GetString (detail)); } long int rde_ot_intern1 (RDE_STATE p, const char* operator, Tcl_Obj* detail) { long int id; Tcl_DString buf; TRACE (("rde_ot_intern1 (%p, '%s' %p = '%s')", p, operator, detail, Tcl_GetString(detail))); if (IsCached (p, detail, &id)) { return id; } TRACE (("INTERNALIZE")); /* Create a list of operator + detail. * Using a DString. */ Tcl_DStringInit (&buf); Tcl_DStringAppendElement (&buf, operator); Tcl_DStringAppendElement (&buf, Tcl_GetString (detail)); id = Make (p, detail, Tcl_DStringValue (&buf)); Tcl_DStringFree (&buf); return id; } long int rde_ot_intern2 (RDE_STATE p, const char* operator, Tcl_Obj* detail1, Tcl_Obj* detail2) { long int id; Tcl_DString buf; TRACE (("rde_ot_intern2 (%p, '%s' %p = '%s', %p = '%s')", p, operator, detail1, Tcl_GetString(detail1) detail2, Tcl_GetString(detail2))); if (IsCached (p, detail1, &id)) { return id; } TRACE (("INTERNALIZE")); /* Create a list of operator + detail1 + detail2. * Using a DString. */ Tcl_DStringInit (&buf); Tcl_DStringAppendElement (&buf, operator); Tcl_DStringAppendElement (&buf, Tcl_GetString (detail1)); Tcl_DStringAppendElement (&buf, Tcl_GetString (detail2)); id = Make (p, detail1, Tcl_DStringValue (&buf)); Tcl_DStringFree (&buf); return id; } /* * = = == === ===== ======== ============= ===================== */ static int IsCached (RDE_STATE p, Tcl_Obj* obj, long int* id) { /* * Quick exit if we have a cached and valid value. */ if ((obj->typePtr == &ot_type) && (obj->internalRep.twoPtrValue.ptr1 == p)) { RDE_STRING* rs = (RDE_STRING*) obj->internalRep.twoPtrValue.ptr2; TRACE (("CACHED %p = %d", rs, rs->id)); *id = rs->id; return 1; } return 0; } static long int Make (RDE_STATE p, Tcl_Obj* obj, const char* str) { long int id = param_intern (p, str); RDE_STRING* rs = ALLOC (RDE_STRING); rs->next = p->sfirst; rs->self = obj; rs->id = id; p->sfirst = rs; /* Invalidate previous int.rep before setting our own. * Inlined copy of TclFreeIntRep() macro (tclInt.h) */ if ((obj)->typePtr && (obj)->typePtr->freeIntRepProc) { (obj)->typePtr->freeIntRepProc(obj); } obj->internalRep.twoPtrValue.ptr1 = p; obj->internalRep.twoPtrValue.ptr2 = rs; obj->typePtr = &ot_type; return id; } |
︙ | ︙ | |||
129 130 131 132 133 134 135 | RDE_STRING* iter = p->sfirst; while (iter->next != rs) { iter = iter->next; } iter->next = rs->next; } | | > > | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | RDE_STRING* iter = p->sfirst; while (iter->next != rs) { iter = iter->next; } iter->next = rs->next; } /* Drop the now un-tracked structure */ ckfree ((char*) rs); /* Nothing to release in the obj itself, just resetting references. */ obj->internalRep.twoPtrValue.ptr1 = NULL; obj->internalRep.twoPtrValue.ptr2 = NULL; } static void ot_dup_rep(Tcl_Obj* obj, Tcl_Obj* dup) { |
︙ | ︙ |
Changes to modules/pt/rde_critcl/ot.h.
1 2 3 4 5 6 7 8 9 10 11 | /* * = = == === ===== ======== ============= ===================== * == pt::rde (critcl) - Data Structures - ObjType for interned strings. */ #ifndef _RDE_DS_OT_H #define _RDE_DS_OT_H 1 #include "tcl.h" #include <p.h> /* State declarations */ | | > > > > > > > > > > | 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 | /* * = = == === ===== ======== ============= ===================== * == pt::rde (critcl) - Data Structures - ObjType for interned strings. */ #ifndef _RDE_DS_OT_H #define _RDE_DS_OT_H 1 #include "tcl.h" #include <p.h> /* State declarations */ long int rde_ot_intern0 (RDE_STATE p, Tcl_Obj* detail); long int rde_ot_intern1 (RDE_STATE p, const char* operator, Tcl_Obj* detail); long int rde_ot_intern2 (RDE_STATE p, const char* operator, Tcl_Obj* detail1, Tcl_Obj* detail2); #endif /* _RDE_DS_OT_H */ /* * Local Variables: * mode: c * c-basic-offset: 4 |
︙ | ︙ |
Changes to modules/pt/rde_critcl/p.c.
︙ | ︙ | |||
108 109 110 111 112 113 114 | TRACE (("Tcl_Command %p",c)); p->c = c; RETURNVOID; } | | | > | | | | | 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 | TRACE (("Tcl_Command %p",c)); p->c = c; RETURNVOID; } long int param_intern (RDE_STATE p, const char* literal) { long int res; int isnew; Tcl_HashEntry* hPtr; ENTER ("param_intern"); TRACE (("RDE_STATE %p",p)); TRACE (("CHAR* '%s'",literal)); hPtr = Tcl_FindHashEntry (&p->str, literal); if (hPtr) { res = (long int) Tcl_GetHashValue (hPtr); RETURN("CACHED %d",res); } hPtr = Tcl_CreateHashEntry(&p->str, literal, &isnew); ASSERT (isnew, "Should have found entry"); Tcl_SetHashValue (hPtr, p->numstr); if (p->numstr >= p->maxnum) { long int new; char** str; new = 2 * (p->maxnum ? p->maxnum : 8); TRACE (("extend to %d strings",new)); str = (char**) ckrealloc ((char*) p->string, new * sizeof(char*)); ASSERT (str,"Memory allocation failure for string table"); p->maxnum = new; |
︙ | ︙ |
Changes to modules/pt/rde_critcl/pInt.h.
︙ | ︙ | |||
24 25 26 27 28 29 30 | Tcl_HashTable str; /* Table to intern strings, i.e. convert them into * unique numerical indices for the PARAM instructions. */ /* And the counter mapping from ids to strings, this is handed to the * PARAM for use. */ | | | | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | Tcl_HashTable str; /* Table to intern strings, i.e. convert them into * unique numerical indices for the PARAM instructions. */ /* And the counter mapping from ids to strings, this is handed to the * PARAM for use. */ long int maxnum; /* NOTE -- */ long int numstr; /* This is, essentially, an RDE_STACK (char* elements) */ char** string; /* Convert over to that instead of replicating the code */ #ifdef RDE_TRACE int icount; /* Instruction counter, when tracing */ #endif } RDE_STATE_; long int param_intern (RDE_STATE p, const char* literal); #endif /* _P_H */ /* * Local Variables: * mode: c * c-basic-offset: 4 |
︙ | ︙ |
Changes to modules/pt/rde_critcl/param.c.
︙ | ︙ | |||
84 85 86 87 88 89 90 | /* * = = == === ===== ======== ============= ===================== */ static void ast_node_free (void* n); static void error_state_free (void* es); | | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | /* * = = == === ===== ======== ============= ===================== */ static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); |
︙ | ︙ | |||
299 300 301 302 303 304 305 | SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } |
︙ | ︙ | |||
352 353 354 355 356 357 358 | * quick return. */ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | * quick return. */ res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); /* * Note: We are peeking inside the (message) stack here and are * modifying it in place. This doesn't matter, we are using the stack * code for convenience, not for the ordering. */ qsort (mv, mc, sizeof (void*), er_int_compare); /* * Convert message ids to strings. We ignore duplicates, by comparing * to the last processed id. Here the sorting (see above) comes into * play, we know that duplicates are bunched together in runs, making * it easy to drop them. */ mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; /* inlined query_string */ ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } /* |
︙ | ︙ | |||
482 483 484 485 486 487 488 | { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } |
︙ | ︙ | |||
547 548 549 550 551 552 553 | SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { /* * Disabled. Generate only low-level errors until we have worked out how * to integrate symbol information with them. Do not forget where this * instruction is inlined - No such exist, places using the instruction * directly call on this function. */ |
︙ | ︙ | |||
654 655 656 657 658 659 660 | rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); |
︙ | ︙ | |||
716 717 718 719 720 721 722 | } /* * = = == === ===== ======== ============= ===================== */ SCOPE void | | > > > | | 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 | } /* * = = == === ===== ======== ============= ===================== */ SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { /* * We are at a known position, we can and do take the associated * character out of the token cache. * * FUTURE :: keep track of what location the data stored in CC is * for. If the location is identical no extraction is required. This * may help when a choice repeatedly tests the same character. */ rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); /* Note: BOUNDS(n) <=> [0..(n-1)]. * cc_len in [1..utfmax] <=> cc_len-1 in [0...utfmax-1] <=> BOUNDS(utfmax) */ ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || |
︙ | ︙ | |||
798 799 800 801 802 803 804 | } /* * = = == === ===== ======== ============= ===================== */ SCOPE int | | | 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 | } /* * = = == === ===== ======== ============= ===================== */ SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; /* * 2-level hash table keyed by location, and symbol ... |
︙ | ︙ | |||
837 838 839 840 841 842 843 | SV_SET (p, scs->SV); return 1; } SCOPE void | | | 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 | SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; |
︙ | ︙ | |||
941 942 943 944 945 946 947 | SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 | SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
992 993 994 995 996 997 998 | SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 | SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); |
︙ | ︙ | |||
1083 1084 1085 1086 1087 1088 1089 | SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; |
︙ | ︙ | |||
1149 1150 1151 1152 1153 1154 1155 | /* * = = == === ===== ======== ============= ===================== */ static int er_int_compare (const void* a, const void* b) { | > > > > | > > | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | /* * = = == === ===== ======== ============= ===================== */ static int er_int_compare (const void* a, const void* b) { /* a, b = pointers to element, as void*. * Actual element type is (void*), and * actually stored data is (long int). */ const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } /* * = = == === ===== ======== ============= ===================== * == Super Instructions. */ SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } /* * = = == === ===== ======== ============= ===================== */ SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void |
︙ | ︙ | |||
1521 1522 1523 1524 1525 1526 1527 | SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 | SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } /* |
︙ | ︙ | |||
1610 1611 1612 1613 1614 1615 1616 | rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 | rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } |
︙ | ︙ | |||
1668 1669 1670 1671 1672 1673 1674 | if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 | if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } /* * = = == === ===== ======== ============= ===================== */ SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; /* Future: Place match string into a shared table of constants, like error * messages, indexed by code. Precomputed length information. * * NOTE how we are modifying the error location after the fact. The |
︙ | ︙ | |||
1739 1740 1741 1742 1743 1744 1745 | } str = Tcl_UtfNext (str); } } SCOPE void | | | 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 | } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; |
︙ | ︙ |
Changes to modules/pt/rde_critcl/param.h.
︙ | ︙ | |||
41 42 43 44 45 46 47 | SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len); SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData); /* Accessors */ SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p); | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len); SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData); /* Accessors */ SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p); SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv); SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av); SCOPE const char* rde_param_query_in (RDE_PARAM p); SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len); SCOPE int rde_param_query_cl (RDE_PARAM p); SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p); SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er); SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev); |
︙ | ︙ | |||
68 69 70 71 72 73 74 | SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p); SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p); SCOPE void rde_param_i_ast_push (RDE_PARAM p); SCOPE void rde_param_i_ast_rewind (RDE_PARAM p); SCOPE void rde_param_i_ast_value_push (RDE_PARAM p); SCOPE void rde_param_i_error_clear (RDE_PARAM p); | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p); SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p); SCOPE void rde_param_i_ast_push (RDE_PARAM p); SCOPE void rde_param_i_ast_rewind (RDE_PARAM p); SCOPE void rde_param_i_ast_value_push (RDE_PARAM p); SCOPE void rde_param_i_error_clear (RDE_PARAM p); SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s); SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p); SCOPE void rde_param_i_error_push (RDE_PARAM p); SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p); SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p); SCOPE void rde_param_i_loc_push (RDE_PARAM p); SCOPE void rde_param_i_loc_rewind (RDE_PARAM p); SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m); SCOPE void rde_param_i_status_fail (RDE_PARAM p); SCOPE void rde_param_i_status_ok (RDE_PARAM p); SCOPE void rde_param_i_status_negate (RDE_PARAM p); SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s); SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s); SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int m); SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int m); SCOPE void rde_param_i_test_alnum (RDE_PARAM p); SCOPE void rde_param_i_test_alpha (RDE_PARAM p); SCOPE void rde_param_i_test_ascii (RDE_PARAM p); SCOPE void rde_param_i_test_control (RDE_PARAM p); SCOPE void rde_param_i_test_ddigit (RDE_PARAM p); SCOPE void rde_param_i_test_digit (RDE_PARAM p); SCOPE void rde_param_i_test_graph (RDE_PARAM p); SCOPE void rde_param_i_test_lower (RDE_PARAM p); SCOPE void rde_param_i_test_print (RDE_PARAM p); SCOPE void rde_param_i_test_punct (RDE_PARAM p); SCOPE void rde_param_i_test_space (RDE_PARAM p); SCOPE void rde_param_i_test_upper (RDE_PARAM p); SCOPE void rde_param_i_test_wordchar (RDE_PARAM p); SCOPE void rde_param_i_test_xdigit (RDE_PARAM p); SCOPE void rde_param_i_value_clear (RDE_PARAM p); SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s); SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s); /* Super Instructions - Aggregated common instruction sequences. */ SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s); SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s); SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s); SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s); SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m); SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m); SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m); SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m); SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m); SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m); SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m); SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m); SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m); SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p); SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p); SCOPE void rde_param_i_notahead_exit (RDE_PARAM p); SCOPE void rde_param_i_state_push_2 (RDE_PARAM p); SCOPE void rde_param_i_state_push_void (RDE_PARAM p); |
︙ | ︙ | |||
164 165 166 167 168 169 170 | SCOPE int rde_param_i_seq_value2value (RDE_PARAM p); SCOPE int rde_param_i_bra_void2void (RDE_PARAM p); SCOPE int rde_param_i_bra_void2value (RDE_PARAM p); SCOPE int rde_param_i_bra_value2void (RDE_PARAM p); SCOPE int rde_param_i_bra_value2value (RDE_PARAM p); | | | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | SCOPE int rde_param_i_seq_value2value (RDE_PARAM p); SCOPE int rde_param_i_bra_void2void (RDE_PARAM p); SCOPE int rde_param_i_bra_void2value (RDE_PARAM p); SCOPE int rde_param_i_bra_value2void (RDE_PARAM p); SCOPE int rde_param_i_bra_value2value (RDE_PARAM p); SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m); SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m); /* SKIP END */ #endif /* _RDE_DS_PARAM_H */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to modules/pt/rde_critcl/tc.c.
︙ | ︙ | |||
119 120 121 122 123 124 125 | return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); |
︙ | ︙ |
Added modules/pt/tests/char.tests.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | # -*- tcl -*- # Testsuite for char. # Called by the ../char.test driver file. test char-1.0 {char, wrong#args} -body { char } -returnCodes error \ -result {wrong # args: should be "char subcommand ?argument ...?"} test char-1.1 {char, bogus method} -body { char bogus } -returnCodes error \ -result {unknown or ambiguous subcommand "bogus": must be quote, or unquote} test char-1.2 {char, wrong#args} -body { char quote } -returnCodes error \ -result {wrong # args: should be "char quote subcommand ?argument ...?"} test char-1.3 {char, bogus method} -body { char quote bogus } -returnCodes error \ -result {unknown or ambiguous subcommand "bogus": must be comment, cstring, string, or tcl} #---------------------------------------------------------------------- test char-2.0 {char tcl, wrong#args} -body { char quote tcl } -returnCodes error -result {wrong # args: should be "char quote tcl ch ..."} test char-2.1 {char tcl, single char} -body { char quote tcl A } -result A test char-2.2 {char tcl, multi char} -body { char quote tcl A B } -result {A B} foreach {n label input expected} { 0 obrace \{ \\173 1 obrckt \[ \\133 2 dquote \" \\42 3 escape \033 \\33 4 lf \n \\n 5 space { } \\40 6 backslash \\ \\134 7 A A A 8 del \177 \\177 9 circast \u229b \\u229b } { test char-2.3.$n "char tcl, map $label" -body { char quote tcl $input } -result $expected # collect table columns for string and multi-arg tests. lappend ll $label lappend li $input lappend le $expected } test char-2.4 "char tcl, map string" -body { char quote tcl [join $li {}] } -result [join $le {}] test char-2.5 "char tcl, map multiple" -body { char quote tcl {*}$li } -result $le unset -nocomplain n label input expected ll li le #---------------------------------------------------------------------- test char-3.0 {char string, wrong#args} -body { char quote string } -returnCodes error -result {wrong # args: should be "char quote string ch ..."} test char-3.1 {char string, single char} -body { char quote string A } -result A test char-3.2 {char string, multi char} -body { char quote string A B } -result {A B} foreach {n label input expected} { 0 obrace \{ \{ 1 obrckt \[ \[ 2 dquote \" \" 3 escape \033 <ESC> 4 lf \n <LF> 5 space { } <SPACE> 6 backslash \\ \\ 7 A A A 8 del \177 <DEL> 9 circast \u229b \u229b } { test char-3.3.$n "char string, map $label" -body { char quote string $input } -result $expected # collect table columns for string and multi-arg tests. lappend ll $label lappend li $input lappend le $expected } test char-3.4 "char string, map string" -body { char quote string [join $li {}] } -result [join $le {}] test char-3.5 "char string, map multiple" -body { char quote string {*}$li } -result $le unset -nocomplain n label input expected ll li le #---------------------------------------------------------------------- test char-4.0 {char cstring, wrong#args} -body { char quote cstring } -returnCodes error -result {wrong # args: should be "char quote cstring ch ..."} test char-4.1 {char cstring, single char} -body { char quote cstring A } -result A test char-4.2 {char cstring, multi char} -body { char quote cstring A B } -result {A B} foreach {n label input expected} { 0 obrace \{ \\173 1 obrckt \[ \[ 2 dquote \" \\\" 3 escape \033 \\33 4 lf \n \\n 5 space { } { } 6 backslash \\ \\\\ 7 A A A 8 del \177 \\177 9 circast \u229b \\342\\212\\233 } { test char-4.3.$n "char cstring, map $label" -body { char quote cstring $input } -result $expected # collect table columns for string and multi-arg tests. lappend ll $label lappend li $input lappend le $expected } test char-4.4 "char cstring, map string" -body { char quote cstring [join $li {}] } -result [join $le {}] test char-4.5 "char cstring, map multiple" -body { char quote cstring {*}$li } -result $le unset -nocomplain n label input expected ll li le #---------------------------------------------------------------------- test char-5.0 {char comment, wrong#args} -body { char quote comment } -returnCodes error -result {wrong # args: should be "char quote comment ch ..."} test char-5.1 {char comment, single char} -body { char quote comment A } -result A test char-5.2 {char comment, multi char} -body { char quote comment A B } -result {A B} foreach {n label input expected} { 0 obrace \{ \\\{ 1 obrckt \[ \[ 2 dquote \" \\\" 3 escape \033 \\33 4 lf \n \\n 5 space { } <blank> 6 backslash \\ \\ 7 A A A 8 del \177 \\177 9 circast \u229b \\u229b } { test char-5.3.$n "char comment, map $label" -body { char quote comment $input } -result $expected # collect table columns for string and multi-arg tests. lappend ll $label lappend li $input lappend le $expected } test char-5.4 "char comment, map string" -body { char quote comment [join $li {}] } -result [join $le {}] test char-5.5 "char comment, map multiple" -body { char quote comment {*}$li } -result $le unset -nocomplain n label input expected ll li le #---------------------------------------------------------------------- return |
Changes to modules/pt/tests/common.
︙ | ︙ | |||
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | ## - snit proc make-parser {format glabel grammar} { global pcounter if {![info exist pcounter]} { set pcounter 0 } set debug 0 # should be preloaded by test suite. if {[catch { package present pt::pgen }]} { error "pt::pgen package required and not loaded. Please fix your testsuite." } # Options per format. # container : -name # critcl : -class -name # oo : -class -name # snit : -class -name lappend cmd pt::pgen peg $grammar $format -name G if {$format ne "container"} { | > > | > | > > > > | | | > | 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 | ## - snit proc make-parser {format glabel grammar} { global pcounter if {![info exist pcounter]} { set pcounter 0 } set debug 0 set keep 0 # should be preloaded by test suite. if {[catch { package present pt::pgen }]} { error "pt::pgen package required and not loaded. Please fix your testsuite." } # Options per format. # container : -name # critcl : -class -name # oo : -class -name # snit : -class -name set gc GC[incr pcounter] lappend cmd pt::pgen peg $grammar $format -name G if {$format ne "container"} { lappend cmd -class $gc } try { set code [eval $cmd] } trap {PT RDE SYNTAX} {e o} { error [pt::util error2readable $e $grammar] } # debugging generator output if {$debug} { set k [expr {$keep ? [open $gc$format w] : "stdout"}] puts $k "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $format ($glabel)" puts $k $code puts $k "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $format ($glabel)" if {$keep} { close $k } } # Now do format-specific post-processing of the generated code to # get a proper parser object. switch -exact -- $format { container { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/0_basic_arithmetic.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1753 1754 1755 1756 1757 1758 1759 | /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", | | | | 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 | /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", /* 20 = */ "t (", /* 21 = */ "t )", /* 22 = */ "n Expression", /* 23 = */ "Expression", /* 24 = */ "n Factor", /* 25 = */ "Factor", /* 26 = */ "cl */", /* 27 = */ "n MulOp", /* 28 = */ "MulOp", |
︙ | ︙ | |||
1866 1867 1868 1869 1870 1871 1872 | * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (p); | | | | 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 | * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "(", 20); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; rde_param_i_next_char (p, ")", 21); rde_param_i_state_merge_value (p); return; } static void sequence_18 (RDE_PARAM p) { /* * x |
︙ | ︙ | |||
2143 2144 2145 2146 2147 2148 2149 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/10_notahead.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1832 1833 1834 1835 1836 1837 1838 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/11_epsilon.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1796 1797 1798 1799 1800 1801 1802 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/1_functions.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1736 1737 1738 1739 1740 1741 1742 | /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "n Expression", /* 15 = */ "Expression", /* 16 = */ "n Function", /* 17 = */ "Function", | | | | 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 | /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "n Expression", /* 15 = */ "Expression", /* 16 = */ "n Function", /* 17 = */ "Function", /* 18 = */ "str sin(", /* 19 = */ "t )", /* 20 = */ "n Sinus", /* 21 = */ "Sinus" }; /* * Grammar Start Expression */ |
︙ | ︙ | |||
1808 1809 1810 1811 1812 1813 1814 | * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (p); | | | | 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 | * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "sin(", 18); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; rde_param_i_next_char (p, ")", 19); rde_param_i_state_merge_value (p); return; } } ## END of GENERATED CODE. DO NOT EDIT. |
︙ | ︙ | |||
1857 1858 1859 1860 1861 1862 1863 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/2_fun_arithmetic.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1756 1757 1758 1759 1760 1761 1762 | /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", | | | | | 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 | /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", /* 20 = */ "t (", /* 21 = */ "t )", /* 22 = */ "n Expression", /* 23 = */ "Expression", /* 24 = */ "n Factor", /* 25 = */ "Factor", /* 26 = */ "n Function", /* 27 = */ "Function", /* 28 = */ "cl */", /* 29 = */ "n MulOp", /* 30 = */ "MulOp", /* 31 = */ "n Number", /* 32 = */ "Number", /* 33 = */ "n Sign", /* 34 = */ "Sign", /* 35 = */ "str sin(", /* 36 = */ "n Sinus", /* 37 = */ "Sinus", /* 38 = */ "n Term", /* 39 = */ "Term" }; /* |
︙ | ︙ | |||
1878 1879 1880 1881 1882 1883 1884 | * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (p); | | | | 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 | * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "(", 20); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; rde_param_i_next_char (p, ")", 21); rde_param_i_state_merge_value (p); return; } static void sequence_19 (RDE_PARAM p) { /* * x |
︙ | ︙ | |||
2142 2143 2144 2145 2146 2147 2148 | * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (p); | | | | 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 | * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "sin(", 35); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; rde_param_i_next_char (p, ")", 21); rde_param_i_state_merge_value (p); return; } /* * value Symbol 'Term' */ |
︙ | ︙ | |||
2206 2207 2208 2209 2210 2211 2212 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/3_peg_itself.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1897 1898 1899 1900 1901 1902 1903 | /* 26 = */ "str <ascii>", /* 27 = */ "n ASCII", /* 28 = */ "ASCII", /* 29 = */ "n Attribute", /* 30 = */ "Attribute", /* 31 = */ "n Char", /* 32 = */ "Char", | | | | | | | | | 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 | /* 26 = */ "str <ascii>", /* 27 = */ "n ASCII", /* 28 = */ "ASCII", /* 29 = */ "n Attribute", /* 30 = */ "Attribute", /* 31 = */ "n Char", /* 32 = */ "Char", /* 33 = */ "t \\\\", /* 34 = */ ".. 0 2", /* 35 = */ ".. 0 7", /* 36 = */ "n CharOctalFull", /* 37 = */ "CharOctalFull", /* 38 = */ "n CharOctalPart", /* 39 = */ "CharOctalPart", /* 40 = */ "cl nrt'\\\"\\[\\]\\\\", /* 41 = */ "n CharSpecial", /* 42 = */ "CharSpecial", /* 43 = */ "dot", /* 44 = */ "n CharUnescaped", /* 45 = */ "CharUnescaped", /* 46 = */ "str \173\\u\175", /* 47 = */ "n CharUnicode", /* 48 = */ "CharUnicode", /* 49 = */ "n Class", /* 50 = */ "Class", /* 51 = */ "t )", /* 52 = */ "n CLOSE", /* 53 = */ "CLOSE", /* 54 = */ "t \\]", /* 55 = */ "n CLOSEB", /* 56 = */ "CLOSEB", /* 57 = */ "t :", /* 58 = */ "n COLON", /* 59 = */ "COLON", /* 60 = */ "t #", /* 61 = */ "n COMMENT", /* 62 = */ "COMMENT", /* 63 = */ "str <control>", /* 64 = */ "n CONTROL", /* 65 = */ "CONTROL", /* 66 = */ "t \173\"\175", /* 67 = */ "n DAPOSTROPH", /* 68 = */ "DAPOSTROPH", /* 69 = */ "str <ddigit>", /* 70 = */ "n DDIGIT", /* 71 = */ "DDIGIT", /* 72 = */ "n Definition", /* 73 = */ "Definition", /* 74 = */ "str <digit>", /* 75 = */ "n DIGIT", /* 76 = */ "DIGIT", /* 77 = */ "t .", /* 78 = */ "n DOT", /* 79 = */ "DOT", /* 80 = */ "n EOF", /* 81 = */ "EOF", /* 82 = */ "cl \173\n\r\175", /* 83 = */ "n EOL", /* 84 = */ "EOL", /* 85 = */ "n Expression", /* 86 = */ "Expression", /* 87 = */ "str END", /* 88 = */ "n Final", /* 89 = */ "Final", |
︙ | ︙ | |||
1980 1981 1982 1983 1984 1985 1986 | /* 109 = */ "Literal", /* 110 = */ "str <lower>", /* 111 = */ "n LOWER", /* 112 = */ "LOWER", /* 113 = */ "t !", /* 114 = */ "n NOT", /* 115 = */ "NOT", | | | | 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 | /* 109 = */ "Literal", /* 110 = */ "str <lower>", /* 111 = */ "n LOWER", /* 112 = */ "LOWER", /* 113 = */ "t !", /* 114 = */ "n NOT", /* 115 = */ "NOT", /* 116 = */ "t (", /* 117 = */ "n OPEN", /* 118 = */ "OPEN", /* 119 = */ "t \173[\175", /* 120 = */ "n OPENB", /* 121 = */ "OPENB", /* 122 = */ "str PEG", /* 123 = */ "n PEG", /* 124 = */ "PEG", /* 125 = */ "t +", /* 126 = */ "n PLUS", |
︙ | ︙ | |||
2007 2008 2009 2010 2011 2012 2013 | /* 136 = */ "n PUNCT", /* 137 = */ "PUNCT", /* 138 = */ "t ?", /* 139 = */ "n QUESTION", /* 140 = */ "QUESTION", /* 141 = */ "n Range", /* 142 = */ "Range", | | | 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 | /* 136 = */ "n PUNCT", /* 137 = */ "PUNCT", /* 138 = */ "t ?", /* 139 = */ "n QUESTION", /* 140 = */ "QUESTION", /* 141 = */ "n Range", /* 142 = */ "Range", /* 143 = */ "t \173;\175", /* 144 = */ "n SEMICOLON", /* 145 = */ "SEMICOLON", /* 146 = */ "n Sequence", /* 147 = */ "Sequence", /* 148 = */ "t /", /* 149 = */ "n SLASH", /* 150 = */ "SLASH", |
︙ | ︙ | |||
2320 2321 2322 2323 2324 2325 2326 | * '\' * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (p); | | | 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 | * '\' * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "2", 34); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "7", 35); rde_param_i_state_merge_void (p); |
︙ | ︙ | |||
2360 2361 2362 2363 2364 2365 2366 | * '\' * range (0 .. 7) * ? * range (0 .. 7) */ rde_param_i_state_push_void (p); | | | 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 | * '\' * range (0 .. 7) * ? * range (0 .. 7) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; optional_50 (p); rde_param_i_state_merge_void (p); return; } |
︙ | ︙ | |||
2406 2407 2408 2409 2410 2411 2412 | /* * x * '\' * [nrt'\"[]\] */ rde_param_i_state_push_void (p); | | | | 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 | /* * x * '\' * [nrt'\"[]\] */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_class (p, "nrt'\"[]\\", 40); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'CharUnescaped' */ |
︙ | ︙ | |||
2454 2455 2456 2457 2458 2459 2460 | static void notahead_61 (RDE_PARAM p) { /* * ! * '\' */ rde_param_i_loc_push (p); | | | 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 | static void notahead_61 (RDE_PARAM p) { /* * ! * '\' */ rde_param_i_loc_push (p); rde_param_i_next_char (p, "\\", 33); rde_param_i_notahead_exit (p); return; } /* * leaf Symbol 'CharUnicode' */ |
︙ | ︙ | |||
2500 2501 2502 2503 2504 2505 2506 | * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_void (p); | | | 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 | * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "\\u", 46); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_80 (p); rde_param_i_state_merge_void (p); return; } |
︙ | ︙ | |||
2707 2708 2709 2710 2711 2712 2713 | /* * x * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (p); | | | | 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 | /* * x * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, ")", 51); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'CLOSEB' */ static void sym_CLOSEB (RDE_PARAM p) { /* * ']' */ if (rde_param_i_symbol_void_start (p, 56)) return ; rde_param_i_next_char (p, "]", 54); rde_param_i_symbol_done_void (p, 56, 55); return; } /* * void Symbol 'COLON' */ |
︙ | ︙ | |||
2892 2893 2894 2895 2896 2897 2898 | static void sym_DAPOSTROPH (RDE_PARAM p) { /* * '\"' */ if (rde_param_i_symbol_void_start (p, 68)) return ; | | | 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 | static void sym_DAPOSTROPH (RDE_PARAM p) { /* * '\"' */ if (rde_param_i_symbol_void_start (p, 68)) return ; rde_param_i_next_char (p, "\"", 66); rde_param_i_symbol_done_void (p, 68, 67); return; } /* * leaf Symbol 'DDIGIT' */ |
︙ | ︙ | |||
3808 3809 3810 3811 3812 3813 3814 | /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (p); | | | | 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 | /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "(", 116); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'OPENB' */ static void sym_OPENB (RDE_PARAM p) { /* * '[' */ if (rde_param_i_symbol_void_start (p, 121)) return ; rde_param_i_next_char (p, "[", 119); rde_param_i_symbol_done_void (p, 121, 120); return; } /* * void Symbol 'PEG' */ |
︙ | ︙ | |||
4286 4287 4288 4289 4290 4291 4292 | /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (p); | | | 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 | /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, ";", 143); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* |
︙ | ︙ | |||
4745 4746 4747 4748 4749 4750 4751 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/4_choice.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1780 1781 1782 1783 1784 1785 1786 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/5_sequence.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1780 1781 1782 1783 1784 1785 1786 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/6_optional.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1793 1794 1795 1796 1797 1798 1799 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/7_kleene.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1795 1796 1797 1798 1799 1800 1801 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/8_pkleene.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1798 1799 1800 1801 1802 1803 1804 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam-critcl/9_ahead.
︙ | ︙ | |||
415 416 417 418 419 420 421 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; | | | | | | | | | | 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 | } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ |
︙ | ︙ | |||
648 649 650 651 652 653 654 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; | | | | | | | | | 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 | if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); |
︙ | ︙ | |||
778 779 780 781 782 783 784 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); | | | | 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 | SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void |
︙ | ︙ | |||
826 827 828 829 830 831 832 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; |
︙ | ︙ | |||
882 883 884 885 886 887 888 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); |
︙ | ︙ | |||
924 925 926 927 928 929 930 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void | | > | | 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 | } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { |
︙ | ︙ | |||
970 971 972 973 974 975 976 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } |
︙ | ︙ | |||
993 994 995 996 997 998 999 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); |
︙ | ︙ | |||
1106 1107 1108 1109 1110 1111 1112 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void | | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void | | | | 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 | } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { | | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) |
︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); | | | | | | 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); |
︙ | ︙ | |||
1832 1833 1834 1835 1836 1837 1838 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; | | | 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 | parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { |
︙ | ︙ |
Added modules/pt/tests/data/ok/peg_cparam-tea/0_basic_arithmetic.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void sym_AddOp (RDE_PARAM p); static void sym_Digit (RDE_PARAM p); static void sequence_9 (RDE_PARAM p); static void sequence_14 (RDE_PARAM p); static void kleene_16 (RDE_PARAM p); static void sequence_18 (RDE_PARAM p); static void choice_20 (RDE_PARAM p); static void sym_Expression (RDE_PARAM p); static void sequence_26 (RDE_PARAM p); static void kleene_28 (RDE_PARAM p); static void sequence_30 (RDE_PARAM p); static void sym_Factor (RDE_PARAM p); static void sym_MulOp (RDE_PARAM p); static void optional_36 (RDE_PARAM p); static void poskleene_39 (RDE_PARAM p); static void sequence_41 (RDE_PARAM p); static void sym_Number (RDE_PARAM p); static void sym_Sign (RDE_PARAM p); static void sym_Term (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [35] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", /* 20 = */ "t (", /* 21 = */ "t )", /* 22 = */ "n Expression", /* 23 = */ "Expression", /* 24 = */ "n Factor", /* 25 = */ "Factor", /* 26 = */ "cl */", /* 27 = */ "n MulOp", /* 28 = */ "MulOp", /* 29 = */ "n Number", /* 30 = */ "Number", /* 31 = */ "n Sign", /* 32 = */ "Sign", /* 33 = */ "n Term", /* 34 = */ "Term" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { sym_Expression (p); return; } /* * value Symbol 'AddOp' */ static void sym_AddOp (RDE_PARAM p) { /* * [-+] */ if (rde_param_i_symbol_start (p, 16)) return ; rde_param_i_next_class (p, "-+", 14); rde_param_i_symbol_done_leaf (p, 16, 15); return; } /* * value Symbol 'Digit' */ static void sym_Digit (RDE_PARAM p) { /* * [0123456789] */ if (rde_param_i_symbol_start (p, 19)) return ; rde_param_i_next_class (p, "0123456789", 17); rde_param_i_symbol_done_leaf (p, 19, 18); return; } /* * value Symbol 'Expression' */ static void sym_Expression (RDE_PARAM p) { /* * / * x * '\(' * (Expression) * '\)' * x * (Factor) * * * x * (MulOp) * (Factor) */ if (rde_param_i_symbol_start_d (p, 23)) return ; choice_20 (p); rde_param_i_symbol_done_d_reduce (p, 23, 22); return; } static void choice_20 (RDE_PARAM p) { /* * / * x * '\(' * (Expression) * '\)' * x * (Factor) * * * x * (MulOp) * (Factor) */ rde_param_i_state_push_value (p); sequence_9 (p); if (rde_param_i_bra_value2value(p)) return; sequence_18 (p); rde_param_i_state_merge_value (p); return; } static void sequence_9 (RDE_PARAM p) { /* * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "(", 20); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; rde_param_i_next_char (p, ")", 21); rde_param_i_state_merge_value (p); return; } static void sequence_18 (RDE_PARAM p) { /* * x * (Factor) * * * x * (MulOp) * (Factor) */ rde_param_i_state_push_value (p); sym_Factor (p); if (rde_param_i_seq_value2value(p)) return; kleene_16 (p); rde_param_i_state_merge_value (p); return; } static void kleene_16 (RDE_PARAM p) { /* * * * x * (MulOp) * (Factor) */ while (1) { rde_param_i_state_push_2 (p); sequence_14 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void sequence_14 (RDE_PARAM p) { /* * x * (MulOp) * (Factor) */ rde_param_i_state_push_value (p); sym_MulOp (p); if (rde_param_i_seq_value2value(p)) return; sym_Factor (p); rde_param_i_state_merge_value (p); return; } /* * value Symbol 'Factor' */ static void sym_Factor (RDE_PARAM p) { /* * x * (Term) * * * x * (AddOp) * (Term) */ if (rde_param_i_symbol_start_d (p, 25)) return ; sequence_30 (p); rde_param_i_symbol_done_d_reduce (p, 25, 24); return; } static void sequence_30 (RDE_PARAM p) { /* * x * (Term) * * * x * (AddOp) * (Term) */ rde_param_i_state_push_value (p); sym_Term (p); if (rde_param_i_seq_value2value(p)) return; kleene_28 (p); rde_param_i_state_merge_value (p); return; } static void kleene_28 (RDE_PARAM p) { /* * * * x * (AddOp) * (Term) */ while (1) { rde_param_i_state_push_2 (p); sequence_26 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void sequence_26 (RDE_PARAM p) { /* * x * (AddOp) * (Term) */ rde_param_i_state_push_value (p); sym_AddOp (p); if (rde_param_i_seq_value2value(p)) return; sym_Term (p); rde_param_i_state_merge_value (p); return; } /* * value Symbol 'MulOp' */ static void sym_MulOp (RDE_PARAM p) { /* * [\u002a\u002f] */ if (rde_param_i_symbol_start (p, 28)) return ; rde_param_i_next_class (p, "*/", 26); rde_param_i_symbol_done_leaf (p, 28, 27); return; } /* * value Symbol 'Number' */ static void sym_Number (RDE_PARAM p) { /* * x * ? * (Sign) * + * (Digit) */ if (rde_param_i_symbol_start_d (p, 30)) return ; sequence_41 (p); rde_param_i_symbol_done_d_reduce (p, 30, 29); return; } static void sequence_41 (RDE_PARAM p) { /* * x * ? * (Sign) * + * (Digit) */ rde_param_i_state_push_value (p); optional_36 (p); if (rde_param_i_seq_value2value(p)) return; poskleene_39 (p); rde_param_i_state_merge_value (p); return; } static void optional_36 (RDE_PARAM p) { /* * ? * (Sign) */ rde_param_i_state_push_2 (p); sym_Sign (p); rde_param_i_state_merge_ok (p); return; } static void poskleene_39 (RDE_PARAM p) { /* * + * (Digit) */ rde_param_i_loc_push (p); sym_Digit (p); if (rde_param_i_kleene_abort(p)) return; while (1) { rde_param_i_state_push_2 (p); sym_Digit (p); if (rde_param_i_kleene_close(p)) return; } return; } /* * value Symbol 'Sign' */ static void sym_Sign (RDE_PARAM p) { /* * [-+] */ if (rde_param_i_symbol_start (p, 32)) return ; rde_param_i_next_class (p, "-+", 14); rde_param_i_symbol_done_leaf (p, 32, 31); return; } /* * value Symbol 'Term' */ static void sym_Term (RDE_PARAM p) { /* * (Number) */ if (rde_param_i_symbol_start_d (p, 34)) return ; sym_Number (p); rde_param_i_symbol_done_d_reduce (p, 34, 33); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/10_notahead.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void notahead_3 (RDE_PARAM p); static void sequence_6 (RDE_PARAM p); static void sym_TEST (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [17] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "t a", /* 15 = */ "n TEST", /* 16 = */ "TEST" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { sym_TEST (p); return; } /* * value Symbol 'TEST' */ static void sym_TEST (RDE_PARAM p) { /* * x * ! * 'a' * (IDENTIFIER) */ if (rde_param_i_symbol_start (p, 16)) return ; sequence_6 (p); rde_param_i_symbol_done_leaf (p, 16, 15); return; } static void sequence_6 (RDE_PARAM p) { /* * x * ! * 'a' * (IDENTIFIER) */ rde_param_i_state_push_void (p); notahead_3 (p); if (rde_param_i_seq_void2void(p)) return; /* Undefined symbol 'IDENTIFIER' */; rde_param_i_status_fail (p); rde_param_i_state_merge_void (p); return; } static void notahead_3 (RDE_PARAM p) { /* * ! * 'a' */ rde_param_i_loc_push (p); rde_param_i_next_char (p, "a", 14); rde_param_i_notahead_exit (p); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/11_epsilon.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void choice_3 (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [15] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "t a" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { choice_3 (p); return; } static void choice_3 (RDE_PARAM p) { /* * / * 'a' * <epsilon> */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "a", 14); if (rde_param_i_bra_void2void(p)) return; rde_param_i_status_ok (p); rde_param_i_state_merge_void (p); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/1_functions.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void sym_Expression (RDE_PARAM p); static void sym_Function (RDE_PARAM p); static void sequence_9 (RDE_PARAM p); static void sym_Sinus (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [22] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "n Expression", /* 15 = */ "Expression", /* 16 = */ "n Function", /* 17 = */ "Function", /* 18 = */ "str sin(", /* 19 = */ "t )", /* 20 = */ "n Sinus", /* 21 = */ "Sinus" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { sym_Expression (p); return; } /* * value Symbol 'Expression' */ static void sym_Expression (RDE_PARAM p) { /* * (Function) */ if (rde_param_i_symbol_start_d (p, 15)) return ; sym_Function (p); rde_param_i_symbol_done_d_reduce (p, 15, 14); return; } /* * value Symbol 'Function' */ static void sym_Function (RDE_PARAM p) { /* * (Sinus) */ if (rde_param_i_symbol_start_d (p, 17)) return ; sym_Sinus (p); rde_param_i_symbol_done_d_reduce (p, 17, 16); return; } /* * value Symbol 'Sinus' */ static void sym_Sinus (RDE_PARAM p) { /* * x * "sin\(" * (Expression) * '\)' */ if (rde_param_i_symbol_start_d (p, 21)) return ; sequence_9 (p); rde_param_i_symbol_done_d_reduce (p, 21, 20); return; } static void sequence_9 (RDE_PARAM p) { /* * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "sin(", 18); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; rde_param_i_next_char (p, ")", 19); rde_param_i_state_merge_value (p); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/2_fun_arithmetic.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void sym_AddOp (RDE_PARAM p); static void sym_Digit (RDE_PARAM p); static void sequence_10 (RDE_PARAM p); static void sequence_15 (RDE_PARAM p); static void kleene_17 (RDE_PARAM p); static void sequence_19 (RDE_PARAM p); static void choice_21 (RDE_PARAM p); static void sym_Expression (RDE_PARAM p); static void sequence_27 (RDE_PARAM p); static void kleene_29 (RDE_PARAM p); static void sequence_31 (RDE_PARAM p); static void sym_Factor (RDE_PARAM p); static void sym_Function (RDE_PARAM p); static void sym_MulOp (RDE_PARAM p); static void optional_39 (RDE_PARAM p); static void poskleene_42 (RDE_PARAM p); static void sequence_44 (RDE_PARAM p); static void sym_Number (RDE_PARAM p); static void sym_Sign (RDE_PARAM p); static void sequence_52 (RDE_PARAM p); static void sym_Sinus (RDE_PARAM p); static void sym_Term (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [40] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", /* 20 = */ "t (", /* 21 = */ "t )", /* 22 = */ "n Expression", /* 23 = */ "Expression", /* 24 = */ "n Factor", /* 25 = */ "Factor", /* 26 = */ "n Function", /* 27 = */ "Function", /* 28 = */ "cl */", /* 29 = */ "n MulOp", /* 30 = */ "MulOp", /* 31 = */ "n Number", /* 32 = */ "Number", /* 33 = */ "n Sign", /* 34 = */ "Sign", /* 35 = */ "str sin(", /* 36 = */ "n Sinus", /* 37 = */ "Sinus", /* 38 = */ "n Term", /* 39 = */ "Term" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { sym_Expression (p); return; } /* * value Symbol 'AddOp' */ static void sym_AddOp (RDE_PARAM p) { /* * [-+] */ if (rde_param_i_symbol_start (p, 16)) return ; rde_param_i_next_class (p, "-+", 14); rde_param_i_symbol_done_leaf (p, 16, 15); return; } /* * value Symbol 'Digit' */ static void sym_Digit (RDE_PARAM p) { /* * [0123456789] */ if (rde_param_i_symbol_start (p, 19)) return ; rde_param_i_next_class (p, "0123456789", 17); rde_param_i_symbol_done_leaf (p, 19, 18); return; } /* * value Symbol 'Expression' */ static void sym_Expression (RDE_PARAM p) { /* * / * (Function) * x * '\(' * (Expression) * '\)' * x * (Factor) * * * x * (MulOp) * (Factor) */ if (rde_param_i_symbol_start_d (p, 23)) return ; choice_21 (p); rde_param_i_symbol_done_d_reduce (p, 23, 22); return; } static void choice_21 (RDE_PARAM p) { /* * / * (Function) * x * '\(' * (Expression) * '\)' * x * (Factor) * * * x * (MulOp) * (Factor) */ rde_param_i_state_push_value (p); sym_Function (p); if (rde_param_i_bra_value2value(p)) return; sequence_10 (p); if (rde_param_i_bra_value2value(p)) return; sequence_19 (p); rde_param_i_state_merge_value (p); return; } static void sequence_10 (RDE_PARAM p) { /* * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "(", 20); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; rde_param_i_next_char (p, ")", 21); rde_param_i_state_merge_value (p); return; } static void sequence_19 (RDE_PARAM p) { /* * x * (Factor) * * * x * (MulOp) * (Factor) */ rde_param_i_state_push_value (p); sym_Factor (p); if (rde_param_i_seq_value2value(p)) return; kleene_17 (p); rde_param_i_state_merge_value (p); return; } static void kleene_17 (RDE_PARAM p) { /* * * * x * (MulOp) * (Factor) */ while (1) { rde_param_i_state_push_2 (p); sequence_15 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void sequence_15 (RDE_PARAM p) { /* * x * (MulOp) * (Factor) */ rde_param_i_state_push_value (p); sym_MulOp (p); if (rde_param_i_seq_value2value(p)) return; sym_Factor (p); rde_param_i_state_merge_value (p); return; } /* * value Symbol 'Factor' */ static void sym_Factor (RDE_PARAM p) { /* * x * (Term) * * * x * (AddOp) * (Term) */ if (rde_param_i_symbol_start_d (p, 25)) return ; sequence_31 (p); rde_param_i_symbol_done_d_reduce (p, 25, 24); return; } static void sequence_31 (RDE_PARAM p) { /* * x * (Term) * * * x * (AddOp) * (Term) */ rde_param_i_state_push_value (p); sym_Term (p); if (rde_param_i_seq_value2value(p)) return; kleene_29 (p); rde_param_i_state_merge_value (p); return; } static void kleene_29 (RDE_PARAM p) { /* * * * x * (AddOp) * (Term) */ while (1) { rde_param_i_state_push_2 (p); sequence_27 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void sequence_27 (RDE_PARAM p) { /* * x * (AddOp) * (Term) */ rde_param_i_state_push_value (p); sym_AddOp (p); if (rde_param_i_seq_value2value(p)) return; sym_Term (p); rde_param_i_state_merge_value (p); return; } /* * value Symbol 'Function' */ static void sym_Function (RDE_PARAM p) { /* * (Sinus) */ if (rde_param_i_symbol_start_d (p, 27)) return ; sym_Sinus (p); rde_param_i_symbol_done_d_reduce (p, 27, 26); return; } /* * value Symbol 'MulOp' */ static void sym_MulOp (RDE_PARAM p) { /* * [\u002a\u002f] */ if (rde_param_i_symbol_start (p, 30)) return ; rde_param_i_next_class (p, "*/", 28); rde_param_i_symbol_done_leaf (p, 30, 29); return; } /* * value Symbol 'Number' */ static void sym_Number (RDE_PARAM p) { /* * x * ? * (Sign) * + * (Digit) */ if (rde_param_i_symbol_start_d (p, 32)) return ; sequence_44 (p); rde_param_i_symbol_done_d_reduce (p, 32, 31); return; } static void sequence_44 (RDE_PARAM p) { /* * x * ? * (Sign) * + * (Digit) */ rde_param_i_state_push_value (p); optional_39 (p); if (rde_param_i_seq_value2value(p)) return; poskleene_42 (p); rde_param_i_state_merge_value (p); return; } static void optional_39 (RDE_PARAM p) { /* * ? * (Sign) */ rde_param_i_state_push_2 (p); sym_Sign (p); rde_param_i_state_merge_ok (p); return; } static void poskleene_42 (RDE_PARAM p) { /* * + * (Digit) */ rde_param_i_loc_push (p); sym_Digit (p); if (rde_param_i_kleene_abort(p)) return; while (1) { rde_param_i_state_push_2 (p); sym_Digit (p); if (rde_param_i_kleene_close(p)) return; } return; } /* * value Symbol 'Sign' */ static void sym_Sign (RDE_PARAM p) { /* * [-+] */ if (rde_param_i_symbol_start (p, 34)) return ; rde_param_i_next_class (p, "-+", 14); rde_param_i_symbol_done_leaf (p, 34, 33); return; } /* * value Symbol 'Sinus' */ static void sym_Sinus (RDE_PARAM p) { /* * x * "sin\(" * (Expression) * '\)' */ if (rde_param_i_symbol_start_d (p, 37)) return ; sequence_52 (p); rde_param_i_symbol_done_d_reduce (p, 37, 36); return; } static void sequence_52 (RDE_PARAM p) { /* * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "sin(", 35); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; rde_param_i_next_char (p, ")", 21); rde_param_i_state_merge_value (p); return; } /* * value Symbol 'Term' */ static void sym_Term (RDE_PARAM p) { /* * (Number) */ if (rde_param_i_symbol_start_d (p, 39)) return ; sym_Number (p); rde_param_i_symbol_done_d_reduce (p, 39, 38); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/3_peg_itself.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void sequence_4 (RDE_PARAM p); static void sym_ALNUM (RDE_PARAM p); static void sequence_9 (RDE_PARAM p); static void sym_ALPHA (RDE_PARAM p); static void sequence_14 (RDE_PARAM p); static void sym_AND (RDE_PARAM p); static void sym_APOSTROPH (RDE_PARAM p); static void sequence_21 (RDE_PARAM p); static void sym_ASCII (RDE_PARAM p); static void choice_26 (RDE_PARAM p); static void sequence_29 (RDE_PARAM p); static void sym_Attribute (RDE_PARAM p); static void choice_37 (RDE_PARAM p); static void sym_Char (RDE_PARAM p); static void sequence_44 (RDE_PARAM p); static void sym_CharOctalFull (RDE_PARAM p); static void optional_50 (RDE_PARAM p); static void sequence_52 (RDE_PARAM p); static void sym_CharOctalPart (RDE_PARAM p); static void sequence_57 (RDE_PARAM p); static void sym_CharSpecial (RDE_PARAM p); static void notahead_61 (RDE_PARAM p); static void sequence_64 (RDE_PARAM p); static void sym_CharUnescaped (RDE_PARAM p); static void optional_72 (RDE_PARAM p); static void sequence_74 (RDE_PARAM p); static void optional_76 (RDE_PARAM p); static void sequence_78 (RDE_PARAM p); static void optional_80 (RDE_PARAM p); static void sequence_82 (RDE_PARAM p); static void sym_CharUnicode (RDE_PARAM p); static void notahead_87 (RDE_PARAM p); static void sequence_90 (RDE_PARAM p); static void kleene_92 (RDE_PARAM p); static void sequence_96 (RDE_PARAM p); static void sym_Class (RDE_PARAM p); static void sequence_101 (RDE_PARAM p); static void sym_CLOSE (RDE_PARAM p); static void sym_CLOSEB (RDE_PARAM p); static void sequence_108 (RDE_PARAM p); static void sym_COLON (RDE_PARAM p); static void notahead_113 (RDE_PARAM p); static void sequence_116 (RDE_PARAM p); static void kleene_118 (RDE_PARAM p); static void sequence_121 (RDE_PARAM p); static void sym_COMMENT (RDE_PARAM p); static void sequence_126 (RDE_PARAM p); static void sym_CONTROL (RDE_PARAM p); static void sym_DAPOSTROPH (RDE_PARAM p); static void sequence_133 (RDE_PARAM p); static void sym_DDIGIT (RDE_PARAM p); static void optional_137 (RDE_PARAM p); static void sequence_143 (RDE_PARAM p); static void sym_Definition (RDE_PARAM p); static void sequence_148 (RDE_PARAM p); static void sym_DIGIT (RDE_PARAM p); static void sequence_153 (RDE_PARAM p); static void sym_DOT (RDE_PARAM p); static void notahead_157 (RDE_PARAM p); static void sym_EOF (RDE_PARAM p); static void sym_EOL (RDE_PARAM p); static void sequence_165 (RDE_PARAM p); static void kleene_167 (RDE_PARAM p); static void sequence_169 (RDE_PARAM p); static void sym_Expression (RDE_PARAM p); static void sequence_176 (RDE_PARAM p); static void sym_Final (RDE_PARAM p); static void kleene_182 (RDE_PARAM p); static void sequence_186 (RDE_PARAM p); static void sym_Grammar (RDE_PARAM p); static void sequence_191 (RDE_PARAM p); static void sym_GRAPH (RDE_PARAM p); static void sequence_197 (RDE_PARAM p); static void sym_Header (RDE_PARAM p); static void choice_202 (RDE_PARAM p); static void choice_206 (RDE_PARAM p); static void kleene_208 (RDE_PARAM p); static void sequence_210 (RDE_PARAM p); static void sym_Ident (RDE_PARAM p); static void sequence_215 (RDE_PARAM p); static void sym_Identifier (RDE_PARAM p); static void sequence_220 (RDE_PARAM p); static void sym_IS (RDE_PARAM p); static void sequence_225 (RDE_PARAM p); static void sym_LEAF (RDE_PARAM p); static void notahead_230 (RDE_PARAM p); static void sequence_233 (RDE_PARAM p); static void kleene_235 (RDE_PARAM p); static void sequence_239 (RDE_PARAM p); static void notahead_243 (RDE_PARAM p); static void sequence_246 (RDE_PARAM p); static void kleene_248 (RDE_PARAM p); static void sequence_252 (RDE_PARAM p); static void choice_254 (RDE_PARAM p); static void sym_Literal (RDE_PARAM p); static void sequence_259 (RDE_PARAM p); static void sym_LOWER (RDE_PARAM p); static void sequence_264 (RDE_PARAM p); static void sym_NOT (RDE_PARAM p); static void sequence_269 (RDE_PARAM p); static void sym_OPEN (RDE_PARAM p); static void sym_OPENB (RDE_PARAM p); static void notahead_278 (RDE_PARAM p); static void sequence_281 (RDE_PARAM p); static void sym_PEG (RDE_PARAM p); static void sequence_286 (RDE_PARAM p); static void sym_PLUS (RDE_PARAM p); static void choice_291 (RDE_PARAM p); static void optional_293 (RDE_PARAM p); static void sequence_296 (RDE_PARAM p); static void sym_Prefix (RDE_PARAM p); static void sequence_317 (RDE_PARAM p); static void choice_322 (RDE_PARAM p); static void sym_Primary (RDE_PARAM p); static void sequence_327 (RDE_PARAM p); static void sym_PRINTABLE (RDE_PARAM p); static void sequence_332 (RDE_PARAM p); static void sym_PUNCT (RDE_PARAM p); static void sequence_337 (RDE_PARAM p); static void sym_QUESTION (RDE_PARAM p); static void sequence_343 (RDE_PARAM p); static void choice_346 (RDE_PARAM p); static void sym_Range (RDE_PARAM p); static void sequence_351 (RDE_PARAM p); static void sym_SEMICOLON (RDE_PARAM p); static void poskleene_355 (RDE_PARAM p); static void sym_Sequence (RDE_PARAM p); static void sequence_360 (RDE_PARAM p); static void sym_SLASH (RDE_PARAM p); static void sequence_365 (RDE_PARAM p); static void sym_SPACE (RDE_PARAM p); static void sequence_370 (RDE_PARAM p); static void sym_STAR (RDE_PARAM p); static void sym_StartExpr (RDE_PARAM p); static void choice_382 (RDE_PARAM p); static void optional_384 (RDE_PARAM p); static void sequence_386 (RDE_PARAM p); static void sym_Suffix (RDE_PARAM p); static void sym_TO (RDE_PARAM p); static void sequence_393 (RDE_PARAM p); static void sym_UPPER (RDE_PARAM p); static void sequence_398 (RDE_PARAM p); static void sym_VOID (RDE_PARAM p); static void choice_403 (RDE_PARAM p); static void kleene_405 (RDE_PARAM p); static void sym_WHITESPACE (RDE_PARAM p); static void sequence_410 (RDE_PARAM p); static void sym_WORDCHAR (RDE_PARAM p); static void sequence_415 (RDE_PARAM p); static void sym_XDIGIT (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [178] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "str <alnum>", /* 15 = */ "n ALNUM", /* 16 = */ "ALNUM", /* 17 = */ "str <alpha>", /* 18 = */ "n ALPHA", /* 19 = */ "ALPHA", /* 20 = */ "t &", /* 21 = */ "n AND", /* 22 = */ "AND", /* 23 = */ "t '", /* 24 = */ "n APOSTROPH", /* 25 = */ "APOSTROPH", /* 26 = */ "str <ascii>", /* 27 = */ "n ASCII", /* 28 = */ "ASCII", /* 29 = */ "n Attribute", /* 30 = */ "Attribute", /* 31 = */ "n Char", /* 32 = */ "Char", /* 33 = */ "t \\\\", /* 34 = */ ".. 0 2", /* 35 = */ ".. 0 7", /* 36 = */ "n CharOctalFull", /* 37 = */ "CharOctalFull", /* 38 = */ "n CharOctalPart", /* 39 = */ "CharOctalPart", /* 40 = */ "cl nrt'\\\"\\[\\]\\\\", /* 41 = */ "n CharSpecial", /* 42 = */ "CharSpecial", /* 43 = */ "dot", /* 44 = */ "n CharUnescaped", /* 45 = */ "CharUnescaped", /* 46 = */ "str \173\\u\175", /* 47 = */ "n CharUnicode", /* 48 = */ "CharUnicode", /* 49 = */ "n Class", /* 50 = */ "Class", /* 51 = */ "t )", /* 52 = */ "n CLOSE", /* 53 = */ "CLOSE", /* 54 = */ "t \\]", /* 55 = */ "n CLOSEB", /* 56 = */ "CLOSEB", /* 57 = */ "t :", /* 58 = */ "n COLON", /* 59 = */ "COLON", /* 60 = */ "t #", /* 61 = */ "n COMMENT", /* 62 = */ "COMMENT", /* 63 = */ "str <control>", /* 64 = */ "n CONTROL", /* 65 = */ "CONTROL", /* 66 = */ "t \173\"\175", /* 67 = */ "n DAPOSTROPH", /* 68 = */ "DAPOSTROPH", /* 69 = */ "str <ddigit>", /* 70 = */ "n DDIGIT", /* 71 = */ "DDIGIT", /* 72 = */ "n Definition", /* 73 = */ "Definition", /* 74 = */ "str <digit>", /* 75 = */ "n DIGIT", /* 76 = */ "DIGIT", /* 77 = */ "t .", /* 78 = */ "n DOT", /* 79 = */ "DOT", /* 80 = */ "n EOF", /* 81 = */ "EOF", /* 82 = */ "cl \173\n\r\175", /* 83 = */ "n EOL", /* 84 = */ "EOL", /* 85 = */ "n Expression", /* 86 = */ "Expression", /* 87 = */ "str END", /* 88 = */ "n Final", /* 89 = */ "Final", /* 90 = */ "n Grammar", /* 91 = */ "Grammar", /* 92 = */ "str <graph>", /* 93 = */ "n GRAPH", /* 94 = */ "GRAPH", /* 95 = */ "n Header", /* 96 = */ "Header", /* 97 = */ "cl _:", /* 98 = */ "n Ident", /* 99 = */ "Ident", /* 100 = */ "n Identifier", /* 101 = */ "Identifier", /* 102 = */ "str <-", /* 103 = */ "n IS", /* 104 = */ "IS", /* 105 = */ "str leaf", /* 106 = */ "n LEAF", /* 107 = */ "LEAF", /* 108 = */ "n Literal", /* 109 = */ "Literal", /* 110 = */ "str <lower>", /* 111 = */ "n LOWER", /* 112 = */ "LOWER", /* 113 = */ "t !", /* 114 = */ "n NOT", /* 115 = */ "NOT", /* 116 = */ "t (", /* 117 = */ "n OPEN", /* 118 = */ "OPEN", /* 119 = */ "t \173[\175", /* 120 = */ "n OPENB", /* 121 = */ "OPENB", /* 122 = */ "str PEG", /* 123 = */ "n PEG", /* 124 = */ "PEG", /* 125 = */ "t +", /* 126 = */ "n PLUS", /* 127 = */ "PLUS", /* 128 = */ "n Prefix", /* 129 = */ "Prefix", /* 130 = */ "n Primary", /* 131 = */ "Primary", /* 132 = */ "str <print>", /* 133 = */ "n PRINTABLE", /* 134 = */ "PRINTABLE", /* 135 = */ "str <punct>", /* 136 = */ "n PUNCT", /* 137 = */ "PUNCT", /* 138 = */ "t ?", /* 139 = */ "n QUESTION", /* 140 = */ "QUESTION", /* 141 = */ "n Range", /* 142 = */ "Range", /* 143 = */ "t \173;\175", /* 144 = */ "n SEMICOLON", /* 145 = */ "SEMICOLON", /* 146 = */ "n Sequence", /* 147 = */ "Sequence", /* 148 = */ "t /", /* 149 = */ "n SLASH", /* 150 = */ "SLASH", /* 151 = */ "str <space>", /* 152 = */ "n SPACE", /* 153 = */ "SPACE", /* 154 = */ "t *", /* 155 = */ "n STAR", /* 156 = */ "STAR", /* 157 = */ "n StartExpr", /* 158 = */ "StartExpr", /* 159 = */ "n Suffix", /* 160 = */ "Suffix", /* 161 = */ "t -", /* 162 = */ "n TO", /* 163 = */ "TO", /* 164 = */ "str <upper>", /* 165 = */ "n UPPER", /* 166 = */ "UPPER", /* 167 = */ "str void", /* 168 = */ "n VOID", /* 169 = */ "VOID", /* 170 = */ "n WHITESPACE", /* 171 = */ "WHITESPACE", /* 172 = */ "str <wordchar>", /* 173 = */ "n WORDCHAR", /* 174 = */ "WORDCHAR", /* 175 = */ "str <xdigit>", /* 176 = */ "n XDIGIT", /* 177 = */ "XDIGIT" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { sym_Grammar (p); return; } /* * leaf Symbol 'ALNUM' */ static void sym_ALNUM (RDE_PARAM p) { /* * x * "<alnum>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 16)) return ; sequence_4 (p); rde_param_i_symbol_done_leaf (p, 16, 15); return; } static void sequence_4 (RDE_PARAM p) { /* * x * "<alnum>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<alnum>", 14); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'ALPHA' */ static void sym_ALPHA (RDE_PARAM p) { /* * x * "<alpha>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 19)) return ; sequence_9 (p); rde_param_i_symbol_done_leaf (p, 19, 18); return; } static void sequence_9 (RDE_PARAM p) { /* * x * "<alpha>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<alpha>", 17); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'AND' */ static void sym_AND (RDE_PARAM p) { /* * x * '&' * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 22)) return ; sequence_14 (p); rde_param_i_symbol_done_leaf (p, 22, 21); return; } static void sequence_14 (RDE_PARAM p) { /* * x * '&' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "&", 20); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'APOSTROPH' */ static void sym_APOSTROPH (RDE_PARAM p) { /* * ''' */ if (rde_param_i_symbol_void_start (p, 25)) return ; rde_param_i_next_char (p, "'", 23); rde_param_i_symbol_done_void (p, 25, 24); return; } /* * leaf Symbol 'ASCII' */ static void sym_ASCII (RDE_PARAM p) { /* * x * "<ascii>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 28)) return ; sequence_21 (p); rde_param_i_symbol_done_leaf (p, 28, 27); return; } static void sequence_21 (RDE_PARAM p) { /* * x * "<ascii>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<ascii>", 26); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'Attribute' */ static void sym_Attribute (RDE_PARAM p) { /* * x * / * (VOID) * (LEAF) * (COLON) */ if (rde_param_i_symbol_start_d (p, 30)) return ; sequence_29 (p); rde_param_i_symbol_done_d_reduce (p, 30, 29); return; } static void sequence_29 (RDE_PARAM p) { /* * x * / * (VOID) * (LEAF) * (COLON) */ rde_param_i_state_push_value (p); choice_26 (p); if (rde_param_i_seq_value2value(p)) return; sym_COLON (p); rde_param_i_state_merge_value (p); return; } static void choice_26 (RDE_PARAM p) { /* * / * (VOID) * (LEAF) */ rde_param_i_state_push_value (p); sym_VOID (p); if (rde_param_i_bra_value2value(p)) return; sym_LEAF (p); rde_param_i_state_merge_value (p); return; } /* * value Symbol 'Char' */ static void sym_Char (RDE_PARAM p) { /* * / * (CharSpecial) * (CharOctalFull) * (CharOctalPart) * (CharUnicode) * (CharUnescaped) */ if (rde_param_i_symbol_start_d (p, 32)) return ; choice_37 (p); rde_param_i_symbol_done_d_reduce (p, 32, 31); return; } static void choice_37 (RDE_PARAM p) { /* * / * (CharSpecial) * (CharOctalFull) * (CharOctalPart) * (CharUnicode) * (CharUnescaped) */ rde_param_i_state_push_value (p); sym_CharSpecial (p); if (rde_param_i_bra_value2value(p)) return; sym_CharOctalFull (p); if (rde_param_i_bra_value2value(p)) return; sym_CharOctalPart (p); if (rde_param_i_bra_value2value(p)) return; sym_CharUnicode (p); if (rde_param_i_bra_value2value(p)) return; sym_CharUnescaped (p); rde_param_i_state_merge_value (p); return; } /* * leaf Symbol 'CharOctalFull' */ static void sym_CharOctalFull (RDE_PARAM p) { /* * x * '\' * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ if (rde_param_i_symbol_start (p, 37)) return ; sequence_44 (p); rde_param_i_symbol_done_leaf (p, 37, 36); return; } static void sequence_44 (RDE_PARAM p) { /* * x * '\' * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "2", 34); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "7", 35); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'CharOctalPart' */ static void sym_CharOctalPart (RDE_PARAM p) { /* * x * '\' * range (0 .. 7) * ? * range (0 .. 7) */ if (rde_param_i_symbol_start (p, 39)) return ; sequence_52 (p); rde_param_i_symbol_done_leaf (p, 39, 38); return; } static void sequence_52 (RDE_PARAM p) { /* * x * '\' * range (0 .. 7) * ? * range (0 .. 7) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_range (p, "0", "7", 35); if (rde_param_i_seq_void2void(p)) return; optional_50 (p); rde_param_i_state_merge_void (p); return; } static void optional_50 (RDE_PARAM p) { /* * ? * range (0 .. 7) */ rde_param_i_state_push_2 (p); rde_param_i_next_range (p, "0", "7", 35); rde_param_i_state_merge_ok (p); return; } /* * leaf Symbol 'CharSpecial' */ static void sym_CharSpecial (RDE_PARAM p) { /* * x * '\' * [nrt'\"[]\] */ if (rde_param_i_symbol_start (p, 42)) return ; sequence_57 (p); rde_param_i_symbol_done_leaf (p, 42, 41); return; } static void sequence_57 (RDE_PARAM p) { /* * x * '\' * [nrt'\"[]\] */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "\\", 33); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_class (p, "nrt'\"[]\\", 40); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'CharUnescaped' */ static void sym_CharUnescaped (RDE_PARAM p) { /* * x * ! * '\' * <dot> */ if (rde_param_i_symbol_start (p, 45)) return ; sequence_64 (p); rde_param_i_symbol_done_leaf (p, 45, 44); return; } static void sequence_64 (RDE_PARAM p) { /* * x * ! * '\' * <dot> */ rde_param_i_state_push_void (p); notahead_61 (p); if (rde_param_i_seq_void2void(p)) return; rde_param_i_input_next (p, 43); rde_param_i_state_merge_void (p); return; } static void notahead_61 (RDE_PARAM p) { /* * ! * '\' */ rde_param_i_loc_push (p); rde_param_i_next_char (p, "\\", 33); rde_param_i_notahead_exit (p); return; } /* * leaf Symbol 'CharUnicode' */ static void sym_CharUnicode (RDE_PARAM p) { /* * x * "\u" * <xdigit> * ? * x * <xdigit> * ? * x * <xdigit> * ? * <xdigit> */ if (rde_param_i_symbol_start (p, 48)) return ; sequence_82 (p); rde_param_i_symbol_done_leaf (p, 48, 47); return; } static void sequence_82 (RDE_PARAM p) { /* * x * "\u" * <xdigit> * ? * x * <xdigit> * ? * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "\\u", 46); if (rde_param_i_seq_void2void(p)) return; rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_80 (p); rde_param_i_state_merge_void (p); return; } static void optional_80 (RDE_PARAM p) { /* * ? * x * <xdigit> * ? * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_2 (p); sequence_78 (p); rde_param_i_state_merge_ok (p); return; } static void sequence_78 (RDE_PARAM p) { /* * x * <xdigit> * ? * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_void (p); rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_76 (p); rde_param_i_state_merge_void (p); return; } static void optional_76 (RDE_PARAM p) { /* * ? * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_2 (p); sequence_74 (p); rde_param_i_state_merge_ok (p); return; } static void sequence_74 (RDE_PARAM p) { /* * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_void (p); rde_param_i_next_xdigit (p, 13); if (rde_param_i_seq_void2void(p)) return; optional_72 (p); rde_param_i_state_merge_void (p); return; } static void optional_72 (RDE_PARAM p) { /* * ? * <xdigit> */ rde_param_i_state_push_2 (p); rde_param_i_next_xdigit (p, 13); rde_param_i_state_merge_ok (p); return; } /* * value Symbol 'Class' */ static void sym_Class (RDE_PARAM p) { /* * x * (OPENB) * * * x * ! * (CLOSEB) * (Range) * (CLOSEB) * (WHITESPACE) */ if (rde_param_i_symbol_start_d (p, 50)) return ; sequence_96 (p); rde_param_i_symbol_done_d_reduce (p, 50, 49); return; } static void sequence_96 (RDE_PARAM p) { /* * x * (OPENB) * * * x * ! * (CLOSEB) * (Range) * (CLOSEB) * (WHITESPACE) */ rde_param_i_state_push_void (p); sym_OPENB (p); if (rde_param_i_seq_void2value(p)) return; kleene_92 (p); if (rde_param_i_seq_value2value(p)) return; sym_CLOSEB (p); if (rde_param_i_seq_value2value(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_value (p); return; } static void kleene_92 (RDE_PARAM p) { /* * * * x * ! * (CLOSEB) * (Range) */ while (1) { rde_param_i_state_push_2 (p); sequence_90 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void sequence_90 (RDE_PARAM p) { /* * x * ! * (CLOSEB) * (Range) */ rde_param_i_state_push_void (p); notahead_87 (p); if (rde_param_i_seq_void2value(p)) return; sym_Range (p); rde_param_i_state_merge_value (p); return; } static void notahead_87 (RDE_PARAM p) { /* * ! * (CLOSEB) */ rde_param_i_loc_push (p); sym_CLOSEB (p); rde_param_i_notahead_exit (p); return; } /* * void Symbol 'CLOSE' */ static void sym_CLOSE (RDE_PARAM p) { /* * x * '\)' * (WHITESPACE) */ if (rde_param_i_symbol_void_start (p, 53)) return ; sequence_101 (p); rde_param_i_symbol_done_void (p, 53, 52); return; } static void sequence_101 (RDE_PARAM p) { /* * x * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, ")", 51); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'CLOSEB' */ static void sym_CLOSEB (RDE_PARAM p) { /* * ']' */ if (rde_param_i_symbol_void_start (p, 56)) return ; rde_param_i_next_char (p, "]", 54); rde_param_i_symbol_done_void (p, 56, 55); return; } /* * void Symbol 'COLON' */ static void sym_COLON (RDE_PARAM p) { /* * x * ':' * (WHITESPACE) */ if (rde_param_i_symbol_void_start (p, 59)) return ; sequence_108 (p); rde_param_i_symbol_done_void (p, 59, 58); return; } static void sequence_108 (RDE_PARAM p) { /* * x * ':' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, ":", 57); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'COMMENT' */ static void sym_COMMENT (RDE_PARAM p) { /* * x * '#' * * * x * ! * (EOL) * <dot> * (EOL) */ if (rde_param_i_symbol_void_start (p, 62)) return ; sequence_121 (p); rde_param_i_symbol_done_void (p, 62, 61); return; } static void sequence_121 (RDE_PARAM p) { /* * x * '#' * * * x * ! * (EOL) * <dot> * (EOL) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "#", 60); if (rde_param_i_seq_void2void(p)) return; kleene_118 (p); if (rde_param_i_seq_void2void(p)) return; sym_EOL (p); rde_param_i_state_merge_void (p); return; } static void kleene_118 (RDE_PARAM p) { /* * * * x * ! * (EOL) * <dot> */ while (1) { rde_param_i_state_push_2 (p); sequence_116 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void sequence_116 (RDE_PARAM p) { /* * x * ! * (EOL) * <dot> */ rde_param_i_state_push_void (p); notahead_113 (p); if (rde_param_i_seq_void2void(p)) return; rde_param_i_input_next (p, 43); rde_param_i_state_merge_void (p); return; } static void notahead_113 (RDE_PARAM p) { /* * ! * (EOL) */ rde_param_i_loc_push (p); sym_EOL (p); rde_param_i_notahead_exit (p); return; } /* * leaf Symbol 'CONTROL' */ static void sym_CONTROL (RDE_PARAM p) { /* * x * "<control>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 65)) return ; sequence_126 (p); rde_param_i_symbol_done_leaf (p, 65, 64); return; } static void sequence_126 (RDE_PARAM p) { /* * x * "<control>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<control>", 63); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'DAPOSTROPH' */ static void sym_DAPOSTROPH (RDE_PARAM p) { /* * '\"' */ if (rde_param_i_symbol_void_start (p, 68)) return ; rde_param_i_next_char (p, "\"", 66); rde_param_i_symbol_done_void (p, 68, 67); return; } /* * leaf Symbol 'DDIGIT' */ static void sym_DDIGIT (RDE_PARAM p) { /* * x * "<ddigit>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 71)) return ; sequence_133 (p); rde_param_i_symbol_done_leaf (p, 71, 70); return; } static void sequence_133 (RDE_PARAM p) { /* * x * "<ddigit>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<ddigit>", 69); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'Definition' */ static void sym_Definition (RDE_PARAM p) { /* * x * ? * (Attribute) * (Identifier) * (IS) * (Expression) * (SEMICOLON) */ if (rde_param_i_symbol_start_d (p, 73)) return ; sequence_143 (p); rde_param_i_symbol_done_d_reduce (p, 73, 72); return; } static void sequence_143 (RDE_PARAM p) { /* * x * ? * (Attribute) * (Identifier) * (IS) * (Expression) * (SEMICOLON) */ rde_param_i_state_push_value (p); optional_137 (p); if (rde_param_i_seq_value2value(p)) return; sym_Identifier (p); if (rde_param_i_seq_value2value(p)) return; sym_IS (p); if (rde_param_i_seq_value2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; sym_SEMICOLON (p); rde_param_i_state_merge_value (p); return; } static void optional_137 (RDE_PARAM p) { /* * ? * (Attribute) */ rde_param_i_state_push_2 (p); sym_Attribute (p); rde_param_i_state_merge_ok (p); return; } /* * leaf Symbol 'DIGIT' */ static void sym_DIGIT (RDE_PARAM p) { /* * x * "<digit>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 76)) return ; sequence_148 (p); rde_param_i_symbol_done_leaf (p, 76, 75); return; } static void sequence_148 (RDE_PARAM p) { /* * x * "<digit>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<digit>", 74); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'DOT' */ static void sym_DOT (RDE_PARAM p) { /* * x * '.' * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 79)) return ; sequence_153 (p); rde_param_i_symbol_done_leaf (p, 79, 78); return; } static void sequence_153 (RDE_PARAM p) { /* * x * '.' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, ".", 77); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'EOF' */ static void sym_EOF (RDE_PARAM p) { /* * ! * <dot> */ if (rde_param_i_symbol_void_start (p, 81)) return ; notahead_157 (p); rde_param_i_symbol_done_void (p, 81, 80); return; } static void notahead_157 (RDE_PARAM p) { /* * ! * <dot> */ rde_param_i_loc_push (p); rde_param_i_input_next (p, 43); rde_param_i_notahead_exit (p); return; } /* * void Symbol 'EOL' */ static void sym_EOL (RDE_PARAM p) { /* * [\n\r] */ if (rde_param_i_symbol_void_start (p, 84)) return ; rde_param_i_next_class (p, "\n\r", 82); rde_param_i_symbol_done_void (p, 84, 83); return; } /* * value Symbol 'Expression' */ static void sym_Expression (RDE_PARAM p) { /* * x * (Sequence) * * * x * (SLASH) * (Sequence) */ if (rde_param_i_symbol_start_d (p, 86)) return ; sequence_169 (p); rde_param_i_symbol_done_d_reduce (p, 86, 85); return; } static void sequence_169 (RDE_PARAM p) { /* * x * (Sequence) * * * x * (SLASH) * (Sequence) */ rde_param_i_state_push_value (p); sym_Sequence (p); if (rde_param_i_seq_value2value(p)) return; kleene_167 (p); rde_param_i_state_merge_value (p); return; } static void kleene_167 (RDE_PARAM p) { /* * * * x * (SLASH) * (Sequence) */ while (1) { rde_param_i_state_push_2 (p); sequence_165 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void sequence_165 (RDE_PARAM p) { /* * x * (SLASH) * (Sequence) */ rde_param_i_state_push_void (p); sym_SLASH (p); if (rde_param_i_seq_void2value(p)) return; sym_Sequence (p); rde_param_i_state_merge_value (p); return; } /* * void Symbol 'Final' */ static void sym_Final (RDE_PARAM p) { /* * x * "END" * (WHITESPACE) * (SEMICOLON) * (WHITESPACE) */ if (rde_param_i_symbol_void_start (p, 89)) return ; sequence_176 (p); rde_param_i_symbol_done_void (p, 89, 88); return; } static void sequence_176 (RDE_PARAM p) { /* * x * "END" * (WHITESPACE) * (SEMICOLON) * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "END", 87); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); if (rde_param_i_seq_void2void(p)) return; sym_SEMICOLON (p); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'Grammar' */ static void sym_Grammar (RDE_PARAM p) { /* * x * (WHITESPACE) * (Header) * * * (Definition) * (Final) * (EOF) */ if (rde_param_i_symbol_start_d (p, 91)) return ; sequence_186 (p); rde_param_i_symbol_done_d_reduce (p, 91, 90); return; } static void sequence_186 (RDE_PARAM p) { /* * x * (WHITESPACE) * (Header) * * * (Definition) * (Final) * (EOF) */ rde_param_i_state_push_void (p); sym_WHITESPACE (p); if (rde_param_i_seq_void2value(p)) return; sym_Header (p); if (rde_param_i_seq_value2value(p)) return; kleene_182 (p); if (rde_param_i_seq_value2value(p)) return; sym_Final (p); if (rde_param_i_seq_value2value(p)) return; sym_EOF (p); rde_param_i_state_merge_value (p); return; } static void kleene_182 (RDE_PARAM p) { /* * * * (Definition) */ while (1) { rde_param_i_state_push_2 (p); sym_Definition (p); if (rde_param_i_kleene_close(p)) return; } return; } /* * leaf Symbol 'GRAPH' */ static void sym_GRAPH (RDE_PARAM p) { /* * x * "<graph>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 94)) return ; sequence_191 (p); rde_param_i_symbol_done_leaf (p, 94, 93); return; } static void sequence_191 (RDE_PARAM p) { /* * x * "<graph>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<graph>", 92); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'Header' */ static void sym_Header (RDE_PARAM p) { /* * x * (PEG) * (Identifier) * (StartExpr) */ if (rde_param_i_symbol_start_d (p, 96)) return ; sequence_197 (p); rde_param_i_symbol_done_d_reduce (p, 96, 95); return; } static void sequence_197 (RDE_PARAM p) { /* * x * (PEG) * (Identifier) * (StartExpr) */ rde_param_i_state_push_void (p); sym_PEG (p); if (rde_param_i_seq_void2value(p)) return; sym_Identifier (p); if (rde_param_i_seq_value2value(p)) return; sym_StartExpr (p); rde_param_i_state_merge_value (p); return; } /* * leaf Symbol 'Ident' */ static void sym_Ident (RDE_PARAM p) { /* * x * / * [_:] * <alpha> * * * / * [_:] * <alnum> */ if (rde_param_i_symbol_start (p, 99)) return ; sequence_210 (p); rde_param_i_symbol_done_leaf (p, 99, 98); return; } static void sequence_210 (RDE_PARAM p) { /* * x * / * [_:] * <alpha> * * * / * [_:] * <alnum> */ rde_param_i_state_push_void (p); choice_202 (p); if (rde_param_i_seq_void2void(p)) return; kleene_208 (p); rde_param_i_state_merge_void (p); return; } static void choice_202 (RDE_PARAM p) { /* * / * [_:] * <alpha> */ rde_param_i_state_push_void (p); rde_param_i_next_class (p, "_:", 97); if (rde_param_i_bra_void2void(p)) return; rde_param_i_next_alpha (p, 1); rde_param_i_state_merge_void (p); return; } static void kleene_208 (RDE_PARAM p) { /* * * * / * [_:] * <alnum> */ while (1) { rde_param_i_state_push_2 (p); choice_206 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void choice_206 (RDE_PARAM p) { /* * / * [_:] * <alnum> */ rde_param_i_state_push_void (p); rde_param_i_next_class (p, "_:", 97); if (rde_param_i_bra_void2void(p)) return; rde_param_i_next_alnum (p, 0); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'Identifier' */ static void sym_Identifier (RDE_PARAM p) { /* * x * (Ident) * (WHITESPACE) */ if (rde_param_i_symbol_start_d (p, 101)) return ; sequence_215 (p); rde_param_i_symbol_done_d_reduce (p, 101, 100); return; } static void sequence_215 (RDE_PARAM p) { /* * x * (Ident) * (WHITESPACE) */ rde_param_i_state_push_value (p); sym_Ident (p); if (rde_param_i_seq_value2value(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_value (p); return; } /* * void Symbol 'IS' */ static void sym_IS (RDE_PARAM p) { /* * x * "<-" * (WHITESPACE) */ if (rde_param_i_symbol_void_start (p, 104)) return ; sequence_220 (p); rde_param_i_symbol_done_void (p, 104, 103); return; } static void sequence_220 (RDE_PARAM p) { /* * x * "<-" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<-", 102); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'LEAF' */ static void sym_LEAF (RDE_PARAM p) { /* * x * "leaf" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 107)) return ; sequence_225 (p); rde_param_i_symbol_done_leaf (p, 107, 106); return; } static void sequence_225 (RDE_PARAM p) { /* * x * "leaf" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "leaf", 105); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'Literal' */ static void sym_Literal (RDE_PARAM p) { /* * / * x * (APOSTROPH) * * * x * ! * (APOSTROPH) * (Char) * (APOSTROPH) * (WHITESPACE) * x * (DAPOSTROPH) * * * x * ! * (DAPOSTROPH) * (Char) * (DAPOSTROPH) * (WHITESPACE) */ if (rde_param_i_symbol_start_d (p, 109)) return ; choice_254 (p); rde_param_i_symbol_done_d_reduce (p, 109, 108); return; } static void choice_254 (RDE_PARAM p) { /* * / * x * (APOSTROPH) * * * x * ! * (APOSTROPH) * (Char) * (APOSTROPH) * (WHITESPACE) * x * (DAPOSTROPH) * * * x * ! * (DAPOSTROPH) * (Char) * (DAPOSTROPH) * (WHITESPACE) */ rde_param_i_state_push_value (p); sequence_239 (p); if (rde_param_i_bra_value2value(p)) return; sequence_252 (p); rde_param_i_state_merge_value (p); return; } static void sequence_239 (RDE_PARAM p) { /* * x * (APOSTROPH) * * * x * ! * (APOSTROPH) * (Char) * (APOSTROPH) * (WHITESPACE) */ rde_param_i_state_push_void (p); sym_APOSTROPH (p); if (rde_param_i_seq_void2value(p)) return; kleene_235 (p); if (rde_param_i_seq_value2value(p)) return; sym_APOSTROPH (p); if (rde_param_i_seq_value2value(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_value (p); return; } static void kleene_235 (RDE_PARAM p) { /* * * * x * ! * (APOSTROPH) * (Char) */ while (1) { rde_param_i_state_push_2 (p); sequence_233 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void sequence_233 (RDE_PARAM p) { /* * x * ! * (APOSTROPH) * (Char) */ rde_param_i_state_push_void (p); notahead_230 (p); if (rde_param_i_seq_void2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } static void notahead_230 (RDE_PARAM p) { /* * ! * (APOSTROPH) */ rde_param_i_loc_push (p); sym_APOSTROPH (p); rde_param_i_notahead_exit (p); return; } static void sequence_252 (RDE_PARAM p) { /* * x * (DAPOSTROPH) * * * x * ! * (DAPOSTROPH) * (Char) * (DAPOSTROPH) * (WHITESPACE) */ rde_param_i_state_push_void (p); sym_DAPOSTROPH (p); if (rde_param_i_seq_void2value(p)) return; kleene_248 (p); if (rde_param_i_seq_value2value(p)) return; sym_DAPOSTROPH (p); if (rde_param_i_seq_value2value(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_value (p); return; } static void kleene_248 (RDE_PARAM p) { /* * * * x * ! * (DAPOSTROPH) * (Char) */ while (1) { rde_param_i_state_push_2 (p); sequence_246 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void sequence_246 (RDE_PARAM p) { /* * x * ! * (DAPOSTROPH) * (Char) */ rde_param_i_state_push_void (p); notahead_243 (p); if (rde_param_i_seq_void2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } static void notahead_243 (RDE_PARAM p) { /* * ! * (DAPOSTROPH) */ rde_param_i_loc_push (p); sym_DAPOSTROPH (p); rde_param_i_notahead_exit (p); return; } /* * leaf Symbol 'LOWER' */ static void sym_LOWER (RDE_PARAM p) { /* * x * "<lower>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 112)) return ; sequence_259 (p); rde_param_i_symbol_done_leaf (p, 112, 111); return; } static void sequence_259 (RDE_PARAM p) { /* * x * "<lower>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<lower>", 110); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'NOT' */ static void sym_NOT (RDE_PARAM p) { /* * x * '!' * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 115)) return ; sequence_264 (p); rde_param_i_symbol_done_leaf (p, 115, 114); return; } static void sequence_264 (RDE_PARAM p) { /* * x * '!' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "!", 113); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'OPEN' */ static void sym_OPEN (RDE_PARAM p) { /* * x * '\(' * (WHITESPACE) */ if (rde_param_i_symbol_void_start (p, 118)) return ; sequence_269 (p); rde_param_i_symbol_done_void (p, 118, 117); return; } static void sequence_269 (RDE_PARAM p) { /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "(", 116); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'OPENB' */ static void sym_OPENB (RDE_PARAM p) { /* * '[' */ if (rde_param_i_symbol_void_start (p, 121)) return ; rde_param_i_next_char (p, "[", 119); rde_param_i_symbol_done_void (p, 121, 120); return; } /* * void Symbol 'PEG' */ static void sym_PEG (RDE_PARAM p) { /* * x * "PEG" * ! * / * [_:] * <alnum> * (WHITESPACE) */ if (rde_param_i_symbol_void_start (p, 124)) return ; sequence_281 (p); rde_param_i_symbol_done_void (p, 124, 123); return; } static void sequence_281 (RDE_PARAM p) { /* * x * "PEG" * ! * / * [_:] * <alnum> * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "PEG", 122); if (rde_param_i_seq_void2void(p)) return; notahead_278 (p); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } static void notahead_278 (RDE_PARAM p) { /* * ! * / * [_:] * <alnum> */ rde_param_i_loc_push (p); choice_206 (p); rde_param_i_notahead_exit (p); return; } /* * leaf Symbol 'PLUS' */ static void sym_PLUS (RDE_PARAM p) { /* * x * '+' * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 127)) return ; sequence_286 (p); rde_param_i_symbol_done_leaf (p, 127, 126); return; } static void sequence_286 (RDE_PARAM p) { /* * x * '+' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "+", 125); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'Prefix' */ static void sym_Prefix (RDE_PARAM p) { /* * x * ? * / * (AND) * (NOT) * (Suffix) */ if (rde_param_i_symbol_start_d (p, 129)) return ; sequence_296 (p); rde_param_i_symbol_done_d_reduce (p, 129, 128); return; } static void sequence_296 (RDE_PARAM p) { /* * x * ? * / * (AND) * (NOT) * (Suffix) */ rde_param_i_state_push_value (p); optional_293 (p); if (rde_param_i_seq_value2value(p)) return; sym_Suffix (p); rde_param_i_state_merge_value (p); return; } static void optional_293 (RDE_PARAM p) { /* * ? * / * (AND) * (NOT) */ rde_param_i_state_push_2 (p); choice_291 (p); rde_param_i_state_merge_ok (p); return; } static void choice_291 (RDE_PARAM p) { /* * / * (AND) * (NOT) */ rde_param_i_state_push_value (p); sym_AND (p); if (rde_param_i_bra_value2value(p)) return; sym_NOT (p); rde_param_i_state_merge_value (p); return; } /* * value Symbol 'Primary' */ static void sym_Primary (RDE_PARAM p) { /* * / * (ALNUM) * (ALPHA) * (ASCII) * (CONTROL) * (DDIGIT) * (DIGIT) * (GRAPH) * (LOWER) * (PRINTABLE) * (PUNCT) * (SPACE) * (UPPER) * (WORDCHAR) * (XDIGIT) * (Identifier) * x * (OPEN) * (Expression) * (CLOSE) * (Literal) * (Class) * (DOT) */ if (rde_param_i_symbol_start_d (p, 131)) return ; choice_322 (p); rde_param_i_symbol_done_d_reduce (p, 131, 130); return; } static void choice_322 (RDE_PARAM p) { /* * / * (ALNUM) * (ALPHA) * (ASCII) * (CONTROL) * (DDIGIT) * (DIGIT) * (GRAPH) * (LOWER) * (PRINTABLE) * (PUNCT) * (SPACE) * (UPPER) * (WORDCHAR) * (XDIGIT) * (Identifier) * x * (OPEN) * (Expression) * (CLOSE) * (Literal) * (Class) * (DOT) */ rde_param_i_state_push_value (p); sym_ALNUM (p); if (rde_param_i_bra_value2value(p)) return; sym_ALPHA (p); if (rde_param_i_bra_value2value(p)) return; sym_ASCII (p); if (rde_param_i_bra_value2value(p)) return; sym_CONTROL (p); if (rde_param_i_bra_value2value(p)) return; sym_DDIGIT (p); if (rde_param_i_bra_value2value(p)) return; sym_DIGIT (p); if (rde_param_i_bra_value2value(p)) return; sym_GRAPH (p); if (rde_param_i_bra_value2value(p)) return; sym_LOWER (p); if (rde_param_i_bra_value2value(p)) return; sym_PRINTABLE (p); if (rde_param_i_bra_value2value(p)) return; sym_PUNCT (p); if (rde_param_i_bra_value2value(p)) return; sym_SPACE (p); if (rde_param_i_bra_value2value(p)) return; sym_UPPER (p); if (rde_param_i_bra_value2value(p)) return; sym_WORDCHAR (p); if (rde_param_i_bra_value2value(p)) return; sym_XDIGIT (p); if (rde_param_i_bra_value2value(p)) return; sym_Identifier (p); if (rde_param_i_bra_value2value(p)) return; sequence_317 (p); if (rde_param_i_bra_value2value(p)) return; sym_Literal (p); if (rde_param_i_bra_value2value(p)) return; sym_Class (p); if (rde_param_i_bra_value2value(p)) return; sym_DOT (p); rde_param_i_state_merge_value (p); return; } static void sequence_317 (RDE_PARAM p) { /* * x * (OPEN) * (Expression) * (CLOSE) */ rde_param_i_state_push_void (p); sym_OPEN (p); if (rde_param_i_seq_void2value(p)) return; sym_Expression (p); if (rde_param_i_seq_value2value(p)) return; sym_CLOSE (p); rde_param_i_state_merge_value (p); return; } /* * leaf Symbol 'PRINTABLE' */ static void sym_PRINTABLE (RDE_PARAM p) { /* * x * "<print>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 134)) return ; sequence_327 (p); rde_param_i_symbol_done_leaf (p, 134, 133); return; } static void sequence_327 (RDE_PARAM p) { /* * x * "<print>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<print>", 132); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'PUNCT' */ static void sym_PUNCT (RDE_PARAM p) { /* * x * "<punct>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 137)) return ; sequence_332 (p); rde_param_i_symbol_done_leaf (p, 137, 136); return; } static void sequence_332 (RDE_PARAM p) { /* * x * "<punct>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<punct>", 135); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'QUESTION' */ static void sym_QUESTION (RDE_PARAM p) { /* * x * '?' * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 140)) return ; sequence_337 (p); rde_param_i_symbol_done_leaf (p, 140, 139); return; } static void sequence_337 (RDE_PARAM p) { /* * x * '?' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "?", 138); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'Range' */ static void sym_Range (RDE_PARAM p) { /* * / * x * (Char) * (TO) * (Char) * (Char) */ if (rde_param_i_symbol_start_d (p, 142)) return ; choice_346 (p); rde_param_i_symbol_done_d_reduce (p, 142, 141); return; } static void choice_346 (RDE_PARAM p) { /* * / * x * (Char) * (TO) * (Char) * (Char) */ rde_param_i_state_push_value (p); sequence_343 (p); if (rde_param_i_bra_value2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } static void sequence_343 (RDE_PARAM p) { /* * x * (Char) * (TO) * (Char) */ rde_param_i_state_push_value (p); sym_Char (p); if (rde_param_i_seq_value2value(p)) return; sym_TO (p); if (rde_param_i_seq_value2value(p)) return; sym_Char (p); rde_param_i_state_merge_value (p); return; } /* * void Symbol 'SEMICOLON' */ static void sym_SEMICOLON (RDE_PARAM p) { /* * x * ';' * (WHITESPACE) */ if (rde_param_i_symbol_void_start (p, 145)) return ; sequence_351 (p); rde_param_i_symbol_done_void (p, 145, 144); return; } static void sequence_351 (RDE_PARAM p) { /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, ";", 143); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'Sequence' */ static void sym_Sequence (RDE_PARAM p) { /* * + * (Prefix) */ if (rde_param_i_symbol_start_d (p, 147)) return ; poskleene_355 (p); rde_param_i_symbol_done_d_reduce (p, 147, 146); return; } static void poskleene_355 (RDE_PARAM p) { /* * + * (Prefix) */ rde_param_i_loc_push (p); sym_Prefix (p); if (rde_param_i_kleene_abort(p)) return; while (1) { rde_param_i_state_push_2 (p); sym_Prefix (p); if (rde_param_i_kleene_close(p)) return; } return; } /* * void Symbol 'SLASH' */ static void sym_SLASH (RDE_PARAM p) { /* * x * '/' * (WHITESPACE) */ if (rde_param_i_symbol_void_start (p, 150)) return ; sequence_360 (p); rde_param_i_symbol_done_void (p, 150, 149); return; } static void sequence_360 (RDE_PARAM p) { /* * x * '/' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "/", 148); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'SPACE' */ static void sym_SPACE (RDE_PARAM p) { /* * x * "<space>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 153)) return ; sequence_365 (p); rde_param_i_symbol_done_leaf (p, 153, 152); return; } static void sequence_365 (RDE_PARAM p) { /* * x * "<space>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<space>", 151); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'STAR' */ static void sym_STAR (RDE_PARAM p) { /* * x * '*' * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 156)) return ; sequence_370 (p); rde_param_i_symbol_done_leaf (p, 156, 155); return; } static void sequence_370 (RDE_PARAM p) { /* * x * '*' * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_char (p, "*", 154); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * value Symbol 'StartExpr' */ static void sym_StartExpr (RDE_PARAM p) { /* * x * (OPEN) * (Expression) * (CLOSE) */ if (rde_param_i_symbol_start_d (p, 158)) return ; sequence_317 (p); rde_param_i_symbol_done_d_reduce (p, 158, 157); return; } /* * value Symbol 'Suffix' */ static void sym_Suffix (RDE_PARAM p) { /* * x * (Primary) * ? * / * (QUESTION) * (STAR) * (PLUS) */ if (rde_param_i_symbol_start_d (p, 160)) return ; sequence_386 (p); rde_param_i_symbol_done_d_reduce (p, 160, 159); return; } static void sequence_386 (RDE_PARAM p) { /* * x * (Primary) * ? * / * (QUESTION) * (STAR) * (PLUS) */ rde_param_i_state_push_value (p); sym_Primary (p); if (rde_param_i_seq_value2value(p)) return; optional_384 (p); rde_param_i_state_merge_value (p); return; } static void optional_384 (RDE_PARAM p) { /* * ? * / * (QUESTION) * (STAR) * (PLUS) */ rde_param_i_state_push_2 (p); choice_382 (p); rde_param_i_state_merge_ok (p); return; } static void choice_382 (RDE_PARAM p) { /* * / * (QUESTION) * (STAR) * (PLUS) */ rde_param_i_state_push_value (p); sym_QUESTION (p); if (rde_param_i_bra_value2value(p)) return; sym_STAR (p); if (rde_param_i_bra_value2value(p)) return; sym_PLUS (p); rde_param_i_state_merge_value (p); return; } /* * void Symbol 'TO' */ static void sym_TO (RDE_PARAM p) { /* * '-' */ if (rde_param_i_symbol_void_start (p, 163)) return ; rde_param_i_next_char (p, "-", 161); rde_param_i_symbol_done_void (p, 163, 162); return; } /* * leaf Symbol 'UPPER' */ static void sym_UPPER (RDE_PARAM p) { /* * x * "<upper>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 166)) return ; sequence_393 (p); rde_param_i_symbol_done_leaf (p, 166, 165); return; } static void sequence_393 (RDE_PARAM p) { /* * x * "<upper>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<upper>", 164); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'VOID' */ static void sym_VOID (RDE_PARAM p) { /* * x * "void" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 169)) return ; sequence_398 (p); rde_param_i_symbol_done_leaf (p, 169, 168); return; } static void sequence_398 (RDE_PARAM p) { /* * x * "void" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "void", 167); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * void Symbol 'WHITESPACE' */ static void sym_WHITESPACE (RDE_PARAM p) { /* * * * / * <space> * (COMMENT) */ if (rde_param_i_symbol_void_start (p, 171)) return ; kleene_405 (p); rde_param_i_symbol_done_void (p, 171, 170); return; } static void kleene_405 (RDE_PARAM p) { /* * * * / * <space> * (COMMENT) */ while (1) { rde_param_i_state_push_2 (p); choice_403 (p); if (rde_param_i_kleene_close(p)) return; } return; } static void choice_403 (RDE_PARAM p) { /* * / * <space> * (COMMENT) */ rde_param_i_state_push_void (p); rde_param_i_next_space (p, 10); if (rde_param_i_bra_void2void(p)) return; sym_COMMENT (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'WORDCHAR' */ static void sym_WORDCHAR (RDE_PARAM p) { /* * x * "<wordchar>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 174)) return ; sequence_410 (p); rde_param_i_symbol_done_leaf (p, 174, 173); return; } static void sequence_410 (RDE_PARAM p) { /* * x * "<wordchar>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<wordchar>", 172); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* * leaf Symbol 'XDIGIT' */ static void sym_XDIGIT (RDE_PARAM p) { /* * x * "<xdigit>" * (WHITESPACE) */ if (rde_param_i_symbol_start (p, 177)) return ; sequence_415 (p); rde_param_i_symbol_done_leaf (p, 177, 176); return; } static void sequence_415 (RDE_PARAM p) { /* * x * "<xdigit>" * (WHITESPACE) */ rde_param_i_state_push_void (p); rde_param_i_next_str (p, "<xdigit>", 175); if (rde_param_i_seq_void2void(p)) return; sym_WHITESPACE (p); rde_param_i_state_merge_void (p); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/4_choice.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [15] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "cl abc" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { rde_param_i_next_class (p, "abc", 14); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/5_sequence.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [15] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "str abc" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { rde_param_i_next_str (p, "abc", 14); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/6_optional.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void optional_2 (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [15] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "t a" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { optional_2 (p); return; } static void optional_2 (RDE_PARAM p) { /* * ? * 'a' */ rde_param_i_state_push_2 (p); rde_param_i_next_char (p, "a", 14); rde_param_i_state_merge_ok (p); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/7_kleene.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void kleene_2 (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [15] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "t a" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { kleene_2 (p); return; } static void kleene_2 (RDE_PARAM p) { /* * * * 'a' */ while (1) { rde_param_i_state_push_2 (p); rde_param_i_next_char (p, "a", 14); if (rde_param_i_kleene_close(p)) return; } return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/8_pkleene.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void poskleene_2 (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [15] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "t a" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { poskleene_2 (p); return; } static void poskleene_2 (RDE_PARAM p) { /* * + * 'a' */ rde_param_i_loc_push (p); rde_param_i_next_char (p, "a", 14); if (rde_param_i_kleene_abort(p)) return; while (1) { rde_param_i_state_push_2 (p); rde_param_i_next_char (p, "a", 14); if (rde_param_i_kleene_close(p)) return; } return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Added modules/pt/tests/data/ok/peg_cparam-tea/9_ahead.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 | /************************************************************ ** ** TEA-based C/PARAM implementation of the parsing ** expression grammar ** ** TEMPLATE ** ** Generated from file TEST ** for user unknown ** * * ** *** ***** ******** ************* *********************/ #include <string.h> #include <tcl.h> #include <stdlib.h> #include <ctype.h> #define SCOPE static #line 1 "rde_critcl/util.h" #ifndef _RDE_UTIL_H #define _RDE_UTIL_H 1 #ifndef SCOPE #define SCOPE #endif #define ALLOC(type) (type *) ckalloc (sizeof (type)) #define NALLOC(n,type) (type *) ckalloc ((n) * sizeof (type)) #undef RDE_DEBUG #define RDE_DEBUG 1 #undef RDE_TRACE #ifdef RDE_DEBUG #define STOPAFTER(x) { static int count = (x); count --; if (!count) { Tcl_Panic ("stop"); } } #define XSTR(x) #x #define STR(x) XSTR(x) #define RANGEOK(i,n) ((0 <= (i)) && (i < (n))) #define ASSERT(x,msg) if (!(x)) { Tcl_Panic (msg " (" #x "), in file " __FILE__ " @line " STR(__LINE__));} #define ASSERT_BOUNDS(i,n) ASSERT (RANGEOK(i,n),"array index out of bounds: " STR(i) " >= " STR(n)) #else #define STOPAFTER(x) #define ASSERT(x,msg) #define ASSERT_BOUNDS(i,n) #endif #ifdef RDE_TRACE SCOPE void trace_enter (const char* fun); SCOPE void trace_return (const char *pat, ...); SCOPE void trace_printf (const char *pat, ...); #define ENTER(fun) trace_enter (fun) #define RETURN(format,x) trace_return (format,x) ; return x #define RETURNVOID trace_return ("%s","(void)") ; return #define TRACE0(x) trace_printf0 x #define TRACE(x) trace_printf x #else #define ENTER(fun) #define RETURN(f,x) return x #define RETURNVOID return #define TRACE0(x) #define TRACE(x) #endif #endif #line 1 "rde_critcl/stack.h" #ifndef _RDE_DS_STACK_H #define _RDE_DS_STACK_H 1 typedef void (*RDE_STACK_CELL_FREE) (void* cell); typedef struct RDE_STACK_* RDE_STACK; static const int RDE_STACK_INITIAL_SIZE = 256; #endif #line 1 "rde_critcl/tc.h" #ifndef _RDE_DS_TC_H #define _RDE_DS_TC_H 1 typedef struct RDE_TC_* RDE_TC; #endif #line 1 "rde_critcl/param.h" #ifndef _RDE_DS_PARAM_H #define _RDE_DS_PARAM_H 1 typedef struct RDE_PARAM_* RDE_PARAM; typedef struct ERROR_STATE { int refCount; long int loc; RDE_STACK msg; } ERROR_STATE; typedef struct NC_STATE { long int CL; long int ST; Tcl_Obj* SV; ERROR_STATE* ER; } NC_STATE; #endif #line 1 "rde_critcl/util.c" #ifdef RDE_TRACE typedef struct F_STACK { const char* str; struct F_STACK* down; } F_STACK; static F_STACK* top = 0; static int level = 0; static void push (const char* str) { F_STACK* new = ALLOC (F_STACK); new->str = str; new->down = top; top = new; level += 4; } static void pop (void) { F_STACK* next = top->down; level -= 4; ckfree ((char*)top); top = next; } static void indent (void) { int i; for (i = 0; i < level; i++) { fwrite(" ", 1, 1, stdout); fflush (stdout); } if (top) { fwrite(top->str, 1, strlen(top->str), stdout); fflush (stdout); } fwrite(" ", 1, 1, stdout); fflush (stdout); } SCOPE void trace_enter (const char* fun) { push (fun); indent(); fwrite("ENTER\n", 1, 6, stdout); fflush (stdout); } static char msg [1024*1024]; SCOPE void trace_return (const char *pat, ...) { int len; va_list args; indent(); fwrite("RETURN = ", 1, 9, stdout); fflush (stdout); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); pop(); } SCOPE void trace_printf (const char *pat, ...) { int len; va_list args; indent(); va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } SCOPE void trace_printf0 (const char *pat, ...) { int len; va_list args; va_start(args, pat); len = vsprintf(msg, pat, args); va_end(args); msg[len++] = '\n'; msg[len] = '\0'; fwrite(msg, 1, len, stdout); fflush (stdout); } #endif #line 1 "rde_critcl/stack.c" typedef struct RDE_STACK_ { long int max; long int top; RDE_STACK_CELL_FREE freeCellProc; void** cell; } RDE_STACK_; SCOPE RDE_STACK rde_stack_new (RDE_STACK_CELL_FREE freeCellProc) { RDE_STACK s = ALLOC (RDE_STACK_); s->cell = NALLOC (RDE_STACK_INITIAL_SIZE, void*); s->max = RDE_STACK_INITIAL_SIZE; s->top = 0; s->freeCellProc = freeCellProc; return s; } SCOPE void rde_stack_del (RDE_STACK s) { if (s->freeCellProc && s->top) { long int i; for (i=0; i < s->top; i++) { ASSERT_BOUNDS(i,s->max); s->freeCellProc ( s->cell [i] ); } } ckfree ((char*) s->cell); ckfree ((char*) s); } SCOPE void rde_stack_push (RDE_STACK s, void* item) { if (s->top >= s->max) { long int new = s->max ? (2 * s->max) : RDE_STACK_INITIAL_SIZE; void** cell = (void**) ckrealloc ((char*) s->cell, new * sizeof(void*)); ASSERT (cell,"Memory allocation failure for RDE stack"); s->max = new; s->cell = cell; } ASSERT_BOUNDS(s->top,s->max); s->cell [s->top] = item; s->top ++; } SCOPE void* rde_stack_top (RDE_STACK s) { ASSERT_BOUNDS(s->top-1,s->max); return s->cell [s->top - 1]; } SCOPE void rde_stack_pop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; if (s->freeCellProc) { while (n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); n --; } } else { s->top -= n; } } SCOPE void rde_stack_trim (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad trimsize"); if (s->freeCellProc) { while (s->top > n) { s->top --; ASSERT_BOUNDS(s->top,s->max); s->freeCellProc ( s->cell [s->top] ); } } else { s->top = n; } } SCOPE void rde_stack_drop (RDE_STACK s, long int n) { ASSERT (n >= 0, "Bad pop count"); if (n == 0) return; s->top -= n; } SCOPE void rde_stack_move (RDE_STACK dst, RDE_STACK src) { ASSERT (dst->freeCellProc == src->freeCellProc, "Ownership mismatch"); while (src->top > 0) { src->top --; ASSERT_BOUNDS(src->top,src->max); rde_stack_push (dst, src->cell [src->top] ); } } SCOPE void rde_stack_get (RDE_STACK s, long int* cn, void*** cc) { *cn = s->top; *cc = s->cell; } SCOPE long int rde_stack_size (RDE_STACK s) { return s->top; } #line 1 "rde_critcl/tc.c" typedef struct RDE_TC_ { int max; int num; char* str; RDE_STACK off; } RDE_TC_; SCOPE RDE_TC rde_tc_new (void) { RDE_TC tc = ALLOC (RDE_TC_); tc->max = RDE_STACK_INITIAL_SIZE; tc->num = 0; tc->str = NALLOC (RDE_STACK_INITIAL_SIZE, char); tc->off = rde_stack_new (NULL); return tc; } SCOPE void rde_tc_del (RDE_TC tc) { rde_stack_del (tc->off); ckfree (tc->str); ckfree ((char*) tc); } SCOPE long int rde_tc_size (RDE_TC tc) { return rde_stack_size (tc->off); } SCOPE void rde_tc_clear (RDE_TC tc) { tc->num = 0; rde_stack_trim (tc->off, 0); } SCOPE char* rde_tc_append (RDE_TC tc, char* string, long int len) { long int base = tc->num; long int off = tc->num; char* ch; int clen; Tcl_UniChar uni; if (len < 0) { len = strlen (string); } if (!len) { return tc->str + base; } if ((tc->num + len) >= tc->max) { int new = len + (tc->max ? (2 * tc->max) : RDE_STACK_INITIAL_SIZE); char* str = ckrealloc (tc->str, new * sizeof(char)); ASSERT (str,"Memory allocation failure for token character array"); tc->max = new; tc->str = str; } tc->num += len; ASSERT_BOUNDS(tc->num,tc->max); ASSERT_BOUNDS(off,tc->max); ASSERT_BOUNDS(off+len-1,tc->max); ASSERT_BOUNDS(off+len-1,tc->num); memcpy (tc->str + off, string, len); ch = string; while (ch < (string + len)) { ASSERT_BOUNDS(off,tc->num); rde_stack_push (tc->off, (void*) off); clen = Tcl_UtfToUniChar (ch, &uni); off += clen; ch += clen; } return tc->str + base; } SCOPE void rde_tc_get (RDE_TC tc, int at, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); off = (long int) ov [at]; if ((at+1) == oc) { end = tc->num; } else { end = (long int) ov [at+1]; } TRACE (("rde_tc_get (RDE_TC %p, @ %d) => %d.[%d ... %d]/%d",tc,at,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } SCOPE void rde_tc_get_s (RDE_TC tc, int at, int last, char** ch, long int* len) { long int oc, off, top, end; void** ov; rde_stack_get (tc->off, &oc, &ov); ASSERT_BOUNDS(at,oc); ASSERT_BOUNDS(last,oc); off = (long int) ov [at]; if ((last+1) == oc) { end = tc->num; } else { end = (long int) ov [last+1]; } TRACE (("rde_tc_get_s (RDE_TC %p, @ %d .. %d) => %d.[%d ... %d]/%d",tc,at,last,end-off,off,end-1,tc->num)); ASSERT_BOUNDS(off,tc->num); ASSERT_BOUNDS(end-1,tc->num); *ch = tc->str + off; *len = end - off; } #line 1 "rde_critcl/param.c" typedef struct RDE_PARAM_ { Tcl_Channel IN; Tcl_Obj* readbuf; char* CC; long int CC_len; RDE_TC TC; long int CL; RDE_STACK LS; ERROR_STATE* ER; RDE_STACK ES; long int ST; Tcl_Obj* SV; Tcl_HashTable NC; RDE_STACK ast ; RDE_STACK mark ; long int numstr; char** string; ClientData clientData; } RDE_PARAM_; typedef int (*UniCharClass) (int); typedef enum test_class_id { tc_alnum, tc_alpha, tc_ascii, tc_control, tc_ddigit, tc_digit, tc_graph, tc_lower, tc_printable, tc_punct, tc_space, tc_upper, tc_wordchar, tc_xdigit } test_class_id; static void ast_node_free (void* n); static void error_state_free (void* es); static void error_set (RDE_PARAM p, long int s); static void nc_clear (RDE_PARAM p); static int UniCharIsAscii (int character); static int UniCharIsHexDigit (int character); static int UniCharIsDecDigit (int character); static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id); static int er_int_compare (const void* a, const void* b); #define SV_INIT(p) \ p->SV = NULL; \ TRACE (("SV_INIT (%p => %p)", (p), (p)->SV)) #define SV_SET(p,newsv) \ if (((p)->SV) != (newsv)) { \ TRACE (("SV_CLEAR/set (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = (newsv); \ TRACE (("SV_SET (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_IncrRefCount ((p)->SV); \ } \ } #define SV_CLEAR(p) \ TRACE (("SV_CLEAR (%p => %p)", (p), (p)->SV)); \ if ((p)->SV) { \ Tcl_DecrRefCount ((p)->SV); \ } \ (p)->SV = NULL #define ER_INIT(p) \ p->ER = NULL; \ TRACE (("ER_INIT (%p => %p)", (p), (p)->ER)) #define ER_CLEAR(p) \ error_state_free ((p)->ER); \ (p)->ER = NULL SCOPE RDE_PARAM rde_param_new (long int nstr, char** strings) { RDE_PARAM p; ENTER ("rde_param_new"); TRACE (("\tINT %d strings @ %p", nstr, strings)); p = ALLOC (RDE_PARAM_); p->numstr = nstr; p->string = strings; p->readbuf = Tcl_NewObj (); Tcl_IncrRefCount (p->readbuf); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_InitHashTable (&p->NC, TCL_ONE_WORD_KEYS); p->IN = NULL; p->CL = -1; p->ST = 0; ER_INIT (p); SV_INIT (p); p->CC = NULL; p->CC_len = 0; p->TC = rde_tc_new (); p->ES = rde_stack_new (error_state_free); p->LS = rde_stack_new (NULL); p->ast = rde_stack_new (ast_node_free); p->mark = rde_stack_new (NULL); RETURN ("%p", p); } SCOPE void rde_param_del (RDE_PARAM p) { ENTER ("rde_param_del"); TRACE (("RDE_PARAM %p",p)); ER_CLEAR (p); TRACE (("\ter_clear")); SV_CLEAR (p); TRACE (("\tsv_clear")); nc_clear (p); TRACE (("\tnc_clear")); Tcl_DeleteHashTable (&p->NC); TRACE (("\tnc hashtable delete")); rde_tc_del (p->TC); TRACE (("\ttc clear")); rde_stack_del (p->ES); TRACE (("\tes clear")); rde_stack_del (p->LS); TRACE (("\tls clear")); rde_stack_del (p->ast); TRACE (("\tast clear")); rde_stack_del (p->mark); TRACE (("\tmark clear")); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); Tcl_DecrRefCount (p->readbuf); ckfree ((char*) p); RETURNVOID; } SCOPE void rde_param_reset (RDE_PARAM p, Tcl_Channel chan) { ENTER ("rde_param_reset"); TRACE (("RDE_PARAM %p",p)); TRACE (("Tcl_Channel %p",chan)); p->IN = chan; p->CL = -1; p->ST = 0; p->CC = NULL; p->CC_len = 0; ER_CLEAR (p); SV_CLEAR (p); nc_clear (p); rde_tc_clear (p->TC); rde_stack_trim (p->ES, 0); rde_stack_trim (p->LS, 0); rde_stack_trim (p->ast, 0); rde_stack_trim (p->mark, 0); TRACE (("\tTcl_Obj* readbuf %p used %d", p->readbuf,p->readbuf->refCount)); RETURNVOID; } SCOPE void rde_param_update_strings (RDE_PARAM p, long int nstr, char** strings) { ENTER ("rde_param_update_strings"); TRACE (("RDE_PARAM %p", p)); TRACE (("INT %d strings", nstr)); p->numstr = nstr; p->string = strings; RETURNVOID; } SCOPE void rde_param_data (RDE_PARAM p, char* buf, long int len) { (void) rde_tc_append (p->TC, buf, len); } SCOPE void rde_param_clientdata (RDE_PARAM p, ClientData clientData) { p->clientData = clientData; } static void nc_clear (RDE_PARAM p) { Tcl_HashSearch hs; Tcl_HashEntry* he; Tcl_HashTable* tablePtr; for(he = Tcl_FirstHashEntry(&p->NC, &hs); he != NULL; he = Tcl_FirstHashEntry(&p->NC, &hs)) { Tcl_HashSearch hsc; Tcl_HashEntry* hec; tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (he); for(hec = Tcl_FirstHashEntry(tablePtr, &hsc); hec != NULL; hec = Tcl_NextHashEntry(&hsc)) { NC_STATE* scs = Tcl_GetHashValue (hec); error_state_free (scs->ER); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } ckfree ((char*) scs); } Tcl_DeleteHashTable (tablePtr); ckfree ((char*) tablePtr); Tcl_DeleteHashEntry (he); } } SCOPE ClientData rde_param_query_clientdata (RDE_PARAM p) { return p->clientData; } SCOPE void rde_param_query_amark (RDE_PARAM p, long int* mc, void*** mv) { rde_stack_get (p->mark, mc, mv); } SCOPE void rde_param_query_ast (RDE_PARAM p, long int* ac, Tcl_Obj*** av) { rde_stack_get (p->ast, ac, (void***) av); } SCOPE const char* rde_param_query_in (RDE_PARAM p) { return p->IN ? Tcl_GetChannelName (p->IN) : ""; } SCOPE const char* rde_param_query_cc (RDE_PARAM p, long int* len) { *len = p->CC_len; return p->CC; } SCOPE int rde_param_query_cl (RDE_PARAM p) { return p->CL; } SCOPE const ERROR_STATE* rde_param_query_er (RDE_PARAM p) { return p->ER; } SCOPE Tcl_Obj* rde_param_query_er_tcl (RDE_PARAM p, const ERROR_STATE* er) { Tcl_Obj* res; if (!er) { res = Tcl_NewStringObj ("", 0); } else { Tcl_Obj* ov [2]; Tcl_Obj** mov; long int mc, i, j; void** mv; int lastid; const char* msg; rde_stack_get (er->msg, &mc, &mv); qsort (mv, mc, sizeof (void*), er_int_compare); mov = NALLOC (mc, Tcl_Obj*); lastid = -1; for (i=0, j=0; i < mc; i++) { ASSERT_BOUNDS (i,mc); if (((long int) mv [i]) == lastid) continue; lastid = (long int) mv [i]; ASSERT_BOUNDS((long int) mv[i],p->numstr); msg = p->string [(long int) mv[i]]; ASSERT_BOUNDS (j,mc); mov [j] = Tcl_NewStringObj (msg, -1); j++; } ov [0] = Tcl_NewIntObj (er->loc); ov [1] = Tcl_NewListObj (j, mov); res = Tcl_NewListObj (2, ov); ckfree ((char*) mov); } return res; } SCOPE void rde_param_query_es (RDE_PARAM p, long int* ec, ERROR_STATE*** ev) { rde_stack_get (p->ES, ec, (void***) ev); } SCOPE void rde_param_query_ls (RDE_PARAM p, long int* lc, void*** lv) { rde_stack_get (p->LS, lc, lv); } SCOPE long int rde_param_query_lstop (RDE_PARAM p) { (long int) rde_stack_top (p->LS); } SCOPE Tcl_HashTable* rde_param_query_nc (RDE_PARAM p) { return &p->NC; } SCOPE int rde_param_query_st (RDE_PARAM p) { return p->ST; } SCOPE Tcl_Obj* rde_param_query_sv (RDE_PARAM p) { TRACE (("SV_QUERY %p => (%p)", (p), (p)->SV)); \ return p->SV; } SCOPE long int rde_param_query_tc_size (RDE_PARAM p) { return rde_tc_size (p->TC); } SCOPE void rde_param_query_tc_get_s (RDE_PARAM p, long int at, long int last, char** ch, long int* len) { rde_tc_get_s (p->TC, at, last, ch, len); } SCOPE const char* rde_param_query_string (RDE_PARAM p, long int id) { TRACE (("rde_param_query_string (RDE_PARAM %p, %d/%d)", p, id, p->numstr)); ASSERT_BOUNDS(id,p->numstr); return p->string [id]; } SCOPE void rde_param_i_ast_pop_discard (RDE_PARAM p) { rde_stack_pop (p->mark, 1); } SCOPE void rde_param_i_ast_pop_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_pop_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_rewind (RDE_PARAM p) { long int trim = (long int) rde_stack_top (p->mark); ENTER ("rde_param_i_ast_rewind"); TRACE (("RDE_PARAM %p",p)); rde_stack_trim (p->ast, trim); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_ast_push (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_ast_value_push (RDE_PARAM p) { ENTER ("rde_param_i_ast_value_push"); TRACE (("RDE_PARAM %p",p)); ASSERT(p->SV,"Unable to push undefined semantic value"); TRACE (("rde_param_i_ast_value_push %p => (%p)", p, p->SV)); TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV->refCount, Tcl_GetString (p->SV))); rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); RETURNVOID; } static void ast_node_free (void* n) { Tcl_DecrRefCount ((Tcl_Obj*) n); } SCOPE void rde_param_i_error_clear (RDE_PARAM p) { ER_CLEAR (p); } SCOPE void rde_param_i_error_nonterminal (RDE_PARAM p, long int s) { return; long int pos; if (!p->ER) return; pos = 1 + (long int) rde_stack_top (p->LS); if (p->ER->loc != pos) return; error_set (p, s); p->ER->loc = pos; } SCOPE void rde_param_i_error_pop_merge (RDE_PARAM p) { ERROR_STATE* top = (ERROR_STATE*) rde_stack_top (p->ES); if (top == p->ER) { rde_stack_pop (p->ES, 1); return; } if (!top) { rde_stack_pop (p->ES, 1); return; } if (!p->ER) { rde_stack_drop (p->ES, 1); p->ER = top; return; } if (top->loc < p->ER->loc) { rde_stack_pop (p->ES, 1); return; } if (top->loc > p->ER->loc) { rde_stack_drop (p->ES, 1); error_state_free (p->ER); p->ER = top; return; } rde_stack_move (p->ER->msg, top->msg); rde_stack_pop (p->ES, 1); } SCOPE void rde_param_i_error_push (RDE_PARAM p) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } static void error_set (RDE_PARAM p, long int s) { error_state_free (p->ER); p->ER = ALLOC (ERROR_STATE); p->ER->refCount = 1; p->ER->loc = p->CL; p->ER->msg = rde_stack_new (NULL); ASSERT_BOUNDS(s,p->numstr); rde_stack_push (p->ER->msg, (void*) s); } static void error_state_free (void* esx) { ERROR_STATE* es = esx; if (!es) return; es->refCount --; if (es->refCount > 0) return; rde_stack_del (es->msg); ckfree ((char*) es); } SCOPE void rde_param_i_loc_pop_discard (RDE_PARAM p) { rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_pop_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_loc_push (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); } SCOPE void rde_param_i_loc_rewind (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); } SCOPE void rde_param_i_input_next (RDE_PARAM p, long int m) { int leni; char* ch; ASSERT_BOUNDS(m,p->numstr); p->CL ++; if (p->CL < rde_tc_size (p->TC)) { rde_tc_get (p->TC, p->CL, &p->CC, &p->CC_len); ASSERT_BOUNDS (p->CC_len-1, TCL_UTF_MAX); p->ST = 1; ER_CLEAR (p); return; } if (!p->IN || Tcl_Eof (p->IN) || (Tcl_ReadChars (p->IN, p->readbuf, 1, 0) <= 0)) { p->ST = 0; error_set (p, m); return; } ch = Tcl_GetStringFromObj (p->readbuf, &leni); ASSERT_BOUNDS (leni, TCL_UTF_MAX); p->CC = rde_tc_append (p->TC, ch, leni); p->CC_len = leni; p->ST = 1; ER_CLEAR (p); } SCOPE void rde_param_i_status_fail (RDE_PARAM p) { p->ST = 0; } SCOPE void rde_param_i_status_ok (RDE_PARAM p) { p->ST = 1; } SCOPE void rde_param_i_status_negate (RDE_PARAM p) { p->ST = !p->ST; } SCOPE int rde_param_i_symbol_restore (RDE_PARAM p, long int s) { NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; hPtr = Tcl_FindHashEntry (&p->NC, (char*) p->CL); if (!hPtr) { return 0; } tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); hPtr = Tcl_FindHashEntry (tablePtr, (char*) s); if (!hPtr) { return 0; } scs = Tcl_GetHashValue (hPtr); p->CL = scs->CL; p->ST = scs->ST; error_state_free (p->ER); p->ER = scs->ER; if (p->ER) { p->ER->refCount ++; } TRACE (("SV_RESTORE (%p) '%s'",scs->SV, scs->SV ? Tcl_GetString (scs->SV):"")); SV_SET (p, scs->SV); return 1; } SCOPE void rde_param_i_symbol_save (RDE_PARAM p, long int s) { long int at = (long int) rde_stack_top (p->LS); NC_STATE* scs; Tcl_HashEntry* hPtr; Tcl_HashTable* tablePtr; int isnew; ENTER ("rde_param_i_symbol_save"); TRACE (("RDE_PARAM %p",p)); TRACE (("INT %d",s)); hPtr = Tcl_CreateHashEntry (&p->NC, (char*) at, &isnew); if (isnew) { tablePtr = ALLOC (Tcl_HashTable); Tcl_InitHashTable (tablePtr, TCL_ONE_WORD_KEYS); Tcl_SetHashValue (hPtr, tablePtr); } else { tablePtr = (Tcl_HashTable*) Tcl_GetHashValue (hPtr); } hPtr = Tcl_CreateHashEntry (tablePtr, (char*) s, &isnew); if (isnew) { scs = ALLOC (NC_STATE); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "")); scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } Tcl_SetHashValue (hPtr, scs); } else { scs = (NC_STATE*) Tcl_GetHashValue (hPtr); scs->CL = p->CL; scs->ST = p->ST; TRACE (("SV_CACHE/over (%p '%s')", p->SV, p->SV ? Tcl_GetString(p->SV) : "" )); if (scs->SV) { Tcl_DecrRefCount (scs->SV); } scs->SV = p->SV; if (scs->SV) { Tcl_IncrRefCount (scs->SV); } error_state_free (scs->ER); scs->ER = p->ER; if (scs->ER) { scs->ER->refCount ++; } } TRACE (("SV = (%p rc%d '%s')", p->SV, p->SV ? p->SV->refCount : -1, p->SV ? Tcl_GetString (p->SV) : "")); RETURNVOID; } SCOPE void rde_param_i_test_alnum (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlnum, tc_alnum); } SCOPE void rde_param_i_test_alpha (RDE_PARAM p) { test_class (p, Tcl_UniCharIsAlpha, tc_alpha); } SCOPE void rde_param_i_test_ascii (RDE_PARAM p) { test_class (p, UniCharIsAscii, tc_ascii); } SCOPE void rde_param_i_test_control (RDE_PARAM p) { test_class (p, Tcl_UniCharIsControl, tc_control); } SCOPE void rde_param_i_test_char (RDE_PARAM p, const char* c, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = Tcl_UtfNcmp (p->CC, c, 1) == 0; if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_ddigit (RDE_PARAM p) { test_class (p, UniCharIsDecDigit, tc_ddigit); } SCOPE void rde_param_i_test_digit (RDE_PARAM p) { test_class (p, Tcl_UniCharIsDigit, tc_digit); } SCOPE void rde_param_i_test_graph (RDE_PARAM p) { test_class (p, Tcl_UniCharIsGraph, tc_graph); } SCOPE void rde_param_i_test_lower (RDE_PARAM p) { test_class (p, Tcl_UniCharIsLower, tc_lower); } SCOPE void rde_param_i_test_print (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPrint, tc_printable); } SCOPE void rde_param_i_test_punct (RDE_PARAM p) { test_class (p, Tcl_UniCharIsPunct, tc_punct); } SCOPE void rde_param_i_test_range (RDE_PARAM p, const char* s, const char* e, long int msg) { ASSERT_BOUNDS(msg,p->numstr); p->ST = (Tcl_UtfNcmp (s, p->CC, 1) <= 0) && (Tcl_UtfNcmp (p->CC, e, 1) <= 0); if (p->ST) { ER_CLEAR (p); } else { error_set (p, msg); p->CL --; } } SCOPE void rde_param_i_test_space (RDE_PARAM p) { test_class (p, Tcl_UniCharIsSpace, tc_space); } SCOPE void rde_param_i_test_upper (RDE_PARAM p) { test_class (p, Tcl_UniCharIsUpper, tc_upper); } SCOPE void rde_param_i_test_wordchar (RDE_PARAM p) { test_class (p, Tcl_UniCharIsWordChar, tc_wordchar); } SCOPE void rde_param_i_test_xdigit (RDE_PARAM p) { test_class (p, UniCharIsHexDigit, tc_xdigit); } static void test_class (RDE_PARAM p, UniCharClass class, test_class_id id) { Tcl_UniChar ch; Tcl_UtfToUniChar(p->CC, &ch); ASSERT_BOUNDS(id,p->numstr); p->ST = !!class (ch); if (p->ST) { ER_CLEAR (p); } else { error_set (p, id); p->CL --; } } static int UniCharIsAscii (int character) { return (character >= 0) && (character < 0x80); } static int UniCharIsHexDigit (int character) { return (character >= 0) && (character < 0x80) && isxdigit(character); } static int UniCharIsDecDigit (int character) { return (character >= 0) && (character < 0x80) && isdigit(character); } SCOPE void rde_param_i_value_clear (RDE_PARAM p) { SV_CLEAR (p); } SCOPE void rde_param_i_value_leaf (RDE_PARAM p, long int s) { Tcl_Obj* newsv; Tcl_Obj* ov [3]; long int pos = 1 + (long int) rde_stack_top (p->LS); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); newsv = Tcl_NewListObj (3, ov); TRACE (("rde_param_i_value_leaf => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); } SCOPE void rde_param_i_value_reduce (RDE_PARAM p, long int s) { Tcl_Obj* newsv; int oc, i, j; Tcl_Obj** ov; long int ac; Tcl_Obj** av; long int pos = 1 + (long int) rde_stack_top (p->LS); long int mark = (long int) rde_stack_top (p->mark); long int asize = rde_stack_size (p->ast); long int new = asize - mark; ASSERT (new >= 0, "Bad number of elements to reduce"); ov = NALLOC (3+new, Tcl_Obj*); ASSERT_BOUNDS(s,p->numstr); ov [0] = Tcl_NewStringObj (p->string[s], -1); ov [1] = Tcl_NewIntObj (pos); ov [2] = Tcl_NewIntObj (p->CL); rde_stack_get (p->ast, &ac, (void***) &av); for (i = 3, j = mark; j < asize; i++, j++) { ASSERT_BOUNDS (i, 3+new); ASSERT_BOUNDS (j, ac); ov [i] = av [j]; } ASSERT (i == 3+new, "Reduction result incomplete"); newsv = Tcl_NewListObj (3+new, ov); TRACE (("rde_param_i_value_reduce => '%s'",Tcl_GetString (newsv))); SV_SET (p, newsv); ckfree ((char*) ov); } static int er_int_compare (const void* a, const void* b) { const void** ael = (const void**) a; const void** bel = (const void**) b; long int avalue = (long int) *ael; long int bvalue = (long int) *bel; if (avalue < bvalue) { return -1; } if (avalue > bvalue) { return 1; } return 0; } SCOPE int rde_param_i_symbol_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) { if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } return 1; } rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE int rde_param_i_symbol_void_start (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); return 0; } SCOPE int rde_param_i_symbol_void_start_d (RDE_PARAM p, long int s) { if (rde_param_i_symbol_restore (p, s)) return 1; rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); return 0; } SCOPE void rde_param_i_symbol_done_d_reduce (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_reduce (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_d_leaf (RDE_PARAM p, long int s, long int m) { if (p->ST) { rde_param_i_value_leaf (p, s); } else { SV_CLEAR (p); } rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); if (p->ST) { rde_stack_push (p->ast, p->SV); Tcl_IncrRefCount (p->SV); } } SCOPE void rde_param_i_symbol_done_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_symbol_done_d_void (RDE_PARAM p, long int s, long int m) { SV_CLEAR (p); rde_param_i_symbol_save (p, s); rde_param_i_error_nonterminal (p, m); rde_param_i_ast_pop_rewind (p); rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_next_char (RDE_PARAM p, const char* c, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_char (p, c, m); } SCOPE void rde_param_i_next_range (RDE_PARAM p, const char* s, const char* e, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_range (p, s, e, m); } SCOPE void rde_param_i_next_alnum (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alnum (p); } SCOPE void rde_param_i_next_alpha (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_alpha (p); } SCOPE void rde_param_i_next_ascii (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ascii (p); } SCOPE void rde_param_i_next_control (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_control (p); } SCOPE void rde_param_i_next_ddigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_ddigit (p); } SCOPE void rde_param_i_next_digit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_digit (p); } SCOPE void rde_param_i_next_graph (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_graph (p); } SCOPE void rde_param_i_next_lower (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_lower (p); } SCOPE void rde_param_i_next_print (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_print (p); } SCOPE void rde_param_i_next_punct (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_punct (p); } SCOPE void rde_param_i_next_space (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_space (p); } SCOPE void rde_param_i_next_upper (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_upper (p); } SCOPE void rde_param_i_next_wordchar (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_wordchar (p); } SCOPE void rde_param_i_next_xdigit (RDE_PARAM p, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; rde_param_i_test_xdigit (p); } SCOPE void rde_param_i_notahead_start_d (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); } SCOPE void rde_param_i_notahead_exit_d (RDE_PARAM p) { if (p->ST) { rde_param_i_ast_pop_rewind (p); } else { rde_stack_pop (p->mark, 1); } p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_notahead_exit (RDE_PARAM p) { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); p->ST = !p->ST; } SCOPE void rde_param_i_state_push_2 (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } SCOPE void rde_param_i_state_push_void (RDE_PARAM p) { rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_push_value (RDE_PARAM p) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->LS, (void*) p->CL); ER_CLEAR (p); rde_stack_push (p->ES, p->ER); } SCOPE void rde_param_i_state_merge_ok (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); } SCOPE void rde_param_i_state_merge_value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (!p->ST) { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } SCOPE int rde_param_i_kleene_close (RDE_PARAM p) { int stop = !p->ST; rde_param_i_error_pop_merge (p); if (stop) { p->ST = 1; p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_kleene_abort (RDE_PARAM p) { int stop = !p->ST; if (stop) { p->CL = (long int) rde_stack_top (p->LS); } rde_stack_pop (p->LS, 1); return stop; } SCOPE int rde_param_i_seq_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_seq_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } return 0; } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_pop (p->LS, 1); return 1; } } SCOPE int rde_param_i_bra_void2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_void2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->LS, 1); } else { rde_stack_push (p->mark, (void*) rde_stack_size (p->ast)); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2void (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_pop (p->mark, 1); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE int rde_param_i_bra_value2value (RDE_PARAM p) { rde_param_i_error_pop_merge (p); if (p->ST) { rde_stack_pop (p->mark, 1); rde_stack_pop (p->LS, 1); } else { long int trim = (long int) rde_stack_top (p->mark); rde_stack_trim (p->ast, trim); p->CL = (long int) rde_stack_top (p->LS); rde_stack_push (p->ES, p->ER); if (p->ER) { p->ER->refCount ++; } } return p->ST; } SCOPE void rde_param_i_next_str (RDE_PARAM p, const char* str, long int m) { int at = p->CL; while (*str) { rde_param_i_input_next (p, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } rde_param_i_test_char (p, str, m); if (!p->ST) { p->ER->loc = at+1; p->CL = at; return; } str = Tcl_UtfNext (str); } } SCOPE void rde_param_i_next_class (RDE_PARAM p, const char* class, long int m) { rde_param_i_input_next (p, m); if (!p->ST) return; while (*class) { p->ST = Tcl_UtfNcmp (p->CC, class, 1) == 0; if (p->ST) { ER_CLEAR (p); return; } class = Tcl_UtfNext (class); } error_set (p, m); p->CL --; } /* * Declaring the parse functions */ static void ahead_3 (RDE_PARAM p); static void sequence_6 (RDE_PARAM p); static void sym_TEST (RDE_PARAM p); /* * Precomputed table of strings (symbols, error messages, etc.). */ static char const* p_string [17] = { /* 0 = */ "alnum", /* 1 = */ "alpha", /* 2 = */ "ascii", /* 3 = */ "control", /* 4 = */ "ddigit", /* 5 = */ "digit", /* 6 = */ "graph", /* 7 = */ "lower", /* 8 = */ "print", /* 9 = */ "punct", /* 10 = */ "space", /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "t a", /* 15 = */ "n TEST", /* 16 = */ "TEST" }; /* * Grammar Start Expression */ static void MAIN (RDE_PARAM p) { sym_TEST (p); return; } /* * value Symbol 'TEST' */ static void sym_TEST (RDE_PARAM p) { /* * x * & * 'a' * (IDENTIFIER) */ if (rde_param_i_symbol_start (p, 16)) return ; sequence_6 (p); rde_param_i_symbol_done_leaf (p, 16, 15); return; } static void sequence_6 (RDE_PARAM p) { /* * x * & * 'a' * (IDENTIFIER) */ rde_param_i_state_push_void (p); ahead_3 (p); if (rde_param_i_seq_void2void(p)) return; /* Undefined symbol 'IDENTIFIER' */; rde_param_i_status_fail (p); rde_param_i_state_merge_void (p); return; } static void ahead_3 (RDE_PARAM p) { /* * & * 'a' */ rde_param_i_loc_push (p); rde_param_i_next_char (p, "a", 14); rde_param_i_loc_pop_rewind (p); return; } /* -*- c -*- */ typedef struct PARSERg { long int counter; char buf [50]; } PARSERg; static void PARSERgRelease (ClientData cd, Tcl_Interp* interp) { ckfree((char*) cd); } static const char* PARSERnewName (Tcl_Interp* interp) { #define KEY "tcllib/parser/PACKAGE/TEA" Tcl_InterpDeleteProc* proc = PARSERgRelease; PARSERg* parserg; parserg = Tcl_GetAssocData (interp, KEY, &proc); if (parserg == NULL) { parserg = (PARSERg*) ckalloc (sizeof (PARSERg)); parserg->counter = 0; Tcl_SetAssocData (interp, KEY, proc, (ClientData) parserg); } parserg->counter ++; sprintf (parserg->buf, "PARSER%ld", parserg->counter); return parserg->buf; #undef KEY } static void PARSERdeleteCmd (ClientData clientData) { /* * Release the whole PARSER * (Low-level engine only actually). */ rde_param_del ((RDE_PARAM) clientData); } /* * ** *** ***** ******** ************* ** Functions implementing the object methods, and helper. */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp); static int parser_PARSE (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { int mode; Tcl_Channel chan; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "chan"); return TCL_ERROR; } chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); if (!chan) { return TCL_ERROR; } rde_param_reset (p, chan); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } static int parser_PARSET (RDE_PARAM p, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { char* buf; int len; if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "text"); return TCL_ERROR; } buf = Tcl_GetStringFromObj (objv[2], &len); rde_param_reset (p, NULL); rde_param_data (p, buf, len); MAIN (p) ; /* Entrypoint for the generated code. */ return COMPLETE (p, interp); } /* See also rde_critcl/m.c, param_COMPLETE() */ static int COMPLETE (RDE_PARAM p, Tcl_Interp* interp) { if (rde_param_query_st (p)) { long int ac; Tcl_Obj** av; rde_param_query_ast (p, &ac, &av); if (ac > 1) { Tcl_Obj** lv = NALLOC (3+ac, Tcl_Obj*); memcpy(lv + 3, av, ac * sizeof (Tcl_Obj*)); lv [0] = Tcl_NewObj (); lv [1] = Tcl_NewIntObj (1 + rde_param_query_lstop (p)); lv [2] = Tcl_NewIntObj (rde_param_query_cl (p)); Tcl_SetObjResult (interp, Tcl_NewListObj (3, lv)); ckfree ((char*) lv); } else if (ac == 0) { /* * Match, but no AST. This is possible if the grammar * consists of only the start expression. */ Tcl_SetObjResult (interp, Tcl_NewStringObj ("",-1)); } else { Tcl_SetObjResult (interp, av [0]); } return TCL_OK; } else { Tcl_Obj* xv [1]; const ERROR_STATE* er = rde_param_query_er (p); Tcl_Obj* res = rde_param_query_er_tcl (p, er); /* res = list (location, list(msg)) */ /* Stick the exception type-tag before the existing elements */ xv [0] = Tcl_NewStringObj ("pt::rde",-1); Tcl_ListObjReplace(interp, res, 0, 0, 1, xv); Tcl_SetErrorCode (interp, "PT", "RDE", "SYNTAX", NULL); Tcl_SetObjResult (interp, res); return TCL_ERROR; } } /* * ** *** ***** ******** ************* ** Object command, method dispatch. */ static int parser_objcmd (ClientData cd, Tcl_Interp* interp, int objc, Tcl_Obj* CONST* objv) { RDE_PARAM p = (RDE_PARAM) cd; int m, res; static CONST char* methods [] = { "destroy", "parse", "parset", NULL }; enum methods { M_DESTROY, M_PARSE, M_PARSET }; if (objc < 2) { Tcl_WrongNumArgs (interp, objc, objv, "option ?arg arg ...?"); return TCL_ERROR; } else if (Tcl_GetIndexFromObj (interp, objv [1], methods, "option", 0, &m) != TCL_OK) { return TCL_ERROR; } /* Dispatch to methods. They check the #args in * detail before performing the requested * functionality */ switch (m) { case M_DESTROY: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, NULL); return TCL_ERROR; } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) rde_param_query_clientdata (p)); return TCL_OK; case M_PARSE: res = parser_PARSE (p, interp, objc, objv); break; case M_PARSET: res = parser_PARSET (p, interp, objc, objv); break; default: /* Not coming to this place */ ASSERT (0,"Reached unreachable location"); } return res; } /** * ** *** ***** ******** ************* * Class command, i.e. object construction. */ static int ParserClassCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const*objv) { /* * Syntax: No arguments beyond the name */ RDE_PARAM parser; CONST char* name; Tcl_Obj* fqn; Tcl_CmdInfo ci; Tcl_Command c; #define USAGE "?name?" if ((objc != 2) && (objc != 1)) { Tcl_WrongNumArgs (interp, 1, objv, USAGE); return TCL_ERROR; } if (objc < 2) { name = PARSERnewName (interp); } else { name = Tcl_GetString (objv [1]); } if (!Tcl_StringMatch (name, "::*")) { /* Relative name. Prefix with current namespace */ Tcl_Eval (interp, "namespace current"); fqn = Tcl_GetObjResult (interp); fqn = Tcl_DuplicateObj (fqn); Tcl_IncrRefCount (fqn); if (!Tcl_StringMatch (Tcl_GetString (fqn), "::")) { Tcl_AppendToObj (fqn, "::", -1); } Tcl_AppendToObj (fqn, name, -1); } else { fqn = Tcl_NewStringObj (name, -1); Tcl_IncrRefCount (fqn); } Tcl_ResetResult (interp); if (Tcl_GetCommandInfo (interp, Tcl_GetString (fqn), &ci)) { Tcl_Obj* err; err = Tcl_NewObj (); Tcl_AppendToObj (err, "command \"", -1); Tcl_AppendObjToObj (err, fqn); Tcl_AppendToObj (err, "\" already exists", -1); Tcl_DecrRefCount (fqn); Tcl_SetObjResult (interp, err); return TCL_ERROR; } parser = rde_param_new (sizeof(p_string)/sizeof(char*), (char**) p_string); c = Tcl_CreateObjCommand (interp, Tcl_GetString (fqn), parser_objcmd, (ClientData) parser, PARSERdeleteCmd); rde_param_clientdata (parser, (ClientData) c); Tcl_SetObjResult (interp, fqn); Tcl_DecrRefCount (fqn); return TCL_OK; } int Package_Init(Tcl_Interp* interp) { if (interp == 0) return TCL_ERROR; if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { return TCL_ERROR; } if (Tcl_CreateObjCommand(interp, "PARSER", ParserClassCmd , NULL, NULL) == NULL) { Tcl_SetResult(interp, "Can't create constructor", NULL); return TCL_ERROR; } Tcl_PkgProvide(interp, "PACKAGE", "0.1"); return TCL_OK; } |
Changes to modules/pt/tests/data/ok/peg_cparam/0_basic_arithmetic.
︙ | ︙ | |||
49 50 51 52 53 54 55 | /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", | | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", /* 20 = */ "t (", /* 21 = */ "t )", /* 22 = */ "n Expression", /* 23 = */ "Expression", /* 24 = */ "n Factor", /* 25 = */ "Factor", /* 26 = */ "cl */", /* 27 = */ "n MulOp", /* 28 = */ "MulOp", |
︙ | ︙ | |||
162 163 164 165 166 167 168 | * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (<<state>>); | | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_char (<<state>>, "(", 20); if (rde_param_i_seq_void2value(<<state>>)) return; <<self>> <<ns>>sym_Expression (<<state>>); if (rde_param_i_seq_value2value(<<state>>)) return; rde_param_i_next_char (<<state>>, ")", 21); rde_param_i_state_merge_value (<<state>>); return; } <<attributes>> void <<ns>>sequence_18 (<<STATE>> <<state>>) { <<prelude>> /* * x |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam/1_functions.
︙ | ︙ | |||
32 33 34 35 36 37 38 | /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "n Expression", /* 15 = */ "Expression", /* 16 = */ "n Function", /* 17 = */ "Function", | | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /* 11 = */ "upper", /* 12 = */ "wordchar", /* 13 = */ "xdigit", /* 14 = */ "n Expression", /* 15 = */ "Expression", /* 16 = */ "n Function", /* 17 = */ "Function", /* 18 = */ "str sin(", /* 19 = */ "t )", /* 20 = */ "n Sinus", /* 21 = */ "Sinus" }; /* * Grammar Start Expression */ |
︙ | ︙ | |||
104 105 106 107 108 109 110 | * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (<<state>>); | | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_str (<<state>>, "sin(", 18); if (rde_param_i_seq_void2value(<<state>>)) return; <<self>> <<ns>>sym_Expression (<<state>>); if (rde_param_i_seq_value2value(<<state>>)) return; rde_param_i_next_char (<<state>>, ")", 19); rde_param_i_state_merge_value (<<state>>); return; } /* */ |
Changes to modules/pt/tests/data/ok/peg_cparam/2_fun_arithmetic.
︙ | ︙ | |||
52 53 54 55 56 57 58 | /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", | | | | | 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 | /* 13 = */ "xdigit", /* 14 = */ "cl -+", /* 15 = */ "n AddOp", /* 16 = */ "AddOp", /* 17 = */ "cl 0123456789", /* 18 = */ "n Digit", /* 19 = */ "Digit", /* 20 = */ "t (", /* 21 = */ "t )", /* 22 = */ "n Expression", /* 23 = */ "Expression", /* 24 = */ "n Factor", /* 25 = */ "Factor", /* 26 = */ "n Function", /* 27 = */ "Function", /* 28 = */ "cl */", /* 29 = */ "n MulOp", /* 30 = */ "MulOp", /* 31 = */ "n Number", /* 32 = */ "Number", /* 33 = */ "n Sign", /* 34 = */ "Sign", /* 35 = */ "str sin(", /* 36 = */ "n Sinus", /* 37 = */ "Sinus", /* 38 = */ "n Term", /* 39 = */ "Term" }; /* |
︙ | ︙ | |||
174 175 176 177 178 179 180 | * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (<<state>>); | | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | * x * '\(' * (Expression) * '\)' */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_char (<<state>>, "(", 20); if (rde_param_i_seq_void2value(<<state>>)) return; <<self>> <<ns>>sym_Expression (<<state>>); if (rde_param_i_seq_value2value(<<state>>)) return; rde_param_i_next_char (<<state>>, ")", 21); rde_param_i_state_merge_value (<<state>>); return; } <<attributes>> void <<ns>>sequence_19 (<<STATE>> <<state>>) { <<prelude>> /* * x |
︙ | ︙ | |||
438 439 440 441 442 443 444 | * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (<<state>>); | | | | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | * x * "sin\(" * (Expression) * '\)' */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_str (<<state>>, "sin(", 35); if (rde_param_i_seq_void2value(<<state>>)) return; <<self>> <<ns>>sym_Expression (<<state>>); if (rde_param_i_seq_value2value(<<state>>)) return; rde_param_i_next_char (<<state>>, ")", 21); rde_param_i_state_merge_value (<<state>>); return; } /* * value Symbol 'Term' */ |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_cparam/3_peg_itself.
︙ | ︙ | |||
193 194 195 196 197 198 199 | /* 26 = */ "str <ascii>", /* 27 = */ "n ASCII", /* 28 = */ "ASCII", /* 29 = */ "n Attribute", /* 30 = */ "Attribute", /* 31 = */ "n Char", /* 32 = */ "Char", | | | | | | | | | 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 | /* 26 = */ "str <ascii>", /* 27 = */ "n ASCII", /* 28 = */ "ASCII", /* 29 = */ "n Attribute", /* 30 = */ "Attribute", /* 31 = */ "n Char", /* 32 = */ "Char", /* 33 = */ "t \\\\", /* 34 = */ ".. 0 2", /* 35 = */ ".. 0 7", /* 36 = */ "n CharOctalFull", /* 37 = */ "CharOctalFull", /* 38 = */ "n CharOctalPart", /* 39 = */ "CharOctalPart", /* 40 = */ "cl nrt'\\\"\\[\\]\\\\", /* 41 = */ "n CharSpecial", /* 42 = */ "CharSpecial", /* 43 = */ "dot", /* 44 = */ "n CharUnescaped", /* 45 = */ "CharUnescaped", /* 46 = */ "str \173\\u\175", /* 47 = */ "n CharUnicode", /* 48 = */ "CharUnicode", /* 49 = */ "n Class", /* 50 = */ "Class", /* 51 = */ "t )", /* 52 = */ "n CLOSE", /* 53 = */ "CLOSE", /* 54 = */ "t \\]", /* 55 = */ "n CLOSEB", /* 56 = */ "CLOSEB", /* 57 = */ "t :", /* 58 = */ "n COLON", /* 59 = */ "COLON", /* 60 = */ "t #", /* 61 = */ "n COMMENT", /* 62 = */ "COMMENT", /* 63 = */ "str <control>", /* 64 = */ "n CONTROL", /* 65 = */ "CONTROL", /* 66 = */ "t \173\"\175", /* 67 = */ "n DAPOSTROPH", /* 68 = */ "DAPOSTROPH", /* 69 = */ "str <ddigit>", /* 70 = */ "n DDIGIT", /* 71 = */ "DDIGIT", /* 72 = */ "n Definition", /* 73 = */ "Definition", /* 74 = */ "str <digit>", /* 75 = */ "n DIGIT", /* 76 = */ "DIGIT", /* 77 = */ "t .", /* 78 = */ "n DOT", /* 79 = */ "DOT", /* 80 = */ "n EOF", /* 81 = */ "EOF", /* 82 = */ "cl \173\n\r\175", /* 83 = */ "n EOL", /* 84 = */ "EOL", /* 85 = */ "n Expression", /* 86 = */ "Expression", /* 87 = */ "str END", /* 88 = */ "n Final", /* 89 = */ "Final", |
︙ | ︙ | |||
276 277 278 279 280 281 282 | /* 109 = */ "Literal", /* 110 = */ "str <lower>", /* 111 = */ "n LOWER", /* 112 = */ "LOWER", /* 113 = */ "t !", /* 114 = */ "n NOT", /* 115 = */ "NOT", | | | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | /* 109 = */ "Literal", /* 110 = */ "str <lower>", /* 111 = */ "n LOWER", /* 112 = */ "LOWER", /* 113 = */ "t !", /* 114 = */ "n NOT", /* 115 = */ "NOT", /* 116 = */ "t (", /* 117 = */ "n OPEN", /* 118 = */ "OPEN", /* 119 = */ "t \173[\175", /* 120 = */ "n OPENB", /* 121 = */ "OPENB", /* 122 = */ "str PEG", /* 123 = */ "n PEG", /* 124 = */ "PEG", /* 125 = */ "t +", /* 126 = */ "n PLUS", |
︙ | ︙ | |||
303 304 305 306 307 308 309 | /* 136 = */ "n PUNCT", /* 137 = */ "PUNCT", /* 138 = */ "t ?", /* 139 = */ "n QUESTION", /* 140 = */ "QUESTION", /* 141 = */ "n Range", /* 142 = */ "Range", | | | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | /* 136 = */ "n PUNCT", /* 137 = */ "PUNCT", /* 138 = */ "t ?", /* 139 = */ "n QUESTION", /* 140 = */ "QUESTION", /* 141 = */ "n Range", /* 142 = */ "Range", /* 143 = */ "t \173;\175", /* 144 = */ "n SEMICOLON", /* 145 = */ "SEMICOLON", /* 146 = */ "n Sequence", /* 147 = */ "Sequence", /* 148 = */ "t /", /* 149 = */ "n SLASH", /* 150 = */ "SLASH", |
︙ | ︙ | |||
616 617 618 619 620 621 622 | * '\' * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (<<state>>); | | | 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 | * '\' * range (0 .. 2) * range (0 .. 7) * range (0 .. 7) */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_char (<<state>>, "\\", 33); if (rde_param_i_seq_void2void(<<state>>)) return; rde_param_i_next_range (<<state>>, "0", "2", 34); if (rde_param_i_seq_void2void(<<state>>)) return; rde_param_i_next_range (<<state>>, "0", "7", 35); if (rde_param_i_seq_void2void(<<state>>)) return; rde_param_i_next_range (<<state>>, "0", "7", 35); rde_param_i_state_merge_void (<<state>>); |
︙ | ︙ | |||
656 657 658 659 660 661 662 | * '\' * range (0 .. 7) * ? * range (0 .. 7) */ rde_param_i_state_push_void (<<state>>); | | | 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | * '\' * range (0 .. 7) * ? * range (0 .. 7) */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_char (<<state>>, "\\", 33); if (rde_param_i_seq_void2void(<<state>>)) return; rde_param_i_next_range (<<state>>, "0", "7", 35); if (rde_param_i_seq_void2void(<<state>>)) return; <<self>> <<ns>>optional_50 (<<state>>); rde_param_i_state_merge_void (<<state>>); return; } |
︙ | ︙ | |||
702 703 704 705 706 707 708 | /* * x * '\' * [nrt'\"[]\] */ rde_param_i_state_push_void (<<state>>); | | | | 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | /* * x * '\' * [nrt'\"[]\] */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_char (<<state>>, "\\", 33); if (rde_param_i_seq_void2void(<<state>>)) return; rde_param_i_next_class (<<state>>, "nrt'\"[]\\", 40); rde_param_i_state_merge_void (<<state>>); return; } /* * leaf Symbol 'CharUnescaped' */ |
︙ | ︙ | |||
750 751 752 753 754 755 756 | <<attributes>> void <<ns>>notahead_61 (<<STATE>> <<state>>) { <<prelude>> /* * ! * '\' */ rde_param_i_loc_push (<<state>>); | | | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | <<attributes>> void <<ns>>notahead_61 (<<STATE>> <<state>>) { <<prelude>> /* * ! * '\' */ rde_param_i_loc_push (<<state>>); rde_param_i_next_char (<<state>>, "\\", 33); rde_param_i_notahead_exit (<<state>>); return; } /* * leaf Symbol 'CharUnicode' */ |
︙ | ︙ | |||
796 797 798 799 800 801 802 | * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_void (<<state>>); | | | 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | * x * <xdigit> * ? * <xdigit> */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_str (<<state>>, "\\u", 46); if (rde_param_i_seq_void2void(<<state>>)) return; rde_param_i_next_xdigit (<<state>>, 13); if (rde_param_i_seq_void2void(<<state>>)) return; <<self>> <<ns>>optional_80 (<<state>>); rde_param_i_state_merge_void (<<state>>); return; } |
︙ | ︙ | |||
1003 1004 1005 1006 1007 1008 1009 | /* * x * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (<<state>>); | | | | 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 | /* * x * '\)' * (WHITESPACE) */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_char (<<state>>, ")", 51); if (rde_param_i_seq_void2void(<<state>>)) return; <<self>> <<ns>>sym_WHITESPACE (<<state>>); rde_param_i_state_merge_void (<<state>>); return; } /* * void Symbol 'CLOSEB' */ <<attributes>> void <<ns>>sym_CLOSEB (<<STATE>> <<state>>) { <<prelude>> /* * ']' */ if (rde_param_i_symbol_void_start (<<state>>, 56)) return ; rde_param_i_next_char (<<state>>, "]", 54); rde_param_i_symbol_done_void (<<state>>, 56, 55); return; } /* * void Symbol 'COLON' */ |
︙ | ︙ | |||
1188 1189 1190 1191 1192 1193 1194 | <<attributes>> void <<ns>>sym_DAPOSTROPH (<<STATE>> <<state>>) { <<prelude>> /* * '\"' */ if (rde_param_i_symbol_void_start (<<state>>, 68)) return ; | | | 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 | <<attributes>> void <<ns>>sym_DAPOSTROPH (<<STATE>> <<state>>) { <<prelude>> /* * '\"' */ if (rde_param_i_symbol_void_start (<<state>>, 68)) return ; rde_param_i_next_char (<<state>>, "\"", 66); rde_param_i_symbol_done_void (<<state>>, 68, 67); return; } /* * leaf Symbol 'DDIGIT' */ |
︙ | ︙ | |||
2104 2105 2106 2107 2108 2109 2110 | /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (<<state>>); | | | | 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 | /* * x * '\(' * (WHITESPACE) */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_char (<<state>>, "(", 116); if (rde_param_i_seq_void2void(<<state>>)) return; <<self>> <<ns>>sym_WHITESPACE (<<state>>); rde_param_i_state_merge_void (<<state>>); return; } /* * void Symbol 'OPENB' */ <<attributes>> void <<ns>>sym_OPENB (<<STATE>> <<state>>) { <<prelude>> /* * '[' */ if (rde_param_i_symbol_void_start (<<state>>, 121)) return ; rde_param_i_next_char (<<state>>, "[", 119); rde_param_i_symbol_done_void (<<state>>, 121, 120); return; } /* * void Symbol 'PEG' */ |
︙ | ︙ | |||
2582 2583 2584 2585 2586 2587 2588 | /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (<<state>>); | | | 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 | /* * x * ';' * (WHITESPACE) */ rde_param_i_state_push_void (<<state>>); rde_param_i_next_char (<<state>>, ";", 143); if (rde_param_i_seq_void2void(<<state>>)) return; <<self>> <<ns>>sym_WHITESPACE (<<state>>); rde_param_i_state_merge_void (<<state>>); return; } /* |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_param-compact/3_peg_itself.
︙ | ︙ | |||
746 747 748 749 750 751 752 | failed_93: loc_pop_rewind return char_85: # '\' | | | | 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | failed_93: loc_pop_rewind return char_85: # '\' input_next "t \" ok! test_char "\" return range_87: # range (0 .. 2) input_next ".. 0 2" ok! test_range "0" "2" |
︙ | ︙ | |||
1018 1019 1020 1021 1022 1023 1024 | input_next "t t" ok! test_char "t" return char_114: # '\"' | | | | 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | input_next "t t" ok! test_char "t" return char_114: # '\"' input_next "t "" ok! test_char """ return char_116: # '[' input_next "t [" ok! test_char "[" |
︙ | ︙ | |||
2325 2326 2327 2328 2329 2330 2331 | oknoast_290: loc_pop_discard return char_286: # '\n' | | | | | | 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 | oknoast_290: loc_pop_discard return char_286: # '\n' input_next "t <LF>" ok! test_char "<LF>" return char_288: # '\r' input_next "t <CR>" ok! test_char "<CR>" return # # value Symbol 'Expression' # sym_Expression: # x |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_param-inlined/3_peg_itself.
︙ | ︙ | |||
638 639 640 641 642 643 644 | # range (0 .. 7) loc_push error_clear error_push | | | | 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | # range (0 .. 7) loc_push error_clear error_push input_next "t \" ok! test_char "\" error_pop_merge fail! jump failed_76 error_push input_next ".. 0 2" ok! test_range "0" "2" |
︙ | ︙ | |||
710 711 712 713 714 715 716 | # range (0 .. 7) loc_push error_clear error_push | | | | 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | # range (0 .. 7) loc_push error_clear error_push input_next "t \" ok! test_char "\" error_pop_merge fail! jump failed_86 error_push input_next ".. 0 7" ok! test_range "0" "7" |
︙ | ︙ | |||
802 803 804 805 806 807 808 | # '\' loc_push error_clear error_push | | | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | # '\' loc_push error_clear error_push input_next "t \" ok! test_char "\" error_pop_merge fail! jump failed_103 error_push call choice_100 |
︙ | ︙ | |||
877 878 879 880 881 882 883 | error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push | | | | 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 | error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push input_next "t "" ok! test_char """ error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push |
︙ | ︙ | |||
907 908 909 910 911 912 913 | error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push | | | | 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push input_next "t \" ok! test_char "\" error_pop_merge ok! jump oknoast_99 loc_pop_rewind status_fail return |
︙ | ︙ | |||
981 982 983 984 985 986 987 | notahead_108: # ! # '\' loc_push | | | | 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 | notahead_108: # ! # '\' loc_push input_next "t \" ok! test_char "\" loc_pop_rewind status_negate return # # leaf Symbol 'CharUnicode' # |
︙ | ︙ | |||
1040 1041 1042 1043 1044 1045 1046 | # <xdigit> loc_push error_clear error_push | | | | 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | # <xdigit> loc_push error_clear error_push input_next "t \" ok! test_char "\" error_pop_merge fail! jump failed_135 error_push input_next "t u" ok! test_char "u" |
︙ | ︙ | |||
1722 1723 1724 1725 1726 1727 1728 | sym_DAPOSTROPH: # '\"' symbol_restore DAPOSTROPH found! return loc_push | | | | 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 | sym_DAPOSTROPH: # '\"' symbol_restore DAPOSTROPH found! return loc_push input_next "t "" ok! test_char """ value_clear symbol_save DAPOSTROPH error_nonterminal DAPOSTROPH loc_pop_discard return # |
︙ | ︙ | |||
2166 2167 2168 2169 2170 2171 2172 | # '\r' error_clear loc_push error_push | | | | | | 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 | # '\r' error_clear loc_push error_push input_next "t <LF>" ok! test_char "<LF>" error_pop_merge ok! jump oknoast_258 loc_pop_rewind loc_push error_push input_next "t <CR>" ok! test_char "<CR>" error_pop_merge ok! jump oknoast_258 loc_pop_rewind status_fail return |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_param-unopt/3_peg_itself.
︙ | ︙ | |||
809 810 811 812 813 814 815 | failed_103: loc_pop_rewind return char_94: # '\' | | | | 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 | failed_103: loc_pop_rewind return char_94: # '\' input_next "t \" ok! test_char "\" return range_96: # range (0 .. 2) input_next ".. 0 2" ok! test_range "0" "2" |
︙ | ︙ | |||
899 900 901 902 903 904 905 | failed_116: loc_pop_rewind return char_107: # '\' | | | | 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 | failed_116: loc_pop_rewind return char_107: # '\' input_next "t \" ok! test_char "\" return range_109: # range (0 .. 7) input_next ".. 0 7" ok! test_range "0" "7" |
︙ | ︙ | |||
1003 1004 1005 1006 1007 1008 1009 | failed_142: loc_pop_rewind return char_120: # '\' | | | | 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 | failed_142: loc_pop_rewind return char_120: # '\' input_next "t \" ok! test_char "\" return choice_139: # / # 'n' # 'r' # 't' |
︙ | ︙ | |||
1130 1131 1132 1133 1134 1135 1136 | input_next "t '" ok! test_char "'" return char_130: # '\"' | | | | | | 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 | input_next "t '" ok! test_char "'" return char_130: # '\"' input_next "t "" ok! test_char """ return char_132: # '[' input_next "t [" ok! test_char "[" return char_134: # ']' input_next "t ]" ok! test_char "]" return char_136: # '\' input_next "t \" ok! test_char "\" return # # leaf Symbol 'CharUnescaped' # sym_CharUnescaped: # x |
︙ | ︙ | |||
1224 1225 1226 1227 1228 1229 1230 | loc_pop_rewind status_negate return char_146: # '\' | | | | 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 | loc_pop_rewind status_negate return char_146: # '\' input_next "t \" ok! test_char "\" return # # leaf Symbol 'CharUnicode' # sym_CharUnicode: # x |
︙ | ︙ | |||
1313 1314 1315 1316 1317 1318 1319 | failed_181: loc_pop_rewind return char_156: # '\' | | | | 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 | failed_181: loc_pop_rewind return char_156: # '\' input_next "t \" ok! test_char "\" return char_158: # 'u' input_next "t u" ok! test_char "u" |
︙ | ︙ | |||
2087 2088 2089 2090 2091 2092 2093 | error_nonterminal DAPOSTROPH loc_pop_discard return char_263: # '\"' | | | | 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 | error_nonterminal DAPOSTROPH loc_pop_discard return char_263: # '\"' input_next "t "" ok! test_char """ return # # leaf Symbol 'DDIGIT' # sym_DDIGIT: # x |
︙ | ︙ | |||
2647 2648 2649 2650 2651 2652 2653 | oknoast_336: loc_pop_discard return char_332: # '\n' | | | | | | 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 | oknoast_336: loc_pop_discard return char_332: # '\n' input_next "t <LF>" ok! test_char "<LF>" return char_334: # '\r' input_next "t <CR>" ok! test_char "<CR>" return # # value Symbol 'Expression' # sym_Expression: # x |
︙ | ︙ |
Changes to modules/pt/tests/data/ok/peg_param/3_peg_itself.
︙ | ︙ | |||
638 639 640 641 642 643 644 | # range (0 .. 7) loc_push error_clear error_push | | | | 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | # range (0 .. 7) loc_push error_clear error_push input_next "t \" ok! test_char "\" error_pop_merge fail! jump failed_76 error_push input_next ".. 0 2" ok! test_range "0" "2" |
︙ | ︙ | |||
710 711 712 713 714 715 716 | # range (0 .. 7) loc_push error_clear error_push | | | | 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | # range (0 .. 7) loc_push error_clear error_push input_next "t \" ok! test_char "\" error_pop_merge fail! jump failed_86 error_push input_next ".. 0 7" ok! test_range "0" "7" |
︙ | ︙ | |||
802 803 804 805 806 807 808 | # '\' loc_push error_clear error_push | | | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | # '\' loc_push error_clear error_push input_next "t \" ok! test_char "\" error_pop_merge fail! jump failed_103 error_push call choice_100 |
︙ | ︙ | |||
877 878 879 880 881 882 883 | error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push | | | | 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 | error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push input_next "t "" ok! test_char """ error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push |
︙ | ︙ | |||
907 908 909 910 911 912 913 | error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push | | | | 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | error_pop_merge ok! jump oknoast_99 loc_pop_rewind loc_push error_push input_next "t \" ok! test_char "\" error_pop_merge ok! jump oknoast_99 loc_pop_rewind status_fail return |
︙ | ︙ | |||
981 982 983 984 985 986 987 | notahead_108: # ! # '\' loc_push | | | | 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 | notahead_108: # ! # '\' loc_push input_next "t \" ok! test_char "\" loc_pop_rewind status_negate return # # leaf Symbol 'CharUnicode' # |
︙ | ︙ | |||
1040 1041 1042 1043 1044 1045 1046 | # <xdigit> loc_push error_clear error_push | | | | 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | # <xdigit> loc_push error_clear error_push input_next "t \" ok! test_char "\" error_pop_merge fail! jump failed_135 error_push input_next "t u" ok! test_char "u" |
︙ | ︙ | |||
1722 1723 1724 1725 1726 1727 1728 | sym_DAPOSTROPH: # '\"' symbol_restore DAPOSTROPH found! return loc_push | | | | 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 | sym_DAPOSTROPH: # '\"' symbol_restore DAPOSTROPH found! return loc_push input_next "t "" ok! test_char """ value_clear symbol_save DAPOSTROPH error_nonterminal DAPOSTROPH loc_pop_discard return # |
︙ | ︙ | |||
2166 2167 2168 2169 2170 2171 2172 | # '\r' error_clear loc_push error_push | | | | | | 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 | # '\r' error_clear loc_push error_push input_next "t <LF>" ok! test_char "<LF>" error_pop_merge ok! jump oknoast_258 loc_pop_rewind loc_push error_push input_next "t <CR>" ok! test_char "<CR>" error_pop_merge ok! jump oknoast_258 loc_pop_rewind status_fail return |
︙ | ︙ |
Changes to modules/pt/tests/pt_cparam_config_critcl.tests.
︙ | ︙ | |||
23 24 25 26 27 28 29 | # ------------------------------------------------------------------------- # TODO :: Tests missing for: configure/cget, reset # ------------------------------------------------------------------------- | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # ------------------------------------------------------------------------- # TODO :: Tests missing for: configure/cget, reset # ------------------------------------------------------------------------- # Testing the generation of c/param output configured for critcl. TestFilesProcess $mytestdir ok peg_serial-canonical peg_cparam-critcl -> n label input data expected { test pt-cparam-config-critcl-3.$n "pt::cparam::configuration::critcl, $label, ok :- $input" -setup { pt::peg::to::cparam reset pt::peg::to::cparam configure -name TEMPLATE pt::peg::to::cparam configure -file TEST |
︙ | ︙ |
Added modules/pt/tests/pt_cparam_config_tea.tests.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | # -*- tcl -*- # General set of error cases regarding the number of arguments. test pt-cparam-config-tea-1.0 {convert, wrong#args} -body { pt::cparam::configuration::tea def } -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} test pt-cparam-config-tea-1.1 {convert, wrong#args} -body { pt::cparam::configuration::tea def C } -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} test pt-cparam-config-tea-1.2 {convert, wrong#args} -body { pt::cparam::configuration::tea def C P } -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} test pt-cparam-config-tea-1.3 {convert, wrong#args} -body { pt::cparam::configuration::tea def C P V } -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} test pt-cparam-config-tea-2.0 {reset, wrong#args} -body { pt::cparam::configuration::tea def C P V C XXX } -returnCodes error -result {wrong # args: should be "pt::cparam::configuration::tea def class pkg version cmd"} # ------------------------------------------------------------------------- # TODO :: Tests missing for: configure/cget, reset # ------------------------------------------------------------------------- # Testing the generation of c/param output configured for tea. TestFilesProcess $mytestdir ok peg_serial-canonical peg_cparam-tea -> n label input data expected { test pt-cparam-config-tea-3.$n "pt::cparam::configuration::tea, $label, ok :- $input" -setup { pt::peg::to::cparam reset pt::peg::to::cparam configure -name TEMPLATE pt::peg::to::cparam configure -file TEST pt::cparam::configuration::tea def \ PARSER PACKAGE 1 \ {pt::peg::to::cparam configure} } -body { pt::peg::to::cparam convert $data } -cleanup { pt::peg::to::cparam reset } -result $expected } #---------------------------------------------------------------------- unset n label input data expected |
Changes to modules/pt/tests/pt_pgen.tests.
︙ | ︙ | |||
32 33 34 35 36 37 38 | # Test parser on good inputs for the grammar. TestFilesProcess $mytestdir gr ok-${glabel} ok-${glabel}-res -> k label infile text expected { test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-t:${label}-1.$n.$k \ "$format parser $glabel, good input - $label" -setup { } -body { $p parset $text | < | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # Test parser on good inputs for the grammar. TestFilesProcess $mytestdir gr ok-${glabel} ok-${glabel}-res -> k label infile text expected { test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-t:${label}-1.$n.$k \ "$format parser $glabel, good input - $label" -setup { } -body { $p parset $text } -result $expected } # Test parser on bad inputs for the grammar. ## # Note how the expected output depends not only on grammar, # but the parser format as well. Different optimizations and |
︙ | ︙ | |||
60 61 62 63 64 65 66 | # by msg id, that is not necessarily # lexicographical, nor matching the Tcl results. lassign $msg tag loc mlist set msg [list $tag $loc [lsort -dict $mlist]] # TODO: Convert message to readable. list $code $msg | < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | # by msg id, that is not necessarily # lexicographical, nor matching the Tcl results. lassign $msg tag loc mlist set msg [list $tag $loc [lsort -dict $mlist]] # TODO: Convert message to readable. list $code $msg } -result $expected } yes ;# Allow missing testsets, for two reasons: # # (a) Easier during testsuite development, allowing incremental buildup # # (b) Some grammar construction *cannot* fail (Ex: x*), thus we cannot provide # # failure cases either. # Kill shared parser instance. $p destroy } # Testing the handling of generated parsers for single # characters, for characters special to Tcl, C, and # PEGs. I.e. ensure that the various forms of quoting are done # correctly. foreach {n peg input message hmsg} $chars { set glabel "T_$hmsg" set grdata [string map [list @ $peg] $gtemplate] set edata [string map [list @ $hmsg] $etemplate] # Make parser instance. Shared across tests. # Amortize the time spent on dynamically making it. set p [make-parser $format $glabel $grdata] test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-3.$n \ "$format parser $glabel, good input" -setup { } -body { $p parset $input } -result {} test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-4.$n \ "$format parser $glabel, bad input, tcl error" -setup { } -body { set code [catch { $p parset X } msg] lassign $msg tag loc mlist list $tag $loc [lsort -dict $mlist] } -result [list pt::rde 0 [list $message]] test pt-pgen-parse:${parseimpl}-rde:${rdeimpl}-stack:${stackimpl}-f:${format}-g:${glabel}-5.$n \ "$format parser $glabel, bad input, readable error" -setup { } -body { set code [catch { $p parset X } msg] lassign $msg tag loc mlist pt::util::error2readable [list $tag $loc [lsort -dict $mlist]] X } -result $edata # Kill shared parser instance. $p destroy } } #---------------------------------------------------------------------- |
Changes to support/devel/sak/doc/kwic.txt.
︙ | ︙ | |||
425 426 427 428 429 430 431 432 433 434 435 436 437 438 | [key {context-free languages}] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | [key {context-free languages}] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
856 857 858 859 860 861 862 863 864 865 866 867 868 869 | [manpage modules/valtype/isbn.man valtype::isbn] [key earley] [manpage modules/grammar_aycock/aycock.man grammar::aycock] [key EBNF] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | [manpage modules/valtype/isbn.man valtype::isbn] [key earley] [manpage modules/grammar_aycock/aycock.man grammar::aycock] [key EBNF] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 | [key expression] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 | [key expression] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 | [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_me/me_vm.man grammar::me_vm] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 | [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_me/me_vm.man grammar::me_vm] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 | [key LL(k)] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 | [key LL(k)] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 | [manpage modules/valtype/cc_mastercard.man valtype::creditcard::mastercard] [key matching] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 | [manpage modules/valtype/cc_mastercard.man valtype::creditcard::mastercard] [key matching] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 | [manpage modules/doctools2idx/idx_parse.man doctools::idx::parse] [manpage modules/doctools2base/tcl_parse.man doctools::tcl::parse] [manpage modules/doctools2toc/toc_parse.man doctools::toc::parse] [manpage modules/grammar_aycock/aycock.man grammar::aycock] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 | [manpage modules/doctools2idx/idx_parse.man doctools::idx::parse] [manpage modules/doctools2base/tcl_parse.man doctools::tcl::parse] [manpage modules/doctools2toc/toc_parse.man doctools::toc::parse] [manpage modules/grammar_aycock/aycock.man grammar::aycock] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 | [manpage modules/yaml/yaml.man yaml] [key {parsing expression}] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 | [manpage modules/yaml/yaml.man yaml] [key {parsing expression}] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 | [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage modules/page/page_util_peg.man page_util_peg] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 | [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage modules/page/page_util_peg.man page_util_peg] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 | [key PEG] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/page/page_util_norm_peg.man page_util_norm_peg] [manpage modules/page/page_util_peg.man page_util_peg] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 | [key PEG] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/page/page_util_norm_peg.man page_util_norm_peg] [manpage modules/page/page_util_peg.man page_util_peg] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 | [key {push down automaton}] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 | [key {push down automaton}] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 | [key {recursive descent}] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 | [key {recursive descent}] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 | [manpage modules/grammar_fa/dexec.man grammar::fa::dexec] [manpage modules/grammar_fa/faop.man grammar::fa::op] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 | [manpage modules/grammar_fa/dexec.man grammar::fa::dexec] [manpage modules/grammar_fa/faop.man grammar::fa::op] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 | [manpage modules/pt/pt_peg_to_tclparam.man pt::peg::to::tclparam] [key TDPL] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 | [manpage modules/pt/pt_peg_to_tclparam.man pt::peg::to::tclparam] [key TDPL] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 | [key {top-down parsing languages}] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 | [key {top-down parsing languages}] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ | |||
3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 | [manpage modules/grammar_fa/faop.man grammar::fa::op] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] | > | 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 | [manpage modules/grammar_fa/faop.man grammar::fa::op] [manpage modules/grammar_me/me_intro.man grammar::me_intro] [manpage modules/grammar_peg/peg.man grammar::peg] [manpage modules/grammar_peg/peg_interp.man grammar::peg::interp] [manpage apps/pt.man pt] [manpage modules/pt/pt_astree.man pt::ast] [manpage modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl] [manpage modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea] [manpage modules/pt/pt_json_language.man pt::json_language] [manpage modules/pt/pt_param.man pt::param] [manpage modules/pt/pt_pexpression.man pt::pe] [manpage modules/pt/pt_pexpr_op.man pt::pe::op] [manpage modules/pt/pt_pegrammar.man pt::peg] [manpage modules/pt/pt_peg_container.man pt::peg::container] [manpage modules/pt/pt_peg_container_peg.man pt::peg::container::peg] |
︙ | ︙ |
Changes to support/devel/sak/doc/manpages.txt.
︙ | ︙ | |||
230 231 232 233 234 235 236 237 238 239 240 241 242 243 | modules/pop3/pop3.man modules/pop3d/pop3d.man modules/pop3d/pop3d_dbox.man modules/pop3d/pop3d_udb.man modules/profiler/profiler.man modules/pt/pt_astree.man modules/pt/pt_cparam_config_critcl.man modules/pt/pt_from_api.man modules/pt/pt_introduction.man modules/pt/pt_json_language.man modules/pt/pt_param.man modules/pt/pt_parse_peg.man modules/pt/pt_parser_api.man modules/pt/pt_peg_container.man | > | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | modules/pop3/pop3.man modules/pop3d/pop3d.man modules/pop3d/pop3d_dbox.man modules/pop3d/pop3d_udb.man modules/profiler/profiler.man modules/pt/pt_astree.man modules/pt/pt_cparam_config_critcl.man modules/pt/pt_cparam_config_tea.man modules/pt/pt_from_api.man modules/pt/pt_introduction.man modules/pt/pt_json_language.man modules/pt/pt_param.man modules/pt/pt_parse_peg.man modules/pt/pt_parser_api.man modules/pt/pt_peg_container.man |
︙ | ︙ |
Changes to support/devel/sak/doc/toc.txt.
︙ | ︙ | |||
268 269 270 271 272 273 274 275 276 277 278 279 280 281 | [item modules/page/page_util_peg.man page_util_peg {page PEG transformation utilities}] [item modules/page/page_util_quote.man page_util_quote {page character quoting utilities}] [division_end] [division_start {Parsing and Grammars}] [item apps/pt.man pt {Parser Tools Application}] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] [item modules/pt/pt_peg_container.man pt::peg::container {PEG Storage}] [item modules/pt/pt_peg_container_peg.man pt::peg::container::peg {PEG Storage. Canned PEG grammar specification}] | > | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | [item modules/page/page_util_peg.man page_util_peg {page PEG transformation utilities}] [item modules/page/page_util_quote.man page_util_quote {page character quoting utilities}] [division_end] [division_start {Parsing and Grammars}] [item apps/pt.man pt {Parser Tools Application}] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] [item modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea {C/PARAM, Canned configuration, TEA}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] [item modules/pt/pt_peg_container.man pt::peg::container {PEG Storage}] [item modules/pt/pt_peg_container_peg.man pt::peg::container::peg {PEG Storage. Canned PEG grammar specification}] |
︙ | ︙ | |||
849 850 851 852 853 854 855 856 857 858 859 860 861 862 | [division_end] [division_start profiler] [item modules/profiler/profiler.man profiler {Tcl source code profiler}] [division_end] [division_start pt] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] [item modules/pt/pt_peg_container.man pt::peg::container {PEG Storage}] [item modules/pt/pt_peg_container_peg.man pt::peg::container::peg {PEG Storage. Canned PEG grammar specification}] | > | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 | [division_end] [division_start profiler] [item modules/profiler/profiler.man profiler {Tcl source code profiler}] [division_end] [division_start pt] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] [item modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea {C/PARAM, Canned configuration, TEA}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] [item modules/pt/pt_peg_container.man pt::peg::container {PEG Storage}] [item modules/pt/pt_peg_container_peg.man pt::peg::container::peg {PEG Storage. Canned PEG grammar specification}] |
︙ | ︙ |
Changes to support/devel/sak/doc/toc_cats.txt.
︙ | ︙ | |||
268 269 270 271 272 273 274 275 276 277 278 279 280 281 | [item modules/page/page_util_peg.man page_util_peg {page PEG transformation utilities}] [item modules/page/page_util_quote.man page_util_quote {page character quoting utilities}] [division_end] [division_start {Parsing and Grammars}] [item apps/pt.man pt {Parser Tools Application}] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] [item modules/pt/pt_peg_container.man pt::peg::container {PEG Storage}] [item modules/pt/pt_peg_container_peg.man pt::peg::container::peg {PEG Storage. Canned PEG grammar specification}] | > | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | [item modules/page/page_util_peg.man page_util_peg {page PEG transformation utilities}] [item modules/page/page_util_quote.man page_util_quote {page character quoting utilities}] [division_end] [division_start {Parsing and Grammars}] [item apps/pt.man pt {Parser Tools Application}] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] [item modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea {C/PARAM, Canned configuration, TEA}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] [item modules/pt/pt_peg_container.man pt::peg::container {PEG Storage}] [item modules/pt/pt_peg_container_peg.man pt::peg::container::peg {PEG Storage. Canned PEG grammar specification}] |
︙ | ︙ |
Changes to support/devel/sak/doc/toc_mods.txt.
︙ | ︙ | |||
378 379 380 381 382 383 384 385 386 387 388 389 390 391 | [division_end] [division_start profiler] [item modules/profiler/profiler.man profiler {Tcl source code profiler}] [division_end] [division_start pt] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] [item modules/pt/pt_peg_container.man pt::peg::container {PEG Storage}] [item modules/pt/pt_peg_container_peg.man pt::peg::container::peg {PEG Storage. Canned PEG grammar specification}] | > | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | [division_end] [division_start profiler] [item modules/profiler/profiler.man profiler {Tcl source code profiler}] [division_end] [division_start pt] [item modules/pt/pt_astree.man pt::ast {Abstract Syntax Tree Serialization}] [item modules/pt/pt_cparam_config_critcl.man pt::cparam::configuration::critcl {C/PARAM, Canned configuration, Critcl}] [item modules/pt/pt_cparam_config_tea.man pt::cparam::configuration::tea {C/PARAM, Canned configuration, TEA}] [item modules/pt/pt_json_language.man pt::json_language {The JSON Grammar Exchange Format}] [item modules/pt/pt_param.man pt::param {PackRat Machine Specification}] [item modules/pt/pt_pexpression.man pt::pe {Parsing Expression Serialization}] [item modules/pt/pt_pexpr_op.man pt::pe::op {Parsing Expression Utilities}] [item modules/pt/pt_pegrammar.man pt::peg {Parsing Expression Grammar Serialization}] [item modules/pt/pt_peg_container.man pt::peg::container {PEG Storage}] [item modules/pt/pt_peg_container_peg.man pt::peg::container::peg {PEG Storage. Canned PEG grammar specification}] |
︙ | ︙ |