| |
15 |
15 |
:public method line {kind string} { |
| |
16 |
16 |
if {${:state} ne $kind} { |
| |
17 |
17 |
if {${:state} ne ""} {:flush} |
| |
18 |
18 |
set :state $kind |
| |
19 |
19 |
set :text "" |
| |
20 |
20 |
} |
| |
21 |
21 |
append :text $string \n |
| |
22 |
22 |
} |
| |
23 |
23 |
:public method flush {} { |
| |
24 |
24 |
set trimmed [string trim ${:text} \n] |
| |
25 |
25 |
if {$trimmed ne ""} { |
| |
26 |
26 |
:${:state} $trimmed |
| |
27 |
27 |
} |
| |
28 |
28 |
} |
| |
29 |
29 |
:public method postprocess {block} { |
| |
30 |
30 |
set result "" |
| |
31 |
31 |
set cmd "" |
| |
32 |
32 |
foreach l [split $block \n] { |
| |
33 |
33 |
append cmd $l \n |
| |
34 |
34 |
if {[info complete $cmd]} then { |
| |
35 |
|
set w0 [lindex $cmd 0] |
| |
|
35 |
regexp {^\s*(\S+)\s*} $cmd _ w0 |
| |
|
36 |
#set w0 [lindex $cmd 0] |
| |
36 |
37 |
if { ($w0 eq "?" && [llength $cmd] == 3) || |
| |
37 |
38 |
($w0 eq "!" && [llength $cmd] == 2) } { |
| |
38 |
39 |
append result "% [lindex $cmd 1]\n" |
| |
39 |
40 |
set cmdresult [lindex $cmd 2] |
| |
40 |
41 |
if {$cmdresult ne "" && ![string match ::nsf::__* $cmdresult]} {append result $cmdresult \n} |
| |
41 |
42 |
} else { |
| |
42 |
43 |
append result $cmd |
| |
43 |
44 |
} |
| |
44 |
45 |
set cmd "" |
| |
45 |
46 |
} |
| |
46 |
47 |
} |
| |
47 |
48 |
return [string trimright $result \n] |
| |
48 |
49 |
} |
| |
49 |
50 |
:public method prog {block} { |
| |
50 |
51 |
puts $::out {[source,tcl]} |
| |
51 |
52 |
puts $::out -------------------------------------------------- |
| |
52 |
53 |
puts $::out [:postprocess $block] |
| |
53 |
54 |
puts $::out --------------------------------------------------\n |
| |
54 |
55 |
} |
| |
55 |
56 |
:public method doc {block} { |