Tcl Library Source Code

Check-in [e6cc443afb]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Modified support command "make-parser" to be able to save generated code into a file for post-run inspection.
Timelines: family | ancestors | descendants | both | pt-work
Files: files | file ages | folders
SHA1: e6cc443afb844209765a09be5bab7cdc751c8caa
User & Date: aku 2014-06-28 05:05:48
Context
2014-06-28
05:08
Tweaked code formatting check-in: 9386346420 user: aku tags: pt-work
05:05
Modified support command "make-parser" to be able to save generated code into a file for post-run inspection. check-in: e6cc443afb user: aku tags: pt-work
05:04
char - Modified internals to accept strings and varargs strings as arguments, not just single char. Drops the need for externa split/join combos to handle strings. Extended the testsuite to match. Further refactored the argument handling into a single helper command. check-in: 570945bf84 user: aku tags: pt-work
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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
303
304
305
306
307
308
309
310
311
312
313

314
315
316

317
318
319
320
321
322
323
## - 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"} {
	lappend cmd -class [set gc GC[incr pcounter]]
    }

    try {
	set code [eval $cmd]
    } trap {PT RDE SYNTAX} {e o} {
	error [pt::util error2readable $e $grammar]
    }

    # debugging generator output
    if {$debug} {

	puts "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $format ($glabel)"
	puts $code
	puts "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $format ($glabel)"

    }

    # Now do format-specific post-processing of the generated code to
    # get a proper parser object.

    switch -exact -- $format {
	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 {