3 ms·
A fun project! I had a buddy tried this, wrote it in C++ over a week. Had console, graphics, formatting and networking (I think). The trick was first a parser,
by JoeAltmaier 8y ago
A fun project! I had a buddy tried this, wrote it in C++ over a week. Had console, graphics, formatting and networking (I think).
The trick was first a parser, then use C++ objects for each construct and instantiate one for each parsed element. The objects had a 'list' and a 'run' method. They were linked in programmatic order. So run the first one, which returns the next one to run (since it may vary with IF, GOTO etc)
Here it is!
http://www.moondew.com/basic/ http://www.moondew.com/basic/
- marktangotango 8y agoSounds like interpreting from an instance of the AST. Pretty easy but there are gotchas; like handling break/continue in loops. It’s an interesting excercise everyone ought to try IMO.