mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
FIxed problems with error recovery
This commit is contained in:
parent
8dc6a287f8
commit
0d005fb3da
@ -86,12 +86,13 @@ function parse() {
|
||||
if (isValid) {
|
||||
$grammarValidation.removeClass('editor-validation-invalid').text('Valid').show();
|
||||
|
||||
const isValid = data.code.length === 0;
|
||||
if (isValid) {
|
||||
codeAst.insert(data.ast);
|
||||
codeAstOptimized.insert(data.astOptimized);
|
||||
$codeValidation.removeClass('editor-validation-invalid').text('Valid').show();
|
||||
} else {
|
||||
|
||||
const isValid = data.code.length === 0;
|
||||
|
||||
if (!isValid) {
|
||||
const html = generateErrorListHTML(data.code);
|
||||
$codeInfo.html(html);
|
||||
$codeValidation.addClass('editor-validation-invalid').text('Invalid').show();
|
||||
|
@ -43,7 +43,7 @@ bool parse_grammar(const std::string &text, peg::parser &peg,
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool parse_code(const std::string &text, peg::parser &peg, std::string &json,
|
||||
void parse_code(const std::string &text, peg::parser &peg, std::string &json,
|
||||
std::shared_ptr<peg::Ast> &ast) {
|
||||
peg.enable_ast();
|
||||
bool init;
|
||||
@ -51,7 +51,6 @@ bool parse_code(const std::string &text, peg::parser &peg, std::string &json,
|
||||
json += "[";
|
||||
auto ret = peg.parse_n(text.data(), text.size(), ast);
|
||||
json += "]";
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline std::vector<std::string> splitRulesText(const std::string &s) {
|
||||
@ -78,7 +77,8 @@ std::string lint(const std::string &grammarText, const std::string &codeText,
|
||||
|
||||
if (ret && peg) {
|
||||
std::shared_ptr<peg::Ast> ast;
|
||||
if (parse_code(codeText, peg, codeResult, ast)) {
|
||||
parse_code(codeText, peg, codeResult, ast);
|
||||
if (ast) {
|
||||
astResult = escape_json(peg::ast_to_s(ast));
|
||||
auto rules = splitRulesText(opt_rules_text);
|
||||
astResultOptimized = escape_json(
|
||||
|
BIN
docs/native.wasm
BIN
docs/native.wasm
Binary file not shown.
Loading…
Reference in New Issue
Block a user