Description
Modify the Interpreter to be able to run programs with Custom Commands.
Rename the existing Program
type to CommandSequence
and add a new Project
type that includes Custom Commands:
export type CommandSequence = Array<string>;
export type Project = {
customCommands: {
[command: string]: CommandSequence
},
program: CommandSequence
};
Example project:
{
customCommands: {
square: ["forward", "left", "forward", "left", "forward", "left", "forward"]
},
program: ["square", "square"]
}
Test cases:
- Project with empty
program
and emptycustomCommands
- Project with
program
command sequence but nocustomCommands
- Project with
program
andcustomCommands
- Program with undefined commands (no registered command handlers or custom commands)
- Redefinition of built-in commands (command handlers)
- Recursion
See the discussion of command redefinition and recursion at https://wiki.fluidproject.org/display/C2LC/Custom+Blocks
We should also rename our existing editors to CommandSequence...Editor
rather than Program...Editor
as they operate on command sequences in our new model.
Comments
-
Daniel Cho commented
2019-11-05T10:08:11.486-0500 We need to think about how we are going to store custom commands – maybe web storage API if we are planning to store them locally, and I think it is valuable approach to make them sharable to other people too.
-
Simon Bates commented
2019-11-05T10:32:16.085-0500 Yeah, we’ll definitely want to support persistence of custom commands and programs. I think we can tackle that a little later, when our program/project model is more evolved. In the overall project plan, we’ve got persistence scheduled for the next milestone: milestone 3 January-June 2020.
-
Daniel Cho commented
2019-11-05T10:37:28.461-0500 Yeah, I realized that I was thinking way ahead as well. That sounds great 👍