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 mode = optimazationMode == 'all';
const data = JSON.parse(Module.lint(grammarText, codeText, mode)); const data = JSON.parse(Module.lint(grammarText, codeText, mode));
const isValid = data.grammar.length === 0; if (data.grammar_valid) {
if (isValid) {
$grammarValidation.removeClass('editor-validation-invalid').text('Valid').show(); $grammarValidation.removeClass('editor-validation-invalid').text('Valid').show();
codeAst.insert(data.ast); codeAst.insert(data.ast);
codeAstOptimized.insert(data.astOptimized); codeAstOptimized.insert(data.astOptimized);
$codeValidation.removeClass('editor-validation-invalid').text('Valid').show(); $codeValidation.removeClass('editor-validation-invalid').text('Valid').show();
const isValid = data.code.length === 0; if (data.code.length > 0) {
if (!isValid) {
const html = generateErrorListHTML(data.code); const html = generateErrorListHTML(data.code);
$codeInfo.html(html); $codeInfo.html(html);
$codeValidation.addClass('editor-validation-invalid').text('Invalid').show(); $codeValidation.addClass('editor-validation-invalid').text('Invalid').show();
} }
} else { } else {
$grammarValidation.addClass('editor-validation-invalid').text('Invalid').show();
}
if (data.grammar.length > 0) {
const html = generateErrorListHTML(data.grammar); const html = generateErrorListHTML(data.grammar);
$grammarInfo.html(html); $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; std::string json;
json += "{"; json += "{";
json += "\"grammar\":" + grammarResult; json += std::string("\"grammar_valid\":") + (ret ? "true" : "false");
json += ",\"grammar\":" + grammarResult;
if (!codeResult.empty()) { if (!codeResult.empty()) {
json += ",\"code\":" + codeResult; json += ",\"code\":" + codeResult;
json += ",\"ast\":\"" + astResult + "\""; json += ",\"ast\":\"" + astResult + "\"";

File diff suppressed because one or more lines are too long

Binary file not shown.