-
Notifications
You must be signed in to change notification settings - Fork 98
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
Let's use a parser other than dxf-parser. #95
Comments
Yes, I agree that current parser is not good. I actually realized that, when created the project, and it supposed to be a temporal solution. For that reason, it is not used from its repo, For current library version, there is no so strong reasons to switch the parser. Besides estetical part, there are a couple of problems I would like to solve, but after a quick look at your parser I see, you have conceptually everything the same as in Finally, type-safety does not give any benefits until the project itself is switched to TS. All this stuff was planned for future major version, however I currently have drastical lack of free time to spend for this project. Work was actually started in |
You want to process large files right away rather than splitting them up and leaving them in memory, right? |
Yes, it should be processed as it is read, line by line. |
I'm also (sometimes) contributing that parser lib, so maybe I can help. Actually I almost redesign them. I understood your requirements, and I also agree for such direction. Since current parser sometimes lookup previous token, note that it must hold some constant(O(1)) buffer, but not definitely entire files(O(n)). But to be clear, I'd like to check the meaning of your following sentence:
Is this means that you want something like following: const it = parseDxf(streamString)
let res = it.next()
while (!res.done) {
const partialEntityOrHeaderOrWhatever = res.value
res = it.next()
} and you don't want like following const entireThings = parseDxf(streamString) right? If it's right, then there is a one problem. DXF specification DOES have some nested context. For example, when parsing ENTITIES section, each parsing attempts generate each ENTITY, but they're also part of ENTITIES. In that case, what Each user have their own schema (which can't be determined during library development), and they require different context. Therefore it's not possible to 'split' the output of the stream exactly. And most of other languages (like JavaScript, or even simple toy grammar of algebraic syntax like But following alternatives may work
|
Yes, something like this.
Yes, that's true, the context is needed indeed, and can be, for example, provided by the user, returning context object from his entity callback, and being passed in nested entities callback invocations. The user decides what should be stored in this context, and what can be discarded. Typically, it can be its representation of the corresponding entity. Alternatively, it can be some parsing-state-related structure needed only during the parsing stage. I would recommend you to not bother with some new parser, because it is quite a low chance that I will accept some 3rd-party implementation of the parser, because it will anyway require significant integration and testing work with no clear benefit, which I want to avoid in 1.0.x branch. Also, I do not want it to be just a TS rewrite of the same old |
Well I'm not a big fan of such approach. And I'm not sure it really has significant performance difference. And receving yet another user defined schema makes difficulty extremly hard as hell. DXF specification changes merely, there is no reason to support generic structure because user still can reduce our full sized parser's result, and can throw it out from memory with respect to their own purpose. (And they can even do that for each steps, since almost every datum are independent to previous one)
I couldn't understand what this exactly means. Do you mean to implement your own parser? |
Yes, there is some work already started in this repository |
Oh I though this repository was dotoritos's one- but here it was |
The dxf-parser currently applied parses the data unreliably, which may result in missing data.
And the dxf-parser repository seems to be dead.
To solve that problem, I created a better, typesafe parser and created a repository. How about trying this parser?
dxf-json repo
dxf-json npm
The text was updated successfully, but these errors were encountered: