You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/api/syntax/writing-syntax.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,30 @@ Parse tags are then applied to each choice, meaning it is equivalent to writing
119
119
Note that there is a group surrounding the parse tag.
120
120
For this feature to work, the parse tag must be empty, and surrounding putting the parse tag within a group ensures this is the case.
121
121
122
+
#### Parse marks
123
+
124
+
The parse mark is the simpler predecessor to the parse tag.
125
+
While less commonly used today, it is still supported.
126
+
Essentially, it is a numeric parse tag, as they are written in the same manner:
127
+
```text
128
+
(1:stop|shutdown) [the] server [in %-timespan%]
129
+
```
130
+
131
+
When a pattern element with a parse mark is used, the parse mark value of the parse is updated.
132
+
In the example above, when `stop` is used, the parse mark value will be `1`.
133
+
134
+
Unlike parse tags, there is only a single parse mark value when an entire pattern is parsed.
135
+
So, what happens when multiple parse marks are reached?
136
+
Their values are XORed.
137
+
Consider the following example:
138
+
```text
139
+
(1:stop|shutdown) [the] server [2:and display an alert]
140
+
```
141
+
In this example, if `stop` is not used, but `and display an alert` is, the parse mark value will be `2`.
142
+
However, if both are used, since the values are XORed, the parse mark value will be `3`.
143
+
144
+
In general, parse tags are recommended over parse marks for their superior readability, but parse marks are still supported for situations that warrant their usage.
145
+
122
146
#### Pattern options summarized
123
147
The pattern options summarized are:
124
148
- Use square brackets (`[the]`) for optional text
@@ -129,7 +153,7 @@ The pattern options summarized are:
129
153
- Prefix with `-` to mark as nullable
130
154
- Suffix with `@-1` or `@1` to force the time state
131
155
- Use angle brackets (`<expr>`) for regular expressions
132
-
- Use colons (`tag:pattern`) for parse tags
156
+
- Use colons for parse tags (`tag:pattern`) and parse marks (`number:pattern`)
133
157
134
158
#### Adding patterns to a syntax info
135
159
When creating a syntax info, patterns can be added by using the following methods from the SyntaxInfo.Builder interface:
0 commit comments