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