'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH Tcl 7tcl "8.1" Tcl "Tcl Built-In Commands" .BS .SH NAME Tcl \- 語言語法總結. .BE .SH 描述 DESCRIPTION .PP 下面的規則定義 Tcl 語言的語法和語義: .IP [1] 一個 Tcl 腳本是一個包含一個或多個命令的字符串。除了象後面描述的那樣被引用(quote)之外,分號(Semi-colon)和換行(newline)是命令分隔符。除了被引用(quote)之外,右方括號(Close bracket)在命令替換期間是命令終結符(見後)。 .IP [2] 命令的求值分兩步。 首先,Tcl 解釋器把命令分解成字 (\fIwords\fR) 並按下面描述的那樣完成替換。對所有命令都以同樣的方式進行替換。第一個字用於定位完成這個命令的一個命令過程,接着命令的所有的字被傳遞給命令過程。命令過程以它喜歡的任何方式自由的解釋命令的字,如一個整數、變量名、列表、或 Tcl 腳本。不同的命令以不同的方式解釋它們的字。 .IP [3] 一個命令的字(word)由白空格(不包括作爲命令分隔符的換行)來分隔。 .IP [4] 如果一個字的第一個字符是雙引號 (``"'',double-quote) 則字終結於下一個雙引號字符。如果是分號,右方括號,或白空格字符(包括換行)出現在引號之間則被作爲普通的字符對待幷包含在字裏。象下面描述的那樣,在引號之間的字符上進行命令替換、變量替換、和反斜槓替換。雙引號不作爲字的一部分而保留。 .IP [5] 如果一個字的第一個字符是左花括號 (“{”,open brace) 則字終結於相匹配的右花括號 (“}”,close brace)。花括號在字中嵌套: 對於每個增加的(additional)左花括號都必須有一個增加的右花括號(但是,如果 在一個字中的左括號或右括號被用一個反斜槓引用起來則在匹配右花括號時不計在內)。除了下面描述的反斜槓-換行替換之外,在花括號之間的字符上不進行替換,對分號、換行、右方括號、或白空格不做特殊的解釋。字由外側的花括號之間的字符精確的組成,不包括花括號自身。 .IP [6] 如果一個字包含一個左方括號 (\[lq][\[rq],open bracket ) 則 Tcl 進行命令替 換 (\fIcommand substitution\fR)。爲此將遞歸調用 Tcl 解釋器來把左方括號後 面的字符作爲一個 Tcl 腳本處理。腳本可以包含任意數目的命令並且必須用一個 右方括號 (\[lq]]\[rq],close bracket) 來終結。腳本的結果(例如,最後的一條命令的結 果)將被替換到字中方括號和它們中間所有字符的位置上。在一個單一的字中可以 有任意數目的命令替換。在由花括號包起來(enclose)的字上不進行命令替換。 .IP [7] 如果一個字包含一個美元符(``$'')則 Tcl 進行變量替換 (\fIvariable substitution\fR): 字中的美元符號和跟隨的字符被一個變量的值所替換。接受下面幾種形式(form)的變量替換: .RS .TP 15 \fB$\fIname\fR \fIName\fR 是一個標量(scalar)變量的名字;名字終結於任何不是字母、數字、或下劃線(underscore)的字符。 .TP 15 \fB$\fIname\fB(\fIindex\fB)\fR \fIName\fR 給出一個數組變量的名字,\fIindex\fR 給出在這個數組中的一個元素的名字. \fIName\fR 只能包含字母、數字、和下劃線。\fIindex\fR 的字符將被進行命令替換、變量替換、和反斜槓替換。 .TP 15 \fB${\fIname\fB}\fR \fIName\fR 是一個標量( scalar)變量的名字。它可以包含除了右括號之外的任何字符。 .LP 一個單一的字中可以有任意數目的變量替換。在由花括號包起來(enclose)的字上不進行命令替換。 .RE .IP [8] 如果在一個字中出現一個反斜槓(\[lq]\\\[rq])則發生反斜槓替換 (\fIbackslash substitution\fR)。除了下面描述的這些情況之外,反斜槓 (backslash)被刪除 (drop),跟隨的字符被作爲普通字符對待。這就允許在字中包含象雙引號、右方括 號、和美元符號等字符而不觸發特殊的處理。下表列出的要特殊處理的反斜槓序列 ,跟着的是每個序列被替換成的值。 .RS .TP 7 \e\fBa\fR 聲音警告 (振鈴) (0x7). .TP 7 \e\fBb\fR 退格 (0x8). .TP 7 \e\fBf\fR 換頁 (0xc). .TP 7 \e\fBn\fR 換行 (0xa). .TP 7 \e\fBr\fR 回車 (0xd). .TP 7 \e\fBt\fR 跳格(Tab) (0x9). .TP 7 \e\fBv\fR 縱向跳格 (0xb). .TP 7 \e\fB\fIwhiteSpace\fR . 一個單一的空格字符替換反斜槓、換行和在換行後面的所有空格和跳格。這個反斜槓序列是唯一一個在命令被實際分析之前在一次獨立的預處理(pre- pass)中被替換的。這意味着即使在花括號之間這個替換也發生,並且不在花括號和引號之間時作爲結果的空格被作爲一個字分隔符對待。 .TP 7 \e\e 反斜槓 (``\''). .VS 8.1 br .TP 7 \e\fIooo\fR . 數字\fIooo\fR(它們中的一個、兩個、或三個)給出一個八進制數,是要插入的 Unicode 字符的八位值。 Unicode 字符的高位(upper)將是 0. .TP 7 \e\fBx\fIhh\fR . 十六進制數 \fIhh\fR 給出要插入的 Unicode 字符的八位值。可以提供任意數目的十六進制數字 ;但除了最後兩位之外都被忽略(結果總是一個一字節的數量)。Unicode 字符的高位(upper)將是 0. .TP 7 \e\fBu\fIhhhh\fR . 十六進制數 \fIhhhh\fR (它們中的一個、兩個、三個、或四個)給出要插入的 Unicode 字符的十六位值。 .VE .LP 除了前面描述的反斜槓-換行,在由花括號包起來(enclose)的字上不進行反斜槓替換。 .RE .IP [9] 如果一個升音符 “#” (sharp / hash) 出現在 Tcl 希望是一個命令的第一個字的地方(point),則升音符和其後面跟隨的、一直到下一個換行的所有字符,被作爲一個註釋對待並被忽略。註釋字符只有出現在一個命令開始時纔有意義(significance)。 .IP [10] 每個字符作爲建立的一個命令的某個字的一部分,被 Tcl 解釋器精確的處理一次。例如,如果發生了變量替換則在變量的值上不進行進一步的替換;值被原封不動的(verbatim)插入字中。如果發生了命令替換則嵌套的命令被對 Tcl 解釋器的遞歸調用整個的處理;在做遞歸調用之前不進行替換並且對嵌套的腳本的結果不進行額外的(additional)替換。 .IP [11] 替換不影響一個命令的字邊界(boundary)。例如,即使變量的值包含空格,在變量替換期間變量的整個的值成爲一個單一的字的一部分。 .SH "[中文版維護人]" .B 寒蟬退士 .SH "[中文版最新更新]" .B 2001/06/21 .SH "《中國 Linux 論壇 man 手冊頁翻譯計劃》:" .BI http://cmpp.linuxforum.net .SH "跋" .br 本頁面中文版由中文 man 手冊頁計劃提供。 .br 中文 man 手冊頁計劃:\fBhttps://github.com/man-pages-zh/manpages-zh\fR