Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaeguard committed Sep 18, 2023
1 parent 0c1faa1 commit be2249b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ a very simple regex engine written in go.
- [x] `.` any single character/wildcard
- [x] `[ ]` bracket notation/ranges
- [x] `[^ ]` bracket negation notation
- [ ] Quantifiers
- [x] quantifiers
- [x] `*` none or more times
- [x] `+` one or more times
- [x] `?` optional
- [ ] `{m,n}` more than or equal to `m` and less than equal to `n` times
- [ ] Capturing Group
- [x] `{m,n}` more than or equal to `m` and less than equal to `n` times
- [x] capturing group
- [x] `( )` capturing group or subexpression
- [x] `\n` backreference, e.g, `(dog)\1` where `n` is in `[0, 9]`
- [x] `\k<name>` named backreference, e.g, `(?<animal>dog)\k<animal>`
- [ ] `\` escape character
- [ ] support special characters - context dependant
- [ ] better error handling in the API
- [ ] ability to work on multi-line strings
- [ ] `.` should not match the newline - `\n`
- [ ] `$` should match the newline - `\n`
- [ ] multiple full matches
8 changes: 2 additions & 6 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ type regexTokenType uint8

const (
Literal regexTokenType = iota // any literal character, e.g., a, b, 1, 2, etc.
NoneOrMore = iota // *
OneOrMore = iota // +
Optional = iota // ?
Or = iota // |
Bracket = iota // []
BracketNot = iota // [^]
Expand Down Expand Up @@ -294,6 +291,7 @@ func processChar(regexString string, memory *parsingContext, ch uint8) {
for regexString[endPos] != '}' {
endPos++
}
memory.advTo(endPos)
expr := regexString[startPos:endPos]
pieces := strings.Split(expr, ",")

Expand All @@ -306,14 +304,12 @@ func processChar(regexString string, memory *parsingContext, ch uint8) {
} else if len(pieces) == 2 {
start, _ = strconv.Atoi(pieces[0])
if pieces[1] == "" {
end = -1 // infinity
end = QuantifierInfinity
} else {
end, _ = strconv.Atoi(pieces[1])
}
}

memory.advTo(endPos)

token := regexToken{
tokenType: Quantifier,
value: quantifier{
Expand Down

0 comments on commit be2249b

Please sign in to comment.