Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

followup now that https://github.com/nim-lang/Nim/issues/15511 was fixed #103

Merged
merged 4 commits into from
Mar 21, 2021
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
nim: [0.19.6, 0.20.0, 0.20.2, 1.0.0, 1.0.2, 1.0.4, 1.0.10, 1.2.0, 1.2.2, 1.2.4, 1.2.6, 1.2.8, 1.4.0, 1.4.2]
# xxx trim to on use latest in each branch eg 1.0.10, 1.2.8 etc
nim: [1.0.0, 1.0.2, 1.0.4, 1.0.10, 1.2.0, 1.2.2, 1.2.4, 1.2.6, 1.2.8, 1.4.0, 1.4.2, 1.4.4]
steps:
- uses: actions/checkout@v2
- name: Run Tests
Expand Down
3 changes: 2 additions & 1 deletion regex.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT"
srcDir = "src"
skipDirs = @["tests", "bench", "docs"]

requires "nim >= 0.19.6"
requires "nim >= 1.0.0"
requires "unicodedb >= 0.7.2"

task test, "Test":
Expand All @@ -33,4 +33,5 @@ task test, "Test":
exec "nim doc -o:./docs/ugh/ugh.html ./src/regex.nim"

task docs, "Docs":
# xxx use --outdir:docs
exec "nim doc --project -o:./docs ./src/regex.nim"
6 changes: 5 additions & 1 deletion src/regex/nfa.nim
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ func teClosure(
for s in eNfa.s[state].next:
teClosure(result, eNfa, s, processing, zclosure)

when (NimMajor, NimMinor, NimPatch) < (1,4,0) and not declared(IndexDefect):
# avoids a warning
type IndexDefect = IndexError

func eRemoval*(eNfa: Enfa): Nfa {.raises: [].} =
## Remove e-transitions and return
## remaining state transtions and
Expand Down Expand Up @@ -220,7 +224,7 @@ func eRemoval*(eNfa: Enfa): Nfa {.raises: [].} =
while qw.len > 0:
try:
qa = qw.popLast()
except IndexError:
except IndexDefect:
doAssert false
closure.setLen 0
teClosure(closure, eNfa, qa, processing)
Expand Down
9 changes: 2 additions & 7 deletions src/regex/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ when NimMajor >= 1:
import std/unicode
import std/sets
from std/algorithm import sorted
from std/sequtils import toSeq

import pkg/unicodedb/properties

Expand Down Expand Up @@ -186,13 +187,7 @@ func initSkipNode*(next: openArray[int16]): Node =
## while traversing the NFA
result = Node(
kind: reSkip,
cp: "#".toRune)
when false:
# pending https://github.com/nim-lang/Nim/issues/15511#issuecomment-719952709
result.next.add next
else:
for ai in next:
result.next.add ai
cp: "#".toRune, next: toSeq(next))

func isEmpty*(n: Node): bool =
## check if a set ``Node`` is empty
Expand Down