parser generator

2022-12-03 Thread Araq
The good: * Produces an LALR(1) parser. The bad: * Generates a 'proc lex(code: string): seq[Token]' Traditional lexers are iterator-like, they produce a single token and the storage is reused. For the lexer generator please steal from my [lexim](https://github.com/Araq/lexim) project

Don't understand why ref is marked cyclic

2022-12-03 Thread Araq
> I'm just wondering why this is marked "cyclic" because it seems to me that > it's just 2 references to something not something referencing itself. It's marked cyclic because the compiler thinks it could potentially create a cycle. I suppose the naming could be improved, the semantics are actua

Why is Rust faster than Nim in this CSV parsing example?

2022-12-03 Thread Araq
Why do you use split string hacks instead of the `parsecsv` standard library module?

Why is Rust faster than Nim in this CSV parsing example?

2022-12-03 Thread jrfondren
Take this Rust: `for l in csv.lines() {` What is `l` here? It's a `&str`, or a string slice: logically, a pointer and a length. At this point your program has nim.csv in a single `String` and you're operating over slices of that file without further allocation or copying. Now take this Nim: `

Using pairs() with iterators

2022-12-03 Thread nimmer-vimmer
I did not know about enumerate. TIL. Thank you!

Why is Rust faster than Nim in this CSV parsing example?

2022-12-03 Thread Vindaar
The very short answer is: Performance in these kinds of microbenchmarks depends on all sorts of implementation details. Nim can be just as fast as Rust and vice versa. In this case the CSV parser of the Nim stdlib isn't intended to be fast, but convenient. In addition using `split` and `mapIt` i

Using pairs() with iterators

2022-12-03 Thread Vindaar
The issue you're having is that `lines` itself is an iterator and `pairs` is as well. You can't combine iterators in this way. Either you need to read the file first, split it by lines and then use `pairs` on the resulting `seq[string]` like import strutils let lines = readFile

Don't understand why ref is marked cyclic

2022-12-03 Thread curioussav
If it helps the here is a block of code from the compiler output: chUp = initLine(view, Coord(x: pLeft, y: errorUp), Coord(x: pRight, y: errorUp), style, "line") chDown = initLine(view, Coord(x: pLeft, y: errorDown),

Don't understand why ref is marked cyclic

2022-12-03 Thread curioussav
So I have code that looks like this: let myobj = objectFactory() # returns ref object myseq = @[myobj] Run When checking the containing method with expandArc I see that `nimMarkCyclic` is called on the variable. This object is moved to another thread and the ORC c

parser generator

2022-12-03 Thread Stefan_Salewski
Thanks for the example, I will study it in more detail later. Note, in your readme you used the word "realy" with only one l twice, as well as in your post above. I think common English term is really with two l, you may consider fixing it in the readme.

Forum subscription feature

2022-12-03 Thread carterza
I think a basic prerequisite for great forum software would be the ability to retrieve posts, yet the forum consistently fails at doing this. This is not the way.

parser generator

2022-12-03 Thread choltreppe
You could write it like that: import std/[strutils, strformat] import /home/joel/daten/programming/nim/parlexgen/src/parlexgen type TokenKind = enum tkRect, tkSep, tkNum Token = object case kind: TokenKind of tkNum: val: float else: dis

parser generator

2022-12-03 Thread Stefan_Salewski
Interesting. Unfortunately I have never tried parser generators myself. For my simple use cases Nim's parseutils or strscan was not that bad. Or npegs. In the book I have an example like import std/strscans proc sep(input: string; start: int; seps: set[char] = {' ',',',';'}

parser generator

2022-12-03 Thread choltreppe
Hallo all, I would like to show you a parser generator I wrote: Short summary why I wrote it: I have some projects where I need to parse things, and I was using the std/pegs module for that, but I was not realy happy with that solution. So I searched

Using pairs() with iterators

2022-12-03 Thread nimmer-vimmer
I would like to iterate over a large file line by line. I would also like to increment a counter for each line while doing so. I tried the following without success. import strutils for i, line in pairs("somefile.txt".lines): echo i, line Run That results i

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-03 Thread alexeypetrushin
This is the step in the right direction (I think it's called the [Reactor Pattern](https://en.wikipedia.org/wiki/Reactor_pattern)). It covers most of cases needed from the server. Good job! @boia01 and other implementations are good job too :).

Why is Rust faster than Nim in this CSV parsing example?

2022-12-03 Thread N4v
Hello everyone, I have recently started learning about Nim, and I really like it so far. The elegance of the syntax plus the flexibility of the template/macro system are really cool. Just for fun, I did a small exercise where I produced a CSV file of the numbers 0 through 2,999,999 in three co

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-03 Thread boia01
Just for awareness, I'll mention another, relatively mature, select + threads-based HTTP server with websocket support:

Forum subscription feature

2022-12-03 Thread moigagoo
I guess implementing RSS could me relatively easy. We don't have it yet, the demand hasn't been too high for this feature. However, if you subscribe to the official Telegram or Discord, you'll get notified about new threads.

Forum subscription feature

2022-12-03 Thread boia01
My workaround has been to use the forum's RSS feed and to email posts. Disclaimer: I am not affiliated with Blogtrottr and its free tier is ad-supported. Also, you will get some spam because the RSS feed includes out all new posts, including yet-to-be-moderated posts.

Forum subscription feature

2022-12-03 Thread moigagoo
Contributions are welcome! By the way, the forum is a great example of software written in Nim.

Forum subscription feature

2022-12-03 Thread carterza
What do you think this is? Phpbb? Discourse? This forum barely functions... I'm being facetious, but in all seriousness, no you can't. I'm sure someone though will tell you contributions are welcome and that the forum is a great example of software written in Nim.

Forum subscription feature

2022-12-03 Thread pposca
Hi, Is there a way tu subscribe to forum threads, users and/or categories?

ftpclient download problem.

2022-12-03 Thread ingo
On my umpteencore i9 it also takes 30s. 't seems I'm inpatient ;) although with the windows command-line ftp client the download is almost instantaneous.

Advent of Nim 2022

2022-12-03 Thread shirleyquirk
shirleyquirk's horrifying hack for day3: Want dubious micro-optimized performance gains, AND the possibility of undefined behaviour? Access the lowest member of a set in O(1)! import std/bitops type Priority = range[1..52] func lowest(s:set[Priority]):Priority = asser

ftpclient download problem.

2022-12-03 Thread Jaap
on my slow Contabo linux vm your example results in a file of around 7720 bytes in a slow 30 seconds

ftpclient download problem.

2022-12-03 Thread ingo
The code below does not finish. The file is downloaded, is size stays at 0 until I ctrl-C the program. (using win11) import std/[asyncdispatch, asyncftpclient] proc main() {.async.} = var msg:string var ftp = newAsyncFtpClient("ftp.knmi.nl", user = "anonymous", p

sequtils.nim(786, 15) Error: expected: ':', but got: 'result'

2022-12-03 Thread fxn
I wonder if that line being part of a template may mess up with the rename feature.

sequtils.nim(786, 15) Error: expected: ':', but got: 'result'

2022-12-03 Thread fxn
Wow, I have found it. I have looked at the file in my disk and it is different to the one in GitHub for `v1.6.10`. I have never opened that file, but while doing an AoC exercise I renamed a symbol using [this VS Code extension](https://github.com/pragmagic/vscode-nim) and the rename modified `

sequtils.nim(786, 15) Error: expected: ':', but got: 'result'

2022-12-03 Thread fxn
This has to be a simple thing I am missing, but for some reason I am no longer able to import `std/sequtils`: tmp % cat foo.nim import std/sequtils tmp % nim c foo.nim Hint: used config file '/usr/local/Cellar/nim/1.6.10/nim/config/nim.cfg' [Conf] Hint: used config f