Skip to content

Commit bf867f2

Browse files
committed
Blurb on calling the generated code.
1 parent c4d4ffe commit bf867f2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

doc/advice.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ libfsm provides two main tools for pattern matching:
6262

6363
A recommended workflow when using libfsm is:
6464

65-
1. Validate the Regex
65+
1. Validate the regex
6666

6767
Test behavior using any PCRE-compatible tool (e.g., [pcregrep(1)](https://man7.org/linux/man-pages/man1/pcregrep.1.html) on the CLI or [https://regex101.com/](https://regex101.com/) in the browser).
6868

69-
2. Verify libfsm Compatibility
69+
2. Verify libfsm compatibility
7070

7171
If unsupported constructs exist, libfsm reports the failing location:
7272
```sh
@@ -81,13 +81,13 @@ A recommended workflow when using libfsm is:
8181
```
8282

8383

84-
3. Generate Code
84+
3. Generate code
8585

8686
```sh
8787
re -p -r pcre -l rust -k str '^item-[A-Z]{3}\z' > item_detector.rs
8888
```
8989

90-
4. Multiple Patterns
90+
4. Multiple patterns
9191

9292
```sh
9393
# re - patterns from command line:
@@ -97,6 +97,12 @@ A recommended workflow when using libfsm is:
9797
rx -p -r pcre -l vmc -k str -d skipped.txt patterns.txt > detectors.c
9898
```
9999

100+
5. Call the generated code from your program somehow
101+
102+
You're on your own for this. `-k` controls the API for the generated code to read in data to match. Try different options for the language you're using and see which suits you.
103+
104+
The generated API can also vary depending on how you want libfsm to handle ambiguities between different patterns. See the `AMBIG_*` flags in [include/fsm/options.h](../include/fsm/options.h) for different approaches there.
105+
100106
Both tools:
101107
* Combine all patterns into one function (like using `|` to join them)
102108
* Generate code that can return `(bool, int)` for the match status and pattern ID
@@ -114,7 +120,7 @@ Both tools:
114120
| `-d` | Declined patterns | filename | Only applies to `rx` (batch mode) |
115121

116122
This is not an exhaustive list. For full flag details, see [include/fsm/options.h](../include/fsm/options.h) and the [man pages](../man).
117-
The man pages can be built by running `bmake -r doc`, then view with `build/man/re.1/re.1`.
123+
The man pages can be built by running `bmake -r doc`, then view with `man build/man/re.1/re.1`.
118124

119125
## Writing Effective libfsm Patterns
120126

0 commit comments

Comments
 (0)