UnicodeSet documentation - #4171
Conversation
| character strings. The contents of that object can be specified either by | ||
| patterns or by building them programmatically. | ||
| A UnicodeSet is an object that represents a finite set of Unicode code point | ||
| sequences. The contents of that object can be specified either by |
There was a problem hiding this comment.
| sequences. The contents of that object can be specified either by | |
| sequences, optimized for single code points. The contents of that object can be specified either by |
| character strings. The contents of that object can be specified either by | ||
| patterns or by building them programmatically. | ||
| A UnicodeSet is an object that represents a finite set of Unicode code point | ||
| sequences. The contents of that object can be specified either by |
There was a problem hiding this comment.
Please avoid double spaces between sentences.
| patterns or by building them programmatically. | ||
| A UnicodeSet is an object that represents a finite set of Unicode code point | ||
| sequences. The contents of that object can be specified either by | ||
| patterns using the UnicodeSet syntax defined in |
There was a problem hiding this comment.
| patterns using the UnicodeSet syntax defined in | |
| pattern strings using the UnicodeSet syntax defined in |
| * <em>character classes</em> used in regular expressions. A UnicodeSet specifies a finite set of | ||
| * Unicode code points sequences. |
There was a problem hiding this comment.
| * <em>character classes</em> used in regular expressions. A UnicodeSet specifies a finite set of | |
| * Unicode code points sequences. | |
| * <em>character classes</em> used in regular expressions. A UnicodeSet specifies a finite set of | |
| * Unicode code point sequences, optimized for single code points. |
| * toPattern()</code> API from the <code> | ||
| * java.text.Format</code>-derived classes. Unlike the methods that add characters, add categories, | ||
| * and control the logic of the set, the method <code>applyPattern()</code> sets all attributes of a | ||
| * <code>UnicodeSet</code> at once, based on a string pattern. |
There was a problem hiding this comment.
| * <code>UnicodeSet</code> at once, based on a string pattern. | |
| * <code>UnicodeSet</code> at once, based on a pattern string. |
| * `\u` [four-hexadecimal-digits](https://www.unicode.org/reports/tr61/#four-hexadecimal-digits) | ||
| `\u` [four-hexadecimal-digits](https://www.unicode.org/reports/tr61/#four-hexadecimal-digits) | ||
| where the first constituent [four-hexadecimal-digits](https://www.unicode.org/reports/tr61/#four-hexadecimal-digits) | ||
| represent a high surrogate and the second constituent | ||
| [four-hexadecimal-digits](https://www.unicode.org/reports/tr61/#four-hexadecimal-digits) |
There was a problem hiding this comment.
optional:
when you refer to the same grammar production multiple times closely together, i would put a link only on the first one; the rest can just be plain text
(more readable .md file)
| * `$` is added as a [set-operator](https://www.unicode.org/reports/tr61/#set-operator), and the | ||
| following alternatives are added to [Content](https://www.unicode.org/reports/tr61/#Content)</a>: | ||
| > | `$` | ||
| > | [ElementList](https://www.unicode.org/reports/tr61/#ElementList) `$` | ||
| > | [UnescapedHyphenMinus](https://www.unicode.org/reports/tr61/#UnescapedHyphenMinus) [ElementList](https://www.unicode.org/reports/tr61/#ElementList) `$` | ||
| The following alternative is added to [ElementList](https://www.unicode.org/reports/tr61/#ElementList): | ||
| > | `$` [Elements](https://www.unicode.org/reports/tr61/#Elements) | ||
| The following alternative is added to [Union](https://www.unicode.org/reports/tr61/#Union): | ||
| > | `$` [UnicodeSet](https://www.unicode.org/reports/tr61/#UnicodeSet) | ||
| When the [set-operator](https://www.unicode.org/reports/tr61/#set-operator) `$` occurs | ||
| as an immediate constituent of a [Content](https://www.unicode.org/reports/tr61/#Content)</a>, | ||
| it represents the noncharacter code point U+FFFF. | ||
| When it occurs anywhere else, it represents the character U+0024 $ DOLLAR SIGN. |
There was a problem hiding this comment.
please precede the legalese with some prose like "a literal $ at the end of a set represents the noncharacter code point U+FFFF"
... and maybe even add something like "this is used in Transliterator rule syntax"
with a link to
https://unicode-org.github.io/icu/userguide/transforms/general/rules.html#%C3%A6ther
There was a problem hiding this comment.
Yes, I was thinking about that as I was updating the comments in the parser accordingly (the legalese is going to get worse!).
| element is introduced: | ||
| > variable ⩴ $ reference | ||
| where the function `SymbolTable::parseReference` defines the syntactic category | ||
| reference. The expansion of a variable is defined by `SymbolTable::lookup`; it |
There was a problem hiding this comment.
I think the word reference wants to be quoted or emphasized or something, to suggest that it's the term introduced in the lexical element above
| > :point_right: **Note**:*ICU Regular Expression set expressions have a different (but similar) syntax, | ||
| and a different set of recognized backslash escapes. \[Sets\] in ICU Regular | ||
| Expressions follow the conventions from Perl and Java regular expressions rather | ||
| than the pattern syntax from ICU UnicodeSet.* |
There was a problem hiding this comment.
I think we should keep this note somewhere on this page
| * the support for variables interacts with the API: If a {@link SymbolTable} is passed to the | ||
| * constructor of {@code UnicodeSet}, a new lexical element is introduced: | ||
| * | ||
| * <blockquote> | ||
| * | ||
| * <table> | ||
| * <tr style="vertical-align: top"> | ||
| * <td style="white-space: nowrap; vertical-align: top;text-align:right;"><code>pattern := </code></td> | ||
| * <td style="vertical-align: top;"><code>('[' '^'? item* ']') | | ||
| * property</code></td> | ||
| * </tr> | ||
| * <tr style="vertical-align: top"> | ||
| * <td style="white-space: nowrap; vertical-align: top;text-align:right;"><code>item := </code></td> | ||
| * <td style="vertical-align: top;"><code>char | (char '-' char) | pattern-expr<br> | ||
| * </code></td> | ||
| * </tr> | ||
| * <tr style="vertical-align: top"> | ||
| * <td style="white-space: nowrap; vertical-align: top;text-align:right;"><code>pattern-expr := </code></td> | ||
| * <td style="vertical-align: top;"><code>pattern | pattern-expr pattern | | ||
| * pattern-expr op pattern<br> | ||
| * </code></td> | ||
| * </tr> | ||
| * <tr style="vertical-align: top"> | ||
| * <td style="white-space: nowrap; vertical-align: top;text-align:right;"><code>op := </code></td> | ||
| * <td style="vertical-align: top;"><code>'&' | '-'<br> | ||
| * </code></td> | ||
| * </tr> | ||
| * <tr style="vertical-align: top"> | ||
| * <td style="white-space: nowrap; vertical-align: top;text-align:right;"><code>special := </code></td> | ||
| * <td style="vertical-align: top;"><code>'[' | ']' | '-'<br> | ||
| * </code></td> | ||
| * </tr> | ||
| * <tr style="vertical-align: top"> | ||
| * <td style="white-space: nowrap; vertical-align: top;text-align:right;"><code>char := </code></td> | ||
| * <td style="vertical-align: top;"><em>any character that is not</em><code> special<br> | ||
| * | ('\\' </code><em>any character</em><code>)<br> | ||
| * | ('\u' hex hex hex hex)<br> | ||
| * </code></td> | ||
| * </tr> | ||
| * <tr style="vertical-align: top"> | ||
| * <td style="white-space: nowrap; vertical-align: top;text-align:right;"><code>hex := </code></td> | ||
| * <td style="vertical-align: top;"><code>'0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |<br> | ||
| * 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f'</code></td> | ||
| * </tr> | ||
| * <tr> | ||
| * <td style="white-space: nowrap; vertical-align: top;text-align:right;"><code>property := </code></td> | ||
| * <td style="vertical-align: top;"><em>a Unicode property set pattern</em></td> | ||
| * </tr> | ||
| * </table> | ||
| * variable ⩴ <code>$</code> reference |
There was a problem hiding this comment.
optional: maybe reduce the duplication between this+following and the equivalent User Guide text?
TODO: Please describe your changes here.
TODO: Please read the following on ICU Contributing, and then delete these instructions.
Thank you for your pull request!
TODO: Fill out the checklist below.
Checklist