From 775f20630c7c96e57774f113e7e76bff76b0cf43 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Thu, 25 Feb 2021 12:20:37 -0800 Subject: [PATCH 1/4] followup now that https://github.com/nim-lang/Nim/issues/15511 was fixed --- src/regex/types.nim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/regex/types.nim b/src/regex/types.nim index b51e6c1..e0af11e 100644 --- a/src/regex/types.nim +++ b/src/regex/types.nim @@ -187,12 +187,13 @@ func initSkipNode*(next: openArray[int16]): Node = result = Node( kind: reSkip, cp: "#".toRune) - when false: - # pending https://github.com/nim-lang/Nim/issues/15511#issuecomment-719952709 + when (NimMajor, NimMinor, NimPatch) >= (1,5,1) or (not defined(gcOrc) and not defined(gcArc)): + # refs https://github.com/nim-lang/Nim/issues/15511 result.next.add next else: - for ai in next: - result.next.add ai + result.next.setLen next.len + for i in 0.. Date: Thu, 25 Feb 2021 12:45:44 -0800 Subject: [PATCH 2/4] simplify via toSeq --- src/regex/types.nim | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/regex/types.nim b/src/regex/types.nim index e0af11e..569a1dd 100644 --- a/src/regex/types.nim +++ b/src/regex/types.nim @@ -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 @@ -186,14 +187,7 @@ func initSkipNode*(next: openArray[int16]): Node = ## while traversing the NFA result = Node( kind: reSkip, - cp: "#".toRune) - when (NimMajor, NimMinor, NimPatch) >= (1,5,1) or (not defined(gcOrc) and not defined(gcArc)): - # refs https://github.com/nim-lang/Nim/issues/15511 - result.next.add next - else: - result.next.setLen next.len - for i in 0.. Date: Thu, 25 Feb 2021 12:50:02 -0800 Subject: [PATCH 3/4] avoid warning: IndexError is deprecated --- src/regex/nfa.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/regex/nfa.nim b/src/regex/nfa.nim index b5c7a74..cf16427 100644 --- a/src/regex/nfa.nim +++ b/src/regex/nfa.nim @@ -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 @@ -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) From 72571b5e4119c3f4179301aff8962782668dffd8 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Thu, 25 Feb 2021 13:11:04 -0800 Subject: [PATCH 4/4] drop support for nim < 1.0 which broke tests --- .github/workflows/ci.yml | 3 ++- regex.nimble | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c2637a..d8d6143 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/regex.nimble b/regex.nimble index 9918116..ca7b817 100644 --- a/regex.nimble +++ b/regex.nimble @@ -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": @@ -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"