zaach / jison

Bison in JavaScript.
http://jison.org
4.33k stars 448 forks source link

Can Jison parser be error tolerant? #376

Open wongjiahau opened 5 years ago

wongjiahau commented 5 years ago

Background

In order to design a [language-server[(https://code.visualstudio.com/docs/extensions/example-language-server) to be used for Visual Studio Code, the parser have to be error tolerant(the full mechanism is explained here).

Request

So, I'm wondering if Jison could integrate such feature into the parser.

For example, the parser should automatically fill-in missing token

function hello() {
    console.log("hello");
// } <-- missing token

function next() {
    console.log("next");
}

The parser should look for token that will minimize number of error-filling tokens.
In this case, if the parser tried to fill up the next token as let, then the next token will be error since after let should be variable identifier, so let will not be considered. So, the parser will try all possible next-token and choose the one that produces the least error.

Can you help with this @zaach ?