This answer isn't going to give you the code to solve your problem, it is just ideas that you can look at and see what suits you best.
You should be able to find an example on how to read from a serial connection, I'm sure there is at least one example in the IDE.
You need to work out how to encode your data, having it in nice human friendly format (like you have above) is great if you are processing it on a PC but on a processor that is slow and have very limited memory using A,B,C... as the function names might be more practical. It will be smaller to store and quicker to compare.
You want to store the input so it can be read back later. There are a number of ways you can do this but they all need a non-volatile storage medium. You could use an SD card, obviously you'd need an SD reader and the type of reader you get will affect the code you need, but these can be problematic. You can also use EEPROM chips that, you can get little I2C interfaced modules, they have less space than an SD card, but are generally faster (they also have a shorter lifespan, but don't worry I don't you'll ware one out). You can also use the EEPROM that is in the Arduino itself (I've never done this).
It is best to build you program up in small parts, get the reading from serial working, then calling functions, then saving and loading. That way you only have to debug a small bunch of issues at once. If you wanted you could abstract the storage device away from the code by writing a base class that has virtual save and load functions. You could then inherit from this class for the EEPROM or the SD card and changing wouldn't affect the rest of the code.
Like I said at the start I appreciate this answer hasn't given you a step by step guide on how to solve your problem, but hopefully it has given you a few pointers on what you could do and you can research the options from there. Remember when you get stuck on one particular aspect just post a minimal example of what you have tried and explain what you expect it to be doing and people will be more than willing to help.