Skip to content

Commit

Permalink
Change toRune(string) to toRune(char) (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely authored Dec 11, 2024
1 parent 09c5d12 commit 1d3f085
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 142 deletions.
8 changes: 4 additions & 4 deletions src/regex/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const
# Nim and not the actual `\n`
lineBreakRune* = Rune(10)

proc toRune*(s: string): Rune =
result = s.runeAt(0)
func toRune*(c: char): Rune =
result = Rune(c.ord)

proc `<=`*(x, y: Rune): bool =
func `<=`*(x, y: Rune): bool =
x.int <= y.int

proc cmp*(x, y: Rune): int =
func cmp*(x, y: Rune): int =
x.int - y.int

func bwRuneAt*(s: string, n: int): Rune =
Expand Down
6 changes: 3 additions & 3 deletions src/regex/exptransformation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func expandOneRepRange(subExpr: seq[Node], n: Node): seq[Node] =
result.add(subExpr)
result.add(Node(
kind: reZeroOrMore,
cp: "*".toRune,
cp: '*'.toRune,
isGreedy: n.isGreedy))
elif n.min == n.max: # a{n} -> aaa
result = newSeqOfCap[Node](subExpr.len * n.max)
Expand All @@ -270,12 +270,12 @@ func expandOneRepRange(subExpr: seq[Node], n: Node): seq[Node] =
for _ in n.min ..< n.max - 1:
result.add(Node(
kind: reZeroOrOne,
cp: "?".toRune,
cp: '?'.toRune,
isGreedy: n.isGreedy))
result.add(subExpr)
result.add(Node(
kind: reZeroOrOne,
cp: "?".toRune,
cp: '?'.toRune,
isGreedy: n.isGreedy))

func expandRepRange(exp: Exp): Exp =
Expand Down
Loading

0 comments on commit 1d3f085

Please sign in to comment.