Skip to content

Commit a5bc8d4

Browse files
Update docs
1 parent 835da84 commit a5bc8d4

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

doc/GUIDE.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ libfsm provides stable, “first-class” code generation for:
4646

4747
## Workflow Overview
4848

49+
libfsm provides two main tools: **`re`** takes patterns from command line, **`rx`** takes patterns from file.
50+
4951
### 1. Validate the Regex
5052

5153
Test behavior using any PCRE-compatible tool (e.g., [https://regex101.com/](https://regex101.com/)).
@@ -68,28 +70,34 @@ If unsupported constructs exist, libfsm reports the failing location.
6870
re -p -r pcre -l rust -k str '^item-[A-Z]{3}$' > item_detector.rs
6971
```
7072

71-
### 4. For Multiple Patterns
73+
### 4. Multiple Patterns
7274

7375
```bash
76+
# re - patterns from command line:
77+
re -p -r pcre -l go -k str '^x?a b+c$' '^x*def?$' '^x$'
78+
79+
# rx - patterns from file:
7480
rx -p -r pcre -l vmc -k str -d skipped.txt patterns.txt > detectors.c
7581
```
7682

77-
* Combines all patterns into one function (like using `|` to join them)
78-
* Unsupported patterns are written to `skipped.txt`
83+
Both tools:
84+
* Combine all patterns into one function (like using `|` to join them)
85+
* Return `(bool, int)` - match status and pattern ID
86+
* Pattern ID is argument position for `re`, line number for `rx`
87+
* When encountering unsupported patterns: `rx` skips them to `-d` file and generates code with working patterns; `re` fails completely
7988

8089
---
8190

82-
### `re` / `rx` Flag Reference
83-
84-
| Flag | Purpose | Common Options | Notes |
85-
| ---- | --------------------------- | ----------------------------------------- | ------------------------------------------ |
86-
| `-r` | Select regex dialect | `pcre`, `literal`, `glob`, `native`, `sql`| `pcre` supports the widest set of features |
87-
| `-l` | Choose output language | `go`, `rust`, `vmc`, `llvm`, `wasm` | Use `vmc` for generating `C` code |
88-
| `-k` | Generated function I/O API | `str`, `getc`, `pair` | `str` takes string/slice, `getc` uses callback for streaming, `pair` takes byte array |
89-
| `-p` | Production mode | *(no value)* | Generates optimized code |
90-
| `-d` | Output unsupported patterns | filename | Only applies to `rx` (batch mode) |
91+
### Flag Reference
92+
| Flag | Purpose | Common Options | Notes |
93+
| ---- | --------------------------- | ------------------------------------------ | ------------------------------------------ |
94+
| `-r` | Select regex dialect | `pcre`, `literal`, `glob`, `native`, `sql` | `pcre` supports the widest set of features |
95+
| `-l` | Choose output language | `go`, `rust`, `vmc`, `llvm`, `wasm`, `dot` | Use `vmc` for `C` code, pipe `dot` into `idot` for visualization |
96+
| `-k` | Generated function I/O API | `str`, `getc`, `pair` | `str` takes string, `pair` takes byte array, `getc` uses callback for streaming |
97+
| `-p` | Production mode | *(no value)* | Generates optimized code |
98+
| `-d` | Output unsupported patterns | filename | Only applies to `rx` (batch mode) |
9199

92-
For more detailed information on flags, see [include/fsm/options.h](../include/fsm/options.h).
100+
For more detailed information on flags, see [include/fsm/options.h](../include/fsm/options.h) and the man pages (by running `build/man/re.1/re.1` after `bmake doc`).
93101

94102
---
95103

0 commit comments

Comments
 (0)