show execution history
This commit is contained in:
parent
a8b522fdd8
commit
d5272e30f3
6 changed files with 90 additions and 42 deletions
|
|
@ -59,8 +59,10 @@ text.highlight {
|
|||
stroke: rgb(230,0,0);
|
||||
}
|
||||
.rountangle.active {
|
||||
fill: rgb(255, 196, 0);
|
||||
fill: darkorange;
|
||||
fill-opacity: 0.2;
|
||||
/* filter: drop-shadow( 3px 3px 2px rgba(0, 0, 0, .7)); */
|
||||
stroke-width: 3px;
|
||||
}
|
||||
|
||||
.selected:hover {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { act } from "react";
|
||||
import { evalExpr } from "./actionlang_interpreter";
|
||||
import { computeArena, ConcreteState, getDescendants, isAncestorOf, isOverlapping, OrState, Statechart, stateDescription, Transition } from "./ast";
|
||||
import { Action } from "./label_ast";
|
||||
|
|
@ -209,13 +208,24 @@ export function handleEvent(event: string, statechart: Statechart, activeParent:
|
|||
return {environment, mode, ...raised};
|
||||
}
|
||||
|
||||
export function handleInputEvent(event: string, statechart: Statechart, rt: RT_Statechart): RT_Statechart {
|
||||
let {mode, environment, internalEvents, outputEvents} = handleEvent(event, statechart, statechart.root, rt);
|
||||
|
||||
while (internalEvents.length > 0) {
|
||||
const [event, ...rest] = internalEvents;
|
||||
({mode, environment, internalEvents, outputEvents} = handleEvent(event, statechart, statechart.root, {mode, environment, internalEvents: rest, outputEvents}));
|
||||
}
|
||||
|
||||
return {mode, environment, internalEvents, outputEvents};
|
||||
}
|
||||
|
||||
function transitionDescription(t: Transition) {
|
||||
return stateDescription(t.src) + ' ➔ ' + stateDescription(t.tgt);
|
||||
}
|
||||
|
||||
export function fireTransition(t: Transition, arena: OrState, srcPath: ConcreteState[], tgtPath: ConcreteState[], {mode, environment, ...raised}: RT_Statechart): {mode: Mode, environment: Environment} & RaisedEvents {
|
||||
export function fireTransition(t: Transition, arena: OrState, srcPath: ConcreteState[], tgtPath: ConcreteState[], {mode, environment, ...raised}: RT_Statechart): RT_Statechart {
|
||||
|
||||
console.log('fire ', transitionDescription(t), {arena, srcPath, tgtPath});
|
||||
// console.log('fire ', transitionDescription(t), {arena, srcPath, tgtPath});
|
||||
|
||||
// exit src
|
||||
({environment, ...raised} = exitPath(srcPath.slice(1), {environment, enteredStates: mode, ...raised}));
|
||||
|
|
@ -223,7 +233,7 @@ export function fireTransition(t: Transition, arena: OrState, srcPath: ConcreteS
|
|||
toExit.delete(arena.uid); // do not exit the arena itself
|
||||
const exitedMode = mode.difference(toExit);
|
||||
|
||||
console.log('exitedMode', exitedMode);
|
||||
// console.log('exitedMode', exitedMode);
|
||||
|
||||
// exec transition actions
|
||||
for (const action of t.label[0].actions) {
|
||||
|
|
@ -235,7 +245,7 @@ export function fireTransition(t: Transition, arena: OrState, srcPath: ConcreteS
|
|||
({enteredStates, environment, ...raised} = enterPath(tgtPath.slice(1), {environment, ...raised}));
|
||||
const enteredMode = exitedMode.union(enteredStates);
|
||||
|
||||
console.log('enteredMode', enteredMode);
|
||||
// console.log('enteredMode', enteredMode);
|
||||
|
||||
return {mode: enteredMode, environment, ...raised};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ function peg$parse(input, options) {
|
|||
const peg$c19 = "//";
|
||||
const peg$c20 = "\n";
|
||||
|
||||
const peg$r0 = /^[a-zA-Z0-9]/;
|
||||
const peg$r0 = /^[0-9A-Z_a-z]/;
|
||||
const peg$r1 = /^[0-9]/;
|
||||
const peg$r2 = /^[<>]/;
|
||||
const peg$r3 = /^[+\-]/;
|
||||
|
|
@ -203,7 +203,7 @@ function peg$parse(input, options) {
|
|||
const peg$e7 = peg$literalExpectation("s", false);
|
||||
const peg$e8 = peg$literalExpectation(";", false);
|
||||
const peg$e9 = peg$literalExpectation("=", false);
|
||||
const peg$e10 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false, false);
|
||||
const peg$e10 = peg$classExpectation([["0", "9"], ["A", "Z"], "_", ["a", "z"]], false, false, false);
|
||||
const peg$e11 = peg$classExpectation([["0", "9"]], false, false, false);
|
||||
const peg$e12 = peg$literalExpectation("==", false);
|
||||
const peg$e13 = peg$literalExpectation("!=", false);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ assignment = lhs:identifier _ "=" _ rhs:expr {
|
|||
return {kind: "assignment", lhs, rhs};
|
||||
}
|
||||
|
||||
identifier = [a-zA-Z0-9]+ {
|
||||
identifier = ("_" / [a-zA-Z0-9])+ {
|
||||
return text();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue