Skip to content

Commit

Permalink
Improve the documentation on unquoted words in query expressions
Browse files Browse the repository at this point in the history
This mentions that $ and @ are allowed in unquoted words (previously omitted). The documentation of the characters allowed in unquoted words is also changed to list punctuation characters in the same relative order and format as the list of punctuation characters allowed in target names in that section of the documentation.

It also lists the full set of characters permitted in target expressions which are not permitted in unquoted words (the documentation previously mentioned + and = only in examples and ~ not at all). It emphasizes the implication of this: When writing code that generates query expressions, target names should be quoted.

A slight tweak is made to the bit about alphanumeric characters, since A-Za-z is not "the set of alphabetic characters" and 0-9 is not "numerals" unless you specify "in ASCII".

RELNOTES: None.
PiperOrigin-RevId: 247435415
  • Loading branch information
Googler authored and copybara-github committed May 9, 2019
1 parent 793b18d commit aca672f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions site/docs/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,21 @@ <h2 id='tokens'>Tokens: The Lexical Syntax</h2>
<li>
<p>
<b>Words</b>, such as <code>foo/...</code> or
<code>".*test rule"</code> or
<code>//bar/baz:all</code>.
If a character sequence is "quoted" (begins and ends with a
single-quote <code>'</code>, or begins and ends with a
double-quote <code>&quot;</code>), it is a word.
If a character sequence is not quoted, it may still be parsed as a word.
Unquoted words are sequences of characters drawn from
the set of alphabet characters, numerals, slash <code>/</code>,
hyphen <code>-</code>, underscore <code>_</code>, star <code>*</code>, and
period <code>.</code>. Unquoted words may not start with a
hyphen or period.
<code>".*test rule"</code> or <code>//bar/baz:all</code>. If a
character sequence is "quoted" (begins and ends with a single-quote
<code>'</code>, or begins and ends with a double-quote
<code>&quot;</code>), it is a word. If a character sequence is not
quoted, it may still be parsed as a word. Unquoted words are sequences
of characters drawn from the alphabet characters <code>A-Za-z</code>,
the numerals <code>0-9</code>, and the punctuation <code>_/.-@*$</code>
(underscore, slash, period, hyphen, at sign, star, dollar sign).
Unquoted words may not start with a hyphen or period, even though
relative <a href="build-ref.html#name">target names</a> may start with
those characters. Unquoted words also may not include the characters
plus sign <code>+</code>, equals sign <code>=</code>, or tilde
<code>~</code>, even though those characters are permitted in target
names. Thus, when writing code that generates query expressions, target
names should be quoted.
</p>

<p>We chose this syntax so that quote marks aren't needed in most cases.
Expand Down

0 comments on commit aca672f

Please sign in to comment.