Escape_brackets, Usage, Options – Altera Quartus II Scripting User Manual

Page 300: Description, Escape_brackets –170

Advertising
background image

3–170

Chapter 3: Tcl Packages & Commands

misc

Quartus II Scripting Reference Manual

© July 2013

Altera Corporation

escape_brackets

Usage

escape_brackets <str>

Options

<str>: String to escape

Description

Escapes square brackets in bus name patterns for use in string matching. Also escapes the escape
character; for example, the string "\" is escaped into "\\".

Note that natural bus naming is supported by default. This means that bus names, not bus name patterns,
are automatically detected and do not need to be escaped by using this command. Bus names have the
following format:

<bus name>[<bus index>] or <bus name>[*]

The <bus name> portion is a string of alphanumeric characters. The <bus index> portion is an integer
greater than or equal to zero or it can be the character "*" used for string matching. Notice that the <bus
index> is enclosed by the square brackets "[" and "]". For example, "a[0]" and "a[*]" are supported bus
names.

All other uses of square brackets must be escaped if you do not intend to use the brackets as part of a string
pattern in a string match. For example, the bus name pattern "a\[0-2\]" must be escaped using this
"escape_brackets" command since the "0-2" does not satisfy the <bus index> requirement to be a bus name.

Many Quartus II Tcl commands allow string matching in option arguments. A common error is using bus
name patterns in these arguments, such as:

address\[0-2\]

Square brackets for bus name patterns must already be preceded by an escape character (\[ or \]) to
prevent Tcl from interpreting them as sub-commands. String matching, however, also uses square brackets
to match any character between the brackets. The previous example, when used as a string match pattern,
searches for the string patterns address0, address1, and address2. It does not search for address[0],
address[1], and address[2].

Therefore, for arguments that support string matching, square brackets must be escaped twice (\\\[ or
\\\]) so that the strings are interpreted as bus name patterns. For example, to search for address[0],
address[0], and address[2], type the following string match pattern:

address\\\[\[0-2\]\\\]

or, equivalently,

"address[escape_brackets \[]\[0-2\][escape_brackets \]]"

Quartus II Tcl commands do not convert bus name patterns automatically, since they cannot determine if
the string is intended as a bus name pattern or a regular string match pattern. Therefore, "escape_brackets"
is provided for your convenience.

You may choose to disable natural bus naming in order to string match patterns such as "in\[024\]". In this
example, you are string matching the names "in0", "in2", and "in4".

To disable natural bus naming, type "disable_natural_bus_naming".

Note that if you disable natural bus naming, then square brackets must be escaped twice (\\\[ or \\\]) so
that the strings are interpreted as bus names during a string match, such as:

Advertising