|
2009-06-30
| ||
| 04:47 | • Closed ticket [2814219fff]: Documentation for TclParser is not good plus 7 o... artifact: 618b0e0ab2 user: dgp | |
| 04:47 | • Ticket [2814219fff]: 4 changes artifact: 9c43d2976d user: dgp | |
| 04:41 | • Ticket [2814219fff]: 1 change artifact: 19dd0a9da6 user: msofer | |
|
2009-06-29
| ||
| 20:21 | • New ticket [2814219fff]. artifact: dc9e3a87cf user: hgiese | |
Documentation for TclParser is not good
Closed / Invalid2814219fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-06-29 20:21:56
Hello,
The man page for parse(n) 1.4 is in a sad state.
I suggest the following corrections:
---
Contrary to the description a range is not of the form {first last} but rather {first length}. I suggest the following modifications:
1st paragraph: ... and a range into the script: {first length}. The command parses the script from the first index for <i>length</i> characters. For convenience <i>length</i> can be set to <i>end</i> with the obvious meaning.
Then, change all occurrences of
... [arg first] [arg last]
to
... <i>range</i>
---
2nd paragraph: To the list of tokens add 'expand'
---
3rd paragraph: Change the text to
The <i>first</i> index is treated the same way as are indices in the Tcl string command. An index of 0 refers to the first character of the string. An index of end (or any abbreviation of it) refers to the last character of the string. If first is less than zero then it is treated as if it were zero, and if <i>first + length</i> is greater than or equal to the length of the string then it is treated as if it were end.
if you feel that this description is correct.
---
Remove any mention of 'subcommand' in the Synopsis and in the description. It
does not exist (any more).
---
Under 'Name' at the top of the page please correct this cut 'n paste error
parse - System to control logging of events.
---
'parse list' gives weird results. See below.
#
# [parse list] delivers very curious results when $range is surrounded
# by braces (which happens rather often in Tcl) - even if the range
# selects only the text within the braces.
#
# Example:
# set script {{foo bar baz}} ;# braces are part of the script
# parse list $script {1 11} ;# ... but not part of the range
# -> {0 5} {5 3} {9 3} ;# note the '0' - outside of the range (!)
#
I have the following work-around: I don't hand 'parse list' the original script with the original range, but rather extract the text from the range myself and pass it to 'parse list' with a range {0 end}. Later I adjust the result(s) to point at the correct position in the script.
Maybe a quick fix would be to just implement this work around at the C level.
proc parseList {tree node script range} {
if { $range eq "" } {set range {0 end}}
set src [parse getstring $script $range]
set orgStart [lindex $range 0] ;# here our src started in reality
# 'parse list' returns the range of each element
set res [parse list $src {0 end}]
for {set i 0} {$i < [llength $res]} {incr i} {
set start [lindex $res $i 0]
lset res $i 0 [expr {$start + $orgStart}]
}
...
---
Add a description of what the 'countnewline' subcommand does and what parameters it expects.
Best regards
Helmut Giese
msofer Ticket [2814219fff]: 1 change
[History diff]2009-06-30 04:41:17
dgpplain2009-06-30 04:47:27
There is no parse.n file in the source code distribution of Tcl and no [parse] command among Tcl's built-in commands. Please file your report in the appropriate project.
dgpplain2009-06-30 04:47:28
allow_comments - 1
Log in (anonymous is fine) to add a comment.