diff options
author | Daniel Silverstone <dsilvers+gitlab@digital-scurf.org> | 2020-09-26 16:46:20 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers+gitlab@digital-scurf.org> | 2020-09-26 16:46:20 +0000 |
commit | 61f68650e69d62ea9ba91bc9a917e6bc64941979 (patch) | |
tree | 5a0f31c7143fc49e923593251e501b18f00ab634 /subplot.md | |
parent | 40ae77152af8c7dbf39d42842184614c63c485ba (diff) | |
parent | 7a9c629cd851d24002529aa721addd3c20a0bf95 (diff) | |
download | subplot-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.md | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -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}` – a single word +* `{name:text}` – any text +* `{name:int}` – any whole number, including negative +* `{name:uint}` – any unsigned whole number +* `{name:number}` – 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 |