add transition label parser
This commit is contained in:
parent
58a75ddd8b
commit
e009f718d2
8 changed files with 1399 additions and 74 deletions
53
src/VisualEditor/label_ast.ts
Normal file
53
src/VisualEditor/label_ast.ts
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue