var stateMachine =
new StateMachine(
{
events: {
doorClosed : "D1CL",
drawOpened : "D2OP",
lightOn : "L1ON"
},
commands: {
unlockDoor : "D1UL",
lockPanel : "PNLK"
},
states: {
idle : {
actions : ["unlockDoor", "lockPanel"],
transitions: {
doorClosed : "active"
}
},
active: {
transitions: {
drawOpened : "waitingForLight",
lightOn: "waitingForDraw"
}
}
}
}
);
I know there is lots of red and I don't use => as is used in most of the examples, but I think I got it pretty good, and actually JavaScript is not that bad at all when it comes to internal DSLs. What do you think?
Oh, and I was just thinking, I bet I can do DSL in MPS that will have 0 (zero) syntactic noise! Keep tuned, I really might. That brings up another question: the example and the whole article is based on text based DSLs (blast, he was talking about internal DSLs, and I thought to be a smart a**) and what about graphical DSLs or Language Workbenches? As I said in some more advanced language oriented tools (MPS) we might use no syntactic nose without sacrificing any clarity. Text presented for clarification in this tools is part of the editor and is not there because of the syntax, you type in only significant data.
Comments