@@ -68,7 +68,7 @@ The benchmark always runs under release-fast.
6868Add zigfsm as a [ Zig package] ( https://ziglearn.org/chapter-3 ) in your build file, or simply import it directly after vendoring/adding a submodule:
6969
7070``` zig
71- const fsm = @import("zigfsm/main.zig");
71+ const zigfsm = @import("zigfsm/main.zig");
7272```
7373
7474### Creating a state machine type
@@ -80,13 +80,13 @@ Here we create an FSM for a button that can be clicked to flip between on and of
8080``` zig
8181const State = enum { on, off };
8282const Event = enum { click };
83- const FSM = fsm .StateMachine(State, Event, .off);
83+ const FSM = zigfsm .StateMachine(State, Event, .off);
8484```
8585
8686If you don't need events, simply pass null:
8787
8888``` zig
89- const FSM = fsm .StateMachine(State, null, .off);
89+ const FSM = zigfsm .StateMachine(State, null, .off);
9090```
9191
9292### Making an instance
@@ -96,16 +96,16 @@ Now that we have a state machine *type*, let's create an instance with an initia
9696var fsm = FSM.init();
9797```
9898
99- If you don't need to reference the state machine type, you can define the type and get an instance in one statement :
99+ If you don't need to reference the state machine type, you can define the type and get an instance like this :
100100
101101``` zig
102- var fsm = FSM .StateMachine(State, Event, .off).init();
102+ var fsm = zigfsm .StateMachine(State, Event, .off).init();
103103```
104104
105105You can also pass anonymous state/event enums:
106106
107107``` zig
108- var fsm = FSM .StateMachine(enum { on, off }, enum { click }, .off).init();
108+ var fsm = zigfsm .StateMachine(enum { on, off }, enum { click }, .off).init();
109109```
110110
111111### Adding state transitions
@@ -152,7 +152,7 @@ const definition = [_]Transition(State, Event){
152152 .{ .event = .click, .from = .on, .to = .off },
153153 .{ .event = .click, .from = .off, .to = .on },
154154};
155- var fsm = StateMachineFromTable(State, Event, &definition, .off, &.{}).init();
155+ var fsm = zigfsm. StateMachineFromTable(State, Event, &definition, .off, &.{}).init();
156156```
157157
158158Note that the ` .event ` field is optional, in which case only transition validation is added.
0 commit comments