Skip to content

Commit

Permalink
updated fragment embeding handling
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Nov 20, 2023
1 parent 7e5a15f commit 11ec855
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions matcher/fragment.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (d *FragmentFold) Match(cursor *parsly.Cursor) int {
if matchEnd >= len(cursor.Input) {
return d.size
}
if !IsWhiteSpace(cursor.Input[matchEnd]) {
if IsLetter(cursor.Input[matchEnd]) || IsDigit(cursor.Input[matchEnd]) {
return 0
}
return d.size
Expand Down Expand Up @@ -61,7 +61,7 @@ func (d *Fragment) Match(cursor *parsly.Cursor) int {
if matchEnd >= len(cursor.Input) {
return d.size
}
if !IsWhiteSpace(cursor.Input[matchEnd]) {
if IsLetter(cursor.Input[matchEnd]) || IsDigit(cursor.Input[matchEnd]) {
return 0
}
return d.size
Expand Down
10 changes: 9 additions & 1 deletion matcher/letter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package matcher

//IsLetter returns true if byte is ASCII letter
// IsLetter returns true if byte is ASCII letter
func IsLetter(b byte) bool {
if (b < 'a' || b > 'z') && (b < 'A' || b > 'Z') {
return false
}
return true
}

// IsDigit returns true if byte is ASCII digit
func IsDigit(b byte) bool {
if b < '0' || b > '9' {
return false
}
return true
}

0 comments on commit 11ec855

Please sign in to comment.