admin管理员组文章数量:1368297
I have a grammar for a domain specific language, and I need to create a javascript code editor for that language. Are there any tools that would allow me to generate a) a javascript incremental parser b) a javascript auto-plete / auto-suggest engine?
Thanks!
I have a grammar for a domain specific language, and I need to create a javascript code editor for that language. Are there any tools that would allow me to generate a) a javascript incremental parser b) a javascript auto-plete / auto-suggest engine?
Thanks!
Share Improve this question asked Feb 24, 2011 at 20:14 franck102franck102 1611 silver badge3 bronze badges3 Answers
Reset to default 4An Example of implementing content assist (auto-plete) using Chevrotain Javascript Parsing DSL:
https://github./SAP/chevrotain/tree/master/examples/parser/content_assist
Chevrotain was designed specifically to build parsers used (as part of) language services tools in Editors/IDEs. Some of the relevant features are:
- Automatic Error Recovery / Fault tolerance because editors and IDEs need to be able to handle 'mostly valid' inputs.
- Every Grammar rule may be used as the starting rule as an Editor/IDE may only want to implement incremental parsing for performance reasons.
You may want jison, a js parser generator. In terms of auto-plete / auto-suggest...most of the stuff out there I know if more based on word pletion rather than code pletion. But once you have a parser running I don't think that part is too difficult..
This is difficult. I'm doing the same sort of thing myself.
One approach is:
You need is a parser which will give you an array of the currently possible ASTs for the text up until the token before the current cursor position.
From there you can see the next token can be of a number of types (usually just one), and do the pletion, based on the partial text.
If I ever get my incremental parser working, I'll send a link.
Good luck, and let me know if you find a package which does this.
Chris.
版权声明:本文标题:Are there any javascript frameworks for parsingauto-completing a domain specific language? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743670930a2519521.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论