Commits

Anonymous committed 63c77d1

Handle `caused by` events that are defined elsewhere in the source.

  • Participants
  • Parent commits 82e41d2

Comments (0)

Files changed (3)

File eg/alarm4.bj

-// Description #4 of a burglar alarm in 2Iota (v2.0 only.)
+// Description #4 of a burglar alarm in beta-Juliet (v2.0 only.)
 
 // This is an alternate version of description #3, where the events have
 // multi-symbol names, and which does not use any "caused after" clauses.

File eg/alarm5.bj

+// Description #5 of a burglar alarm in beta-Juliet (v2.0 only.)
+
+// Mainly to check that we can have an event that both causes
+// another event and is caused by yet another event.
+// (In this case, "Window Switch is Broken".)
+
+event Window Switch is Broken,
+        causes Warning Light Lit;
+
+event Window Switch is,
+        causes No That Is Wrong;
+
+event Window Switch is Broken Something,
+        causes No That Is Wrong;
+
+event Alarm,
+        caused by Window Switch is Broken,
+        causes Alarm.
 		int match = 0;
 
 		for (e = etab->head; e != NULL; e = e->next) {
-			/* TODO: */
-			/* if c->cause matches e->name, */
-			/* add a consequence from e to */
-			/* to c->effect */
+			if (symstr_is_literal(e->name) &&
+			    symstr_eq(c->cause, e->name)) {
+				event_consequence_append(e,
+				    c->effect->name, &etime_zero);
+				match = 1;
+				break;
+			}
 		}
 
 		if (!match) {