Annotation For lib/minirivet/minirivet.tcl

Origin for each line in lib/minirivet/minirivet.tcl from check-in b07616bee9:

47dcf5fc27 2019-05-01    1: #! /usr/bin/env tclsh
47dcf5fc27 2019-05-01    2: 
47dcf5fc27 2019-05-01    3: namespace eval ::minirivet {}
47dcf5fc27 2019-05-01    4: 
b07616bee9 2019-09-20    5: if {![info exists ::minirivet::_outputChannel] && ![info exists ::minirivet::_outputVariable]} {
b07616bee9 2019-09-20    6: 	set ::minirivet::_outputChannel stdout
b07616bee9 2019-09-20    7: }
b07616bee9 2019-09-20    8: 
b07616bee9 2019-09-20    9: proc ::minirivet::setOutputChannel {channel} {
b07616bee9 2019-09-20   10: 	unset -nocomplain ::minirivet::_outputVariable
b07616bee9 2019-09-20   11: 	set ::minirivet::_outputChannel $channel
b07616bee9 2019-09-20   12: }
b07616bee9 2019-09-20   13: 
b07616bee9 2019-09-20   14: proc ::minirivet::setOutputVar {variable} {
b07616bee9 2019-09-20   15: 	unset -nocomplain ::minirivet::_outputChannel
b07616bee9 2019-09-20   16: 	set ::minirivet::_outputVariable $variable
b07616bee9 2019-09-20   17: }
b07616bee9 2019-09-20   18: 
b07616bee9 2019-09-20   19: proc ::minirivet::_emitOutput {string} {
b07616bee9 2019-09-20   20: 	if {[info exists ::minirivet::_outputChannel]} {
b07616bee9 2019-09-20   21: 		puts -nonewline $::minirivet::_outputChannel $string
b07616bee9 2019-09-20   22: 	}
b07616bee9 2019-09-20   23: 	if {[info exists ::minirivet::_outputVariable]} {
b07616bee9 2019-09-20   24: 		append $::minirivet::_outputVariable $string
b07616bee9 2019-09-20   25: 	}
b07616bee9 2019-09-20   26: 	return
b07616bee9 2019-09-20   27: }
b07616bee9 2019-09-20   28: 
9b0190676f 2019-05-22   29: proc ::minirivet::parseStringToCode {string} {
47dcf5fc27 2019-05-01   30: 	set code ""
47dcf5fc27 2019-05-01   31: 	while {$string ne ""} {
47dcf5fc27 2019-05-01   32: 		set endIndex [string first "<?" $string]
47dcf5fc27 2019-05-01   33: 		if {$endIndex == -1} {
47dcf5fc27 2019-05-01   34: 			set endIndex [expr {[string length $string] + 1}]
47dcf5fc27 2019-05-01   35: 		}
47dcf5fc27 2019-05-01   36: 
b07616bee9 2019-09-20   37: 		append code [list ::minirivet::_emitOutput [string range $string 0 $endIndex-1]] "; "
47dcf5fc27 2019-05-01   38: 		set string [string range $string $endIndex end]
47dcf5fc27 2019-05-01   39: 		set endIndex [string first "?>" $string]
47dcf5fc27 2019-05-01   40: 		if {$endIndex == -1} {
47dcf5fc27 2019-05-01   41: 			set endIndex [expr {[string length $string] + 1}]
47dcf5fc27 2019-05-01   42: 		}
47dcf5fc27 2019-05-01   43: 
47dcf5fc27 2019-05-01   44: 		set work [string range $string 0 2]
47dcf5fc27 2019-05-01   45: 		if {$work eq "<?="} {
47dcf5fc27 2019-05-01   46: 			set startIndex 3
b07616bee9 2019-09-20   47: 			append code "::minirivet::_emitOutput [string trim [string range $string 3 $endIndex-1]]; "
47dcf5fc27 2019-05-01   48: 		} else {
47dcf5fc27 2019-05-01   49: 			append code [string range $string 2 $endIndex-1] "\n"
47dcf5fc27 2019-05-01   50: 		}
47dcf5fc27 2019-05-01   51: 
47dcf5fc27 2019-05-01   52: 		set string [string range $string $endIndex+2 end]
47dcf5fc27 2019-05-01   53: 
47dcf5fc27 2019-05-01   54: 
47dcf5fc27 2019-05-01   55: 	}
47dcf5fc27 2019-05-01   56: 
f09ab16ca1 2019-05-08   57: 	return $code
f09ab16ca1 2019-05-08   58: }
f09ab16ca1 2019-05-08   59: 
f09ab16ca1 2019-05-08   60: proc ::minirivet::parseString {string} {
f09ab16ca1 2019-05-08   61: 	set code [parseStringToCode $string]
47dcf5fc27 2019-05-01   62: 	tailcall namespace eval ::request $code
47dcf5fc27 2019-05-01   63: }
47dcf5fc27 2019-05-01   64: 
47dcf5fc27 2019-05-01   65: proc ::minirivet::parse {file} {
47dcf5fc27 2019-05-01   66: 	set fd [open $file]
47dcf5fc27 2019-05-01   67: 	set data [read $fd]
47dcf5fc27 2019-05-01   68: 	close $fd
47dcf5fc27 2019-05-01   69: 	tailcall parseString $data
47dcf5fc27 2019-05-01   70: }
47dcf5fc27 2019-05-01   71: 
47dcf5fc27 2019-05-01   72: package provide minirivet 1