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: doc/advice.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,11 +62,11 @@ libfsm provides two main tools for pattern matching:
62
62
63
63
A recommended workflow when using libfsm is:
64
64
65
-
1. Validate the Regex
65
+
1. Validate the regex
66
66
67
67
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).
68
68
69
-
2. Verify libfsm Compatibility
69
+
2. Verify libfsm compatibility
70
70
71
71
If unsupported constructs exist, libfsm reports the failing location:
72
72
```sh
@@ -81,13 +81,13 @@ A recommended workflow when using libfsm is:
81
81
```
82
82
83
83
84
-
3. Generate Code
84
+
3. Generate code
85
85
86
86
```sh
87
87
re -p -r pcre -l rust -k str '^item-[A-Z]{3}\z'> item_detector.rs
88
88
```
89
89
90
-
4. Multiple Patterns
90
+
4. Multiple patterns
91
91
92
92
```sh
93
93
# re - patterns from command line:
@@ -97,6 +97,12 @@ A recommended workflow when using libfsm is:
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
+
100
106
Both tools:
101
107
* Combine all patterns into one function(like using `|` to join them)
102
108
* Generate code that can return`(bool, int)`for the match status and pattern ID
@@ -114,7 +120,7 @@ Both tools:
114
120
|`-d`| Declined patterns | filename | Only applies to `rx` (batch mode) |
115
121
116
122
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`.
0 commit comments