OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [doc/] [Tcl.n] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1993 The Regents of the University of California.
3
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4
'\"
5
'\" See the file "license.terms" for information on usage and redistribution
6
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7
'\"
8
'\" RCS: @(#) $Id: Tcl.n,v 1.1.1.1 2002-01-16 10:25:24 markom Exp $
9
'
10
.so man.macros
11
.TH Tcl n "" Tcl "Tcl Built-In Commands"
12
.BS
13
.SH NAME
14
Tcl \- Summary of Tcl language syntax.
15
.BE
16
 
17
.SH DESCRIPTION
18
.PP
19
The following rules define the syntax and semantics of the Tcl language:
20
.IP [1]
21
A Tcl script is a string containing one or more commands.
22
Semi-colons and newlines are command separators unless quoted as
23
described below.
24
Close brackets are command terminators during command substitution
25
(see below) unless quoted.
26
.IP [2]
27
A command is evaluated in two steps.
28
First, the Tcl interpreter breaks the command into \fIwords\fR
29
and performs substitutions as described below.
30
These substitutions are performed in the same way for all
31
commands.
32
The first word is used to locate a command procedure to
33
carry out the command, then all of the words of the command are
34
passed to the command procedure.
35
The command procedure is free to interpret each of its words
36
in any way it likes, such as an integer, variable name, list,
37
or Tcl script.
38
Different commands interpret their words differently.
39
.IP [3]
40
Words of a command are separated by white space (except for
41
newlines, which are command separators).
42
.IP [4]
43
If the first character of a word is double-quote (``"'') then
44
the word is terminated by the next double-quote character.
45
If semi-colons, close brackets, or white space characters
46
(including newlines) appear between the quotes then they are treated
47
as ordinary characters and included in the word.
48
Command substitution, variable substitution, and backslash substitution
49
are performed on the characters between the quotes as described below.
50
The double-quotes are not retained as part of the word.
51
.IP [5]
52
If the first character of a word is an open brace (``{'') then
53
the word is terminated by the matching close brace (``}'').
54
Braces nest within the word: for each additional open
55
brace there must be an additional close brace (however,
56
if an open brace or close brace within the word is
57
quoted with a backslash then it is not counted in locating the
58
matching close brace).
59
No substitutions are performed on the characters between the
60
braces except for backslash-newline substitutions described
61
below, nor do semi-colons, newlines, close brackets,
62
or white space receive any special interpretation.
63
The word will consist of exactly the characters between the
64
outer braces, not including the braces themselves.
65
.IP [6]
66
If a word contains an open bracket (``['') then Tcl performs
67
\fIcommand substitution\fR.
68
To do this it invokes the Tcl interpreter recursively to process
69
the characters following the open bracket as a Tcl script.
70
The script may contain any number of commands and must be terminated
71
by a close bracket (``]'').
72
The result of the script (i.e. the result of its last command) is
73
substituted into the word in place of the brackets and all of the
74
characters between them.
75
There may be any number of command substitutions in a single word.
76
Command substitution is not performed on words enclosed in braces.
77
.IP [7]
78
If a word contains a dollar-sign (``$'') then Tcl performs \fIvariable
79
substitution\fR:  the dollar-sign and the following characters are
80
replaced in the word by the value of a variable.
81
Variable substitution may take any of the following forms:
82
.RS
83
.TP 15
84
\fB$\fIname\fR
85
\fIName\fR is the name of a scalar variable;  the name is terminated
86
by any character that isn't a letter, digit, or underscore.
87
.TP 15
88
\fB$\fIname\fB(\fIindex\fB)\fR
89
\fIName\fR gives the name of an array variable and \fIindex\fR gives
90
the name of an element within that array.
91
\fIName\fR must contain only letters, digits, and underscores.
92
Command substitutions, variable substitutions, and backslash
93
substitutions are performed on the characters of \fIindex\fR.
94
.TP 15
95
\fB${\fIname\fB}\fR
96
\fIName\fR is the name of a scalar variable.  It may contain any
97
characters whatsoever except for close braces.
98
.LP
99
There may be any number of variable substitutions in a single word.
100
Variable substitution is not performed on words enclosed in braces.
101
.RE
102
.IP [8]
103
If a backslash (``\e'') appears within a word then
104
\fIbackslash substitution\fR occurs.
105
In all cases but those described below the backslash is dropped and
106
the following character is treated as an ordinary
107
character and included in the word.
108
This allows characters such as double quotes, close brackets,
109
and dollar signs to be included in words without triggering
110
special processing.
111
The following table lists the backslash sequences that are
112
handled specially, along with the value that replaces each sequence.
113
.RS
114
.TP 6
115
\e\fBa\fR
116
Audible alert (bell) (0x7).
117
.TP 6
118
\e\fBb\fR
119
Backspace (0x8).
120
.TP 6
121
\e\fBf\fR
122
Form feed (0xc).
123
.TP 6
124
\e\fBn\fR
125
Newline (0xa).
126
.TP 6
127
\e\fBr\fR
128
Carriage-return (0xd).
129
.TP 6
130
\e\fBt\fR
131
Tab (0x9).
132
.TP 6
133
\e\fBv\fR
134
Vertical tab (0xb).
135
.TP 6
136
\e\fB\fIwhiteSpace\fR
137
A single space character replaces the backslash, newline, and all
138
spaces and tabs after the newline.
139
This backslash sequence is unique in that it is replaced in a separate
140
pre-pass before the command is actually parsed.
141
This means that it will be replaced even when it occurs between
142
braces, and the resulting space will be treated as a word separator
143
if it isn't in braces or quotes.
144
.TP 6
145
\e\e
146
Backslash (``\e'').
147
.TP 6
148
\e\fIooo\fR
149
The digits \fIooo\fR (one, two, or three of them) give the octal value of
150
the character.
151
.TP 6
152
\e\fBx\fIhh\fR
153
The hexadecimal digits \fIhh\fR give the hexadecimal value of
154
the character.  Any number of digits may be present.
155
.LP
156
Backslash substitution is not performed on words enclosed in braces,
157
except for backslash-newline as described above.
158
.RE
159
.IP [9]
160
If a hash character (``#'') appears at a point where Tcl is
161
expecting the first character of the first word of a command,
162
then the hash character and the characters that follow it, up
163
through the next newline, are treated as a comment and ignored.
164
The comment character only has significance when it appears
165
at the beginning of a command.
166
.IP [10]
167
Each character is processed exactly once by the Tcl interpreter
168
as part of creating the words of a command.
169
For example, if variable substitution occurs then no further
170
substitutions are performed on the value of the variable;  the
171
value is inserted into the word verbatim.
172
If command substitution occurs then the nested command is
173
processed entirely by the recursive call to the Tcl interpreter;
174
no substitutions are performed before making the recursive
175
call and no additional substitutions are performed on the result
176
of the nested script.
177
.IP [11]
178
Substitutions do not affect the word boundaries of a command.
179
For example, during variable substitution the entire value of
180
the variable becomes part of a single word, even if the variable's
181
value contains spaces.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.