Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any javascript frameworks for parsing/auto-completing a domain specific language?

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-complete / auto-suggest engine?

Thanks!

like image 943
franck102 Avatar asked Feb 24 '11 20:02

franck102


People also ask

What is used to parse and execute JavaScript code?

Different browsers have different JavaScript engines to parse and execute our code. The first thing that happens within the JavaScript engine is parsing of our code by parser.

What is parsing in JavaScript?

Parsing means analyzing and converting a program into an internal format that a runtime environment can actually run, for example the JavaScript engine inside browsers. The browser parses HTML into a DOM tree.

What is used for parsing and running JavaScript in Nodejs?

Parse Arguments using process.argv is the simplest way of parsing arguments in Node. js and you do not need to install any additional package or library for that.

Is JavaScript DSL?

js-dsl is Javascript framework for developing internal domain specific languages (DSLs) that let you declaratively build arbitrary trees to parallel your abstract syntax tree (AST) or semantic model (SM).


2 Answers

An Example of implementing content assist (auto-complete) using Chevrotain Javascript Parsing DSL:

https://github.com/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.
like image 179
bd82 Avatar answered Sep 18 '22 18:09

bd82


You may want jison, a js parser generator. In terms of auto-complete / auto-suggest...most of the stuff out there I know if more based on word completion rather than code completion. But once you have a parser running I don't think that part is too difficult..

like image 39
ysaw Avatar answered Sep 17 '22 18:09

ysaw