Tcl Library Source Code

Check-in [cfca679384]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Aug 20.

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

Overview
Comment:* pt_peg_op.tcl: Sort out correct order of minimization transformations: dechaining must precede unrealizable and unreachable transformations
Timelines: family | ancestors | descendants | both | pt-peg_op-tests-ssoberni
Files: files | file ages | folders
SHA3-256:cfca679384776a94415e10f99db15ba909eab668b5bffdeb8c3bdb6e58f9385d
User & Date: ssoberni 2018-08-08 14:42:12
Context
2018-09-18
22:21
* pt_peg_op.tcl: Complete dechain2, to be reviewed check-in: 6ac792f623 user: ssoberni tags: pt-peg_op-tests-ssoberni
2018-08-08
14:42
* pt_peg_op.tcl: Sort out correct order of minimization transformations: dechaining must precede unrealizable and unreachable transformations check-in: cfca679384 user: ssoberni tags: pt-peg_op-tests-ssoberni
14:28
* pt_peg_op.tcl: Started work on a proper dechain transformation (dechain2); the current dechain logic is entirely broken; added tests check-in: f71a1db4a8 user: ssoberni tags: pt-peg_op-tests-ssoberni
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/pt/pt_peg_op.tcl.

227
228
229
230
231
232
233


234
235
236
237
238
239
240
241
242
243
244
245
    }
}

# # ## ### ##### ######## #############

proc ::pt::peg::op::minimize {container} {
    flatten           $container


    drop unrealizable $container
    drop unreachable  $container
    flatten           $container
    modeopt           $container
    dechain2          $container
    return
}

# # ## ### ##### ######## #############

proc ::pt::peg::op::reachable {container} {








>
>


<
|
|







227
228
229
230
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245
246
    }
}

# # ## ### ##### ######## #############

proc ::pt::peg::op::minimize {container} {
    flatten           $container
    modeopt           $container; # for dechaining
    dechain2          $container
    drop unrealizable $container
    drop unreachable  $container

    modeopt           $container;
    flatten           $container
    return
}

# # ## ### ##### ######## #############

proc ::pt::peg::op::reachable {container} {

Changes to modules/pt/tests/pt_peg_op.tests.

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
...
578
579
580
581
582
583
584















585
586
587
588
589
590
proc g {s r} {
    # quick constructor of a grammar value
    return [list pt::grammar::peg [list rules $r start $s]]
}

proc TestTransformation {op data setImpl} {
    # Convert operation and data table into series of test cases
    set debug 0
    # Note, the `op` changes the container (here ::In) in-place.
    append bodyScript [list {*}::pt::peg::op::$op ::In] \;
    if {$debug} {
	append bodyScript "puts stderr \[::In       serialize\]" \;
	append bodyScript "puts stderr \[::Expected serialize\]" \;
    }
    # After the op, when all is well, the content of ::In should be
................................................................................
    # --- indirect cycle
    {n A} {
	A {is {n B} mode value}
	B {is {n C} mode value}
	C {is {n A} mode value}
    }
    epsilon {}















} $setimpl

# -------------------------------------------------------------------------
rename sl {}
rename g {}
rename TestTransformation {}







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
...
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
proc g {s r} {
    # quick constructor of a grammar value
    return [list pt::grammar::peg [list rules $r start $s]]
}

proc TestTransformation {op data setImpl} {
    # Convert operation and data table into series of test cases
    set debug 1
    # Note, the `op` changes the container (here ::In) in-place.
    append bodyScript [list {*}::pt::peg::op::$op ::In] \;
    if {$debug} {
	append bodyScript "puts stderr \[::In       serialize\]" \;
	append bodyScript "puts stderr \[::Expected serialize\]" \;
    }
    # After the op, when all is well, the content of ::In should be
................................................................................
    # --- indirect cycle
    {n A} {
	A {is {n B} mode value}
	B {is {n C} mode value}
	C {is {n A} mode value}
    }
    epsilon {}
    # --- dechaining creates unreachable and unrealisable rules; here: B, C, Y, Z
    {n S} {
    	S {is {x {n A} {t s}} mode value}
	A {is {n B} mode value}
	B {is {n C} mode value}
	C {is {x {n X} {t c}} mode value}
	X {is {n Y} mode value}
	Y {is {n Z} mode value}
	Z {is {x {t z}} mode leaf}
    }
    {n S} {
	S {is {x {n A} {t s}} mode value}
	A {is {x {n X} {t c}} mode value}
	X {is {t z} mode leaf}
    }
} $setimpl

# -------------------------------------------------------------------------
rename sl {}
rename g {}
rename TestTransformation {}