You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now after using the libdparse API again, I have to complain a bit.
As a user I don't care about LexerConfig, StringCache, RollBackAllocator etc. - those are mostly implementation details and once you added the RollbackAllocator it broke my code and other code.
Here's the most minimal example to read in a module:
File f = File(fileName);
ubyte[] sourceCode = uninitializedArray!(ubyte[])(to!size_t(f.size));
f.rawRead(sourceCode);
LexerConfig config;
StringCache cache = StringCache(StringCache.defaultBucketCount);
auto tokens = getTokensForParser(sourceCode, config, &cache);
RollbackAllocator rba;
Module m = parseModule(tokens.array, fileName, &rba);
How about adding a parseFile method that abstracts this for the user and allows use to swap around the internals in the future?
Module m = parseFile(fileName);
The text was updated successfully, but these errors were encountered:
That might work if we allocate the string cache and the rollback allocator using the GC. Those need to have a longer lifetime than the AST returned from the function.
That might work if we allocate the string cache and the rollback allocator using the GC. Those need to have a longer lifetime than the AST returned from the function.
Yep and my point was that for simple use cases that's the case. Don't give simple users control about something they don't care/know about.
Btw another interesting idea that Ilya is using in his ndslice API is to let the user pass in his allocator and then return everything that has been allocated:
Now after using the libdparse API again, I have to complain a bit.
As a user I don't care about LexerConfig, StringCache, RollBackAllocator etc. - those are mostly implementation details and once you added the RollbackAllocator it broke my code and other code.
Here's the most minimal example to read in a module:
How about adding a
parseFile
method that abstracts this for the user and allows use to swap around the internals in the future?The text was updated successfully, but these errors were encountered: