Tcl Library Source Code

Check-in [f70ef61b95]
Login

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

Overview
Comment:The drop operation should only be permissive on choices (reflecting the realizability condition on choice). New expressions should not be constructed for expressions other than choice.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | pt-container-ssoberni
Files: files | file ages | folders
SHA3-256: f70ef61b952a738698e5c08e0016dbe497356a13117455703ceabeca05beaaa6
User & Date: ssoberni 2018-06-14 14:31:51.627
Context
2018-06-27
17:16
Update peg container transform work to latest trunk, including peg ffp fixes. check-in: 63282d761b user: aku tags: pt-container-ssoberni
2018-06-14
14:31
The drop operation should only be permissive on choices (reflecting the realizability condition on choice). New expressions should not be constructed for expressions other than choice. check-in: f70ef61b95 user: ssoberni tags: pt-container-ssoberni
14:02
Kleene star and optionals are better deemed realizable by definition. check-in: 8cd8a7435f user: ssoberni tags: pt-container-ssoberni
Changes
Unified Diff Ignore Whitespace Patch
Changes to modules/pt/pt_pexpr_op.tcl.
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
# # ## ### ##### ######## #############
## Internals

proc ::pt::pe::op::Drop {dropset pe op arguments} {
    if {$op eq "n"} {
	lassign $arguments symbol
	if {[struct::set contains $dropset $symbol]} {
	    return @@
	} else {
	    return $pe
	}
    } 

    switch -exact -- $op {
	/ - x - * - + - ? - & - ! {
	    set newarg {}
	    foreach a $arguments {
		if {$a eq "@@"} continue
		lappend newarg $a
	    }

	    if {![llength $newarg]} {
		# Nothing remained, drop the whole expression
		return [pt::pe epsilon]
	    } elseif {[llength $newarg] < [llength $arguments]} {
		# Some removed, construct a new expression
		 if {$op eq "/"} {
		     set pe [list $op {*}$newarg]
		 } else {
		     set pe [pt::pe epsilon]
		 }
	     } ; # None removed, no change.
	}
    }

    return $pe
}

proc ::pt::pe::op::Rename {nt ntnew pe op arguments} {
    #puts R($op)/$arguments/
    if {($op eq "n") && ([lindex $arguments 0] eq $nt)} {
	return [pt::pe nonterminal $ntnew]







<
|
<

<
|
<
<
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
<
<







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
# # ## ### ##### ######## #############
## Internals

proc ::pt::pe::op::Drop {dropset pe op arguments} {
    if {$op eq "n"} {
	lassign $arguments symbol
	if {[struct::set contains $dropset $symbol]} {

	    set pe @@

	}

    } elseif {$op in {/ x * + ? & !}} {


	set newarg {}
	foreach a $arguments {
	    if {$a eq "@@"} continue
	    lappend newarg $a
	}

	if {![llength $newarg]} {
	    # Nothing remained, drop the whole expression
	    set pe [pt::pe epsilon]
	} elseif {[llength $newarg] < [llength $arguments]} {
	    # Some removed, construct a new expression
	    if {$op eq "/"} {
		set pe [list $op {*}$newarg]
	    } else {
		set pe @@
	    }
	} ; # None removed, no change.
    }


    return $pe
}

proc ::pt::pe::op::Rename {nt ntnew pe op arguments} {
    #puts R($op)/$arguments/
    if {($op eq "n") && ([lindex $arguments 0] eq $nt)} {
	return [pt::pe nonterminal $ntnew]