|
|
@@ -11,14 +11,21 @@
|
|
|
if (typeof msg === "number") msg = "ERR" + msg + ": " + errors[msg];
|
|
|
if (suffix) msg += suffix;
|
|
|
return new SyntaxError(msg,
|
|
|
- opts.expected,
|
|
|
- opts.found,
|
|
|
+ opts.expected || null,
|
|
|
+ opts.found || null,
|
|
|
offset(),
|
|
|
opts.line || line(),
|
|
|
opts.col || column()
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+ var errors = [
|
|
|
+ "reference to an undefined system",
|
|
|
+ "reference to system in a behavior",
|
|
|
+ "scope lower bound exceeds its upper bound",
|
|
|
+ "definition is recursive"
|
|
|
+ ];
|
|
|
+
|
|
|
var scopify = function scopify(i, q) {
|
|
|
if (q === null) q = {min:1, max:1};
|
|
|
i.scope = q;
|
|
|
@@ -83,26 +90,27 @@
|
|
|
for (var i in model.interactions) {
|
|
|
model.interactions[i].body.forEach(function (sys) {
|
|
|
if (sys.type === "Selector" && !model.systems[sys.system])
|
|
|
- model.errors.push(err("ERROR: reference to an undefined system (" + sys.system + ")", null, sys.location));
|
|
|
+ model.errors.push(err(0, ` (${sys.system})`, sys.location));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
for (var t in model.triggers) {
|
|
|
var sys = model.triggers[t].on;
|
|
|
if (sys.type === "Selector" && !model.systems[sys.system])
|
|
|
- model.errors.push(err("ERROR: reference to an undefined system (" + sys.system + ")", null, sys.location));
|
|
|
+ model.errors.push(err(0, ` (${sys.system})`, sys.location));
|
|
|
}
|
|
|
|
|
|
for (var i in model.init) {
|
|
|
var sys = model.init[i].system;
|
|
|
if (sys && !model.systems[sys])
|
|
|
- model.errors.push(err("ERROR: reference to an undefined system (" + sys + ")", null, model.init[i].location));
|
|
|
+ model.errors.push(err(0, ` (${sys})`, model.init[i].location));
|
|
|
}
|
|
|
|
|
|
for (var b in model.behaviors) {
|
|
|
- model.behaviors[b].refs.forEach(function (ref) {
|
|
|
+ var bhv = model.behaviors[b];
|
|
|
+ bhv.refs.forEach(function (ref) {
|
|
|
if (model.systems[ref])
|
|
|
- model.errors.push(err("ERROR: reference to system (" + ref + ") in a behavior (" + model.behaviors[b].id + ")", null, model.behaviors[b].location));
|
|
|
+ model.errors.push(err(1, ` (${ref} in ${bhv.id})`, bhv.location));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -265,7 +273,7 @@ alternation
|
|
|
var body = [head].concat(tail);
|
|
|
for (var i = 0; i < body.length; i++) {
|
|
|
if (body[i].scope.max && body[i].scope.min > body[i].scope.max)
|
|
|
- ast.errors.push(err("ERROR: Scope (" + body[i].id + ") lower bound exceeds its upper bound"));
|
|
|
+ ast.errors.push(err(2,` (${body[i].id})`));
|
|
|
}
|
|
|
return new ast.Alternation(body);
|
|
|
}
|
|
|
@@ -275,7 +283,7 @@ sequence
|
|
|
{
|
|
|
for (var i = 0; i < body.length; i++) {
|
|
|
if (body[i].scope.max && body[i].scope.min > body[i].scope.max)
|
|
|
- ast.errors.push(err("ERROR: Scope (" + body[i].id + ") lower bound exceeds its upper bound"));
|
|
|
+ ast.errors.push(err(2,` (${body[i].id})`));
|
|
|
}
|
|
|
return new ast.Sequence(body);
|
|
|
}
|
|
|
@@ -319,7 +327,7 @@ event_ref = id:ID
|
|
|
{
|
|
|
if (!ast.selector) {
|
|
|
if (id === ast.toplevelname) {
|
|
|
- ast.errors.push(err("ERROR: Definition is recursive (" + id + ")"));
|
|
|
+ ast.errors.push(err(3, ` (${id})`));
|
|
|
ast.toplevelname = null;
|
|
|
} else ast.references.push(id);
|
|
|
}
|