|
|
@@ -76,14 +76,14 @@
|
|
|
|
|
|
for (var i in model.interactions) {
|
|
|
model.interactions[i].body.forEach(function (sys) {
|
|
|
- if (!model.systems[sys.system])
|
|
|
+ if (sys.type === "Selector" && !model.systems[sys.system])
|
|
|
model.errors.push(err("ERROR: reference to an undefined system (" + sys.system + ")", null, sys.location));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- for (var i in model.triggers) {
|
|
|
- var sys = model.triggers[i].on;
|
|
|
- if (!model.systems[sys.system])
|
|
|
+ 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));
|
|
|
}
|
|
|
|
|
|
@@ -203,13 +203,13 @@ system_statement "System"
|
|
|
= _SYSTEM_ _COLON_ id:system_id
|
|
|
!{ ast.toplevelname = id; ast.localrefs = []; }
|
|
|
_EQ_ body:behavior_pattern
|
|
|
- { return new ast.System(id, [body], ast.localrefs); }
|
|
|
+ { return new ast.System(id, body, ast.localrefs); }
|
|
|
|
|
|
behavior_statement "Behavior"
|
|
|
= _BEHAVIOR_ _COLON_ id:behavior_id
|
|
|
!{ ast.toplevelname = id; ast.localrefs = []; }
|
|
|
_EQ_ body:behavior_pattern
|
|
|
- { return new ast.Behavior(id, [body], ast.localrefs); }
|
|
|
+ { return new ast.Behavior(id, body, ast.localrefs); }
|
|
|
|
|
|
interaction_statement "Interaction"
|
|
|
= _INTERACTION_ _COLON_ first:( system_item_selector / expression )
|
|
|
@@ -249,11 +249,10 @@ operator
|
|
|
/ _ o:"==" _ { return o; }
|
|
|
|
|
|
behavior_pattern "Behavior Pattern"
|
|
|
- = alternation
|
|
|
- / sequence
|
|
|
+ = (alternation / sequence)+
|
|
|
|
|
|
alternation
|
|
|
- = head:sequence tail:( _PIPE_ item:sequence { return item; } )+
|
|
|
+ = head:behavior_pattern_item tail:( _PIPE_ item:behavior_pattern_item { return item; } )+
|
|
|
{ return new ast.Alternation([head].concat(tail)); }
|
|
|
|
|
|
sequence
|
|
|
@@ -285,7 +284,7 @@ trigger "Trigger"
|
|
|
{ return new ast.Trigger(selector, body); }
|
|
|
|
|
|
embedded_code
|
|
|
- = [^{}]* _ ( "{" embedded_code "}")? _
|
|
|
+ = [^{}]* ( "{" embedded_code "}")? [^{}]*
|
|
|
{ return text().trim(); }
|
|
|
|
|
|
behavior_id = id:ID { return id; }
|
|
|
@@ -294,11 +293,11 @@ property = id:ID { return id; }
|
|
|
|
|
|
event_ref = id:ID
|
|
|
{
|
|
|
- if (id === ast.toplevelname) {
|
|
|
- ast.errors.push(err("ERROR: Definition is recursive (" + id + ")"));
|
|
|
- ast.toplevelname = null;
|
|
|
- } else if (!ast.selector) {
|
|
|
- ast.references.push(id);
|
|
|
+ if (!ast.selector) {
|
|
|
+ if (id === ast.toplevelname) {
|
|
|
+ ast.errors.push(err("ERROR: Definition is recursive (" + id + ")"));
|
|
|
+ ast.toplevelname = null;
|
|
|
+ } else ast.references.push(id);
|
|
|
}
|
|
|
return { type: "Behavior", id:id };
|
|
|
}
|