-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
accurate position of syntax error when parsing #416
Comments
It may not be as simple as adding the metadata. |
Actually, I just checked, and all parse errors came from the parser that have info about the line and col. I will see if I can add this information to the error when |
Added the same metadata to the parse errors. |
Hmmm. I updated my html files to point to /**
* @param {string} source
* @returns {Promise<lips.Pair[]>}
*/
export async function parseWithMetadata(source) {
const parser = new lips.Parser({ env: lips.env, meta: true });
parser.prepare(source);
return await lips.parse(parser);
} but am not getting |
It works, I've put your code into CodPen: https://codepen.io/jcubic/pen/MYgexza?editors=0012 |
Now that I've force-reloaded many times, the cache has cleared and I am getting line/columns on some of the syntax errors now. However I am still not getting position info for the "Parser: expected parenthesis but eof found" error. Indeed, when you open the codepen you shared above and change the ")" to "(", the position information all shows up, but is all undefined. |
The problem was that lexer was returning |
I've updated the demo with the latest version https://codepen.io/jcubic/pen/MYgexza?editors=0012 |
Added line number to all error messages, when using higher level |
When I call lips.parse() and it gives me a syntax error there seems to be no way to see at what position in the source the parse error occurred, cause the comments and whitespace get thrown out.
I also tried the "parse with metadata" option you shared earlier in #414 (comment), but it gave the same result (no
__line__
or__col__
appeared).is there a better way to find the exact index of a syntax error?
The text was updated successfully, but these errors were encountered: