summaryrefslogtreecommitdiff
path: root/subplot.md
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers+gitlab@digital-scurf.org>2020-09-26 16:46:20 +0000
committerDaniel Silverstone <dsilvers+gitlab@digital-scurf.org>2020-09-26 16:46:20 +0000
commit61f68650e69d62ea9ba91bc9a917e6bc64941979 (patch)
tree5a0f31c7143fc49e923593251e501b18f00ab634 /subplot.md
parent40ae77152af8c7dbf39d42842184614c63c485ba (diff)
parent7a9c629cd851d24002529aa721addd3c20a0bf95 (diff)
downloadsubplot-61f68650e69d62ea9ba91bc9a917e6bc64941979.tar.gz
Merge branch 'patterns' into 'main'
add: simple word pattern kinds Closes #85 See merge request larswirzenius/subplot!73
Diffstat (limited to 'subplot.md')
-rw-r--r--subplot.md22
1 files changed, 19 insertions, 3 deletions
diff --git a/subplot.md b/subplot.md
index 5bb4779..ec0ca43 100644
--- a/subplot.md
+++ b/subplot.md
@@ -431,13 +431,30 @@ In the example above, there are four bindings:
* A binding for a "then everything is OK" step, which captures nothing,
and calls the `check_everything_is_ok` function.
-The simple patterns (`{name}`) capture white-space delimited words. A
-pattern uses simple patterns by default, or if the `regex` field is
+## Simple patterns
+
+The simple patterns are of the form `{name}` and match a single word
+consisting of printable characters. This can be varied by adding a
+suffix, such as `{name:text}` which matches any text. The following
+kinds of simple patterns are supported:
+
+* `{name}` or `{name:word}` &ndash; a single word
+* `{name:text}` &ndash; any text
+* `{name:int}` &ndash; any whole number, including negative
+* `{name:uint}` &ndash; any unsigned whole number
+* `{name:number}` &ndash; any number
+
+A pattern uses simple patterns by default, or if the `regex` field is
set to false. To use regular expressions, `regex` must be set to true.
Subplot complains if typical regular expression characters are used,
when simple patterns are expected, unless `regex` is explicitly set to
false.
+## Regular expression patterns
+
+Regular expression patterns are used only if the binding `regex` field
+is set to `true`.
+
The regular expressions use [PCRE][] syntax as implemented by the Rust
[regex][] crate. The `(?P<name>pattern)` syntax is used to capture
parts of the step. The captured parts are given to the bound function
@@ -447,7 +464,6 @@ as arguments, when it's called.
[regex]: https://crates.io/crates/regex
-
## Functions file
Functions implementing steps are supported in Bash and Python. The