Changeset - f62bf5223dbf
[Not reviewed]
tip default
0 1 0
Laman - 9 months ago 2024-07-15 13:50:50

added examples to the README
1 file changed with 14 insertions and 0 deletions:
0 comments (0 inline, 0 general)
README.md
Show inline comments
 
@@ -3,6 +3,7 @@
 
Written as an exercise in Rust and a refreshment of my university classes on finite automatons.
 

	
 
The supported syntax is restricted to the following operators:
 

	
 
* `*` - the Kleene star. The previous item can be present zero or more times.
 
* Concatenation - is implied between items following each other. `ab*` matches an `a` followed by any number of `b`s
 
* `+` or `|` - a union of several alternatives. Both symbols are equivalent.
 
@@ -31,6 +32,19 @@ python regexp.py compare PATTERN1 PATTER
 
./target/release/regular-expresso compare PATTERN1 PATTERN2
 
```
 

	
 
### Example
 
```
 
> ./regular-expresso match "(ab)*" abab
 
true
 
> ./regular-expresso match "(ab)*" aba
 
false
 

	
 
> ./regular-expresso compare "ab(ab)*" "a(ba)*b"
 
None
 
> ./regular-expresso compare "a*" "(_|a|aa)"
 
aaa
 
```
 

	
 
## Theory
 
1. The pattern gets parsed into a tree of its parts.
 
2. We check which symbols can stand at the beginning, which can follow each other and which can stand at the end of the string. These data are used to construct a non-deterministic finite automaton (NFA).
0 comments (0 inline, 0 general)