mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Fix #170
This commit is contained in:
parent
3fb33f552a
commit
02d009777c
@ -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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
BIN
docs/native.wasm
BIN
docs/native.wasm
Binary file not shown.
Loading…
Reference in New Issue
Block a user