Replies: 5 comments
-
It is possible to implement this, but it would likely lead to significantly reduced performance, basically the Parser instance method implementations are dynamically chosen at runtime and then we "force" the V8 engine to treat it as if it is a more static class to gain the benefits of internal JIT optimizations that V8 can do. So we don't want to make the base parser even more dynamic by changing its structure post initialization.
|
Beta Was this translation helpful? Give feedback.
-
As far as I can tell, the CST visitor implementation references properties by name So even if you have two instances (with different config options) of the same sub-class of CSTParser it should not matter which of the instances you use to "create" your base CSTVisitor. If you can demonstrate an issue with the TypeScript types I would take a peek at it, but it seems to me the CST output "schema/types" would also be identical, so I don't think there should be type related issues. |
Beta Was this translation helpful? Give feedback.
-
In terms of performance, I would first implement the full featured editor parser and only then compare |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for the detailed explanations. Especially I always wondered why all of that |
Beta Was this translation helpful? Give feedback.
-
When a hot spot with |
Beta Was this translation helpful? Give feedback.
-
I would like to reuse the same parser/visitor in two different setups. One should be fast (recovery turned off and node location tracking disabled) and one should be integrated into an editor (recovery enabled and full location tracking). It seems that those settings (recovery and location tracking) must be chosen during initialization and can't be easily changed later on. Would this be a new feature that can be created with reasonable expenditure (I have my doubts a bit)?
Another option I see would be to create two different parsers dynamically (and maybe cache them), but the visitor extends the base CST visitor created by
myParser.getBaseCstVisitorConstructor()
which makes this a bit tricky (esp. with TypeScript I guess).Any other options here or something I overlooked?
Beta Was this translation helpful? Give feedback.
All reactions