different attempt to parse using collapsable text

ranges
This commit is contained in:
Dave Holoway
2020-05-23 13:20:51 +01:00
parent bdc5b1d4cd
commit 23dc6d3871
18 changed files with 1904 additions and 345 deletions

View File

@@ -0,0 +1,29 @@
const { ModuleBlock, TypeDeclBlock, MethodBlock } = require('../parser9');
const ParseProblem = require('../parsetypes/parse-problem');
/**
* @param {TypeDeclBlock} type
* @param {ParseProblem[]} probs
*/
function checkTypeParseErrors(type, probs) {
type.parseErrors.forEach(err => probs.push(ParseProblem.Error(err, `Invalid, incomplete or unsupported declaration`)));
type.methods.filter(m => m.parseErrors).forEach(m => checkMethodParseErrors(m, probs));
type.types.forEach(type => checkTypeParseErrors(type, probs));
}
/**
* @param {MethodBlock} method
* @param {ParseProblem[]} probs
*/
function checkMethodParseErrors(method, probs) {
method.parseErrors.forEach(err => probs.push(ParseProblem.Error(err, `Invalid, incomplete or unsupported declaration`)));
}
/**
* @param {ModuleBlock} mod
*/
module.exports = function(mod) {
const probs = [];
mod.types.forEach(type => checkTypeParseErrors(type, probs));
return probs;
}