Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading