add transition label parser

This commit is contained in:
Joeri Exelmans 2025-10-06 15:10:55 +02:00
parent 58a75ddd8b
commit e009f718d2
8 changed files with 1399 additions and 74 deletions

View file

@ -0,0 +1,53 @@
export type TransitionLabel = {
trigger: Trigger;
guard: Expression;
actions: Action[];
}
export type Trigger = EventTrigger | AfterTrigger;
export type EventTrigger = {
kind: "event";
event: string;
}
export type AfterTrigger = {
kind: "after";
durationMs: number;
}
export type Action = Assignment | RaiseEvent;
export type Assignment = {
kind: "assignment";
lhs: string;
rhs: Expression;
}
export type RaiseEvent = {
kind: "raise";
event: string;
}
export type Expression = BinaryExpression | UnaryExpression | VarRef;
export type BinaryExpression = {
kind: "binaryExpr";
operator: "+" | "-" | "*" | "/" | "&&" | "||";
lhs: Expression;
rhs: Expression;
}
export type UnaryExpression = {
kind: "unaryExpr";
operator: "!" | "-";
expr: Expression;
}
export type VarRef = {
kind: "ref";
variable: string;
}