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
Add jsre #14870
Add jsre #14870
Conversation
to fix test failure, you can update kochdocs as follows (untested but shouldn't be hard to make it work): # add this:
proc isJsOnly(file: string): bool = file.isRelativeTo("lib/js")
# update `commands[i] = nim & " doc $# --git.url:$# --outdir:$# --index:on $#" % [nimArgs2, gitUrl, destPath, d]`
# to:
let isJsOnly =
var extra = ""
if isJsOnly(d): extra.add " --backend:js"
commands[i] = nim & " doc $# $# --git.url:$# --outdir:$# --index:on $#" % [extra, nimArgs2, gitUrl, destPath, d] (let me know if anything is unclear) |
@juancarlospaco this test will fail: doAssert jsregex.exec(r"nim javascript") == @["nim"] => doAssert jsregex.exec(r"nim javascript") == @["nim".cstring] (as you can see locally with |
and you still need to update kochdocs as described in #14870 (comment) otherwise CI will fail with: 2020-07-01T20:56:15.7235670Z /Users/runner/runners/2.263.0/work/Nim/Nim/lib/js/jsre.nim(6, 13) Error: after that LGTM for me |
eg: # in re.nim
when defined(js):
{.error: "This library needs to be compiled with a c-like backend, and depends on PCRE.".}
=>
when defined(js):
{.error: "This library needs to be compiled with a c-like backend, and depends on PCRE; see std/jsre for js backend".}
running locally |
Shouldn't this be a "fusion" module? |
if regex is stdlib territory for c backend, it makes sense to have regex for js in stdlib as well; it should reduce friction when porting working nim code from c to js; and as said above, in future work it would be nice for this to be transparent (so that re/nre can use jsre under the hood for js backend). And this could be gradual (1 proc at a time). I don't think pkg/regex is "the answer" in the js case since I expect it to have large overhead over jsre but maybe @juancarlospaco can do a quick benchmark? /cc @nitely |
For an example where it would help to have jsre in stdlib, nim-markdown would be able to support js backend. |
@pietroppeter did you look into https://github.com/nitely/nim-regex? I think it might be a good fit too |
@Yardanico see remark here #14870 (comment), this at very least needs a performance comparison, assuming https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions would be natively (or at least efficiently) implemented whereas nim-regex would incur large overhead on js backend |
yes, I was aware of nim-regex, having seen it mentioned in #7640 (which could actually be closed if this is merged), but it is good that this is also mentioned in this conversation. I still think this jsre would be a good fit for stdlib:
|
jsre
module, Regular Expressions for the JavaScript target.:)