You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to develop/debug grammars using the playground would be easier if when there is an error in the input/source and we click the error message it also jumped to the definition/rule in the grammar.
If the parser knows the rule that failed somehow this info could be encoded in the error message to allow jump to it.
Attached is a grammar and input file that actually gives this error message on input:
It seems clear that the failing rule is known due to the expecting list provided, so if that rule could also be shown on the grammar editor when clicking the error message that would be nice.
Maybe something like this pseudo code:
function generateErrorListHTML(errors) {
let html = '<ul>';
html += $.map(errors, function (x) {
return '<li data-ln="' + x.ln + '" data-col="' + x.col + '" data-gln="' + xg.ln + '" data-gcol="' + xg.col + '"><span>' + x.ln + ':' + x.col + '</span> <span>' + escapeHtml(x.msg) + '</span></li>';
}).join('');
html += '<ul>';
return html;
}
...
// Event handing in the info area
function makeOnClickInInfo(editor) {
return function () {
const el = $(this);
editor.navigateTo(el.data('ln') - 1, el.data('col') - 1);
editor.scrollToLine(el.data('ln') - 1, true, false, null);
editor.focus();
if(el.data('gln')) {
grammar.navigateTo(el.data('gln') - 1, el.data('gcol') - 1);
grammar.scrollToLine(el.data('gln') - 1, true, false, null);
}
}
};
@mingodad, I think it's possible to make links for definition rules in expecting lists. (By the way, in your examples, 'construct', 'static', ... are not rules, but tokens. So they cannot be links.)
There is no way to report line no and column offset if a parser isn't made from a grammar, but constructed with parser combinators. I'll close it for now since I am not planning to implement it.
Just for an working example of this feature on a related project (base on your playground) see https://mingodad.github.io/CocoR-Typescript/playground , for example select the Json parser (using the select at the upper middle screen) and edit the Input example to make it invalid the click parse to see the error message and when clicking see that both grammar/input editor show the the offending rule/input.
Trying to develop/debug grammars using the playground would be easier if when there is an error in the input/source and we click the error message it also jumped to the definition/rule in the grammar.
If the parser knows the rule that failed somehow this info could be encoded in the error message to allow jump to it.
Attached is a grammar and input file that actually gives this error message on input:
It seems clear that the failing rule is known due to the
expecting
list provided, so if that rule could also be shown on the grammar editor when clicking the error message that would be nice.Maybe something like this pseudo code:
jancy.peg.zip
The text was updated successfully, but these errors were encountered: