This commit is contained in:
yhirose 2021-04-13 11:10:52 -04:00
parent 3fb33f552a
commit 02d009777c
4 changed files with 9 additions and 8 deletions

View File

@ -79,25 +79,25 @@ function parse() {
const mode = optimazationMode == 'all';
const data = JSON.parse(Module.lint(grammarText, codeText, mode));
const isValid = data.grammar.length === 0;
if (isValid) {
if (data.grammar_valid) {
$grammarValidation.removeClass('editor-validation-invalid').text('Valid').show();
codeAst.insert(data.ast);
codeAstOptimized.insert(data.astOptimized);
$codeValidation.removeClass('editor-validation-invalid').text('Valid').show();
const isValid = data.code.length === 0;
if (!isValid) {
if (data.code.length > 0) {
const html = generateErrorListHTML(data.code);
$codeInfo.html(html);
$codeValidation.addClass('editor-validation-invalid').text('Invalid').show();
}
} else {
$grammarValidation.addClass('editor-validation-invalid').text('Invalid').show();
}
if (data.grammar.length > 0) {
const html = generateErrorListHTML(data.grammar);
$grammarInfo.html(html);
$grammarValidation.addClass('editor-validation-invalid').text('Invalid').show();
}
}

View File

@ -74,7 +74,8 @@ std::string lint(const std::string &grammarText, const std::string &codeText, bo
std::string json;
json += "{";
json += "\"grammar\":" + grammarResult;
json += std::string("\"grammar_valid\":") + (ret ? "true" : "false");
json += ",\"grammar\":" + grammarResult;
if (!codeResult.empty()) {
json += ",\"code\":" + codeResult;
json += ",\"ast\":\"" + astResult + "\"";

File diff suppressed because one or more lines are too long

Binary file not shown.