updated string interpolation docs

pull/432/head
Scott Anderson 2019-08-26 15:24:06 -06:00
parent 6cef09039f
commit 7fbf960f12
1 changed files with 6 additions and 8 deletions

View File

@ -283,12 +283,6 @@ escaped_char = `\` ( "n" | "r" | "t" | `\` | `"` ) .
StringExpression = "${" Expression "}" . StringExpression = "${" Expression "}" .
``` ```
{{% note %}}
To be added: TODO: With string interpolation `string_lit` is not longer a lexical token as part of a literal, but an entire expression in and of itself.
[IMPL#252](https://github.com/influxdata/platform/issues/252) Parse string literals.
{{% /note %}}
##### Examples of string literals ##### Examples of string literals
```js ```js
@ -300,12 +294,12 @@ To be added: TODO: With string interpolation `string_lit` is not longer a lexica
``` ```
String literals are also interpolated for embedded expressions to be evaluated as strings. String literals are also interpolated for embedded expressions to be evaluated as strings.
Embedded expressions are enclosed in curly brackets (`{}`). Embedded expressions are enclosed within the literals `${` and `}` respectively.
The expressions are evaluated in the scope containing the string literal. The expressions are evaluated in the scope containing the string literal.
The result of an expression is formatted as a string and replaces the string content between the brackets. The result of an expression is formatted as a string and replaces the string content between the brackets.
All types are formatted as strings according to their literal representation. All types are formatted as strings according to their literal representation.
A function `printf` exists to allow more precise control over formatting of various types. A function `printf` exists to allow more precise control over formatting of various types.
To include the literal curly brackets within a string they must be escaped. To include the literal `${` within a string, it must be escaped.
{{% note %}} {{% note %}}
[IMPL#248](https://github.com/influxdata/platform/issues/248) Add printf function. [IMPL#248](https://github.com/influxdata/platform/issues/248) Add printf function.
@ -320,6 +314,10 @@ n = 42
"dollar sign opening curly bracket \${" // dollar sign opening curly bracket ${ "dollar sign opening curly bracket \${" // dollar sign opening curly bracket ${
``` ```
{{% note %}}
[IMPL#1775](https://github.com/influxdata/flux/issues/1775) Interpolate arbitrary expressions in string literals
{{% /note %}}
### Regular expression literals ### Regular expression literals
A _regular expression literal_ represents a regular expression pattern, enclosed in forward slashes. A _regular expression literal_ represents a regular expression pattern, enclosed in forward slashes.