By the way, here is a little more detail on one of the issues that I 
encountered. In pegs.nim (0.19.2 and devel), in the parsePeg proc, the 
PegParser var that is created seems to get re-initialized after the init call 
returns when running in the VM at compile time.

The existing code looks like 
    
    
    var p: PegParser
    init(PegLexer(p), pattern, filename, line, col)
    # p.buf, etc should now be set from init call,  but are not
    
    
    Run

The workaround that I was using for my previous experiments added a separate 
PegLexer var to use in the init call, and then afterwards copied the data into 
the PegParser var. 
    
    
    var p: PegParser
    var l: PegLexer
    init(l, pattern, filename, line, col)
    p.bufpos = l.bufpos
    p.buf = l.buf
    p.lineNumber = l.lineNumber
    p.lineStart = l.lineStart
    p.colOffset = l.colOffset
    p.filename = l.filename
    
    
    Run

It's not clear to me why the PegParser var gets re-initialized when running in 
the VM at compile time, but not in regular code, but that workaround above was 
at least enough to let me proceed with my tests.

Anyone have any thoughts on why that happens and/or pointers in Nim's source 
where I might investigate more?

Reply via email to