A good place to start would be the interpreters for various esoteric programming languages. They're typically simpler than those for conventional ones, not least because they're purposely constrained in some way, either because they focus on some particular method of computational (Thue, Unlambda, SMETANA, &c., are good examples of this) or super minimalist (Unlambda, FALSE, Malbolge, &c., are good examples). Implementation strategies can vary from simply walking an abstract syntax tree generated from the parser output (Ruby did this for a long time) to generating bytecode for a simple custom VM. All that is actually really easy. Where it gets awkward is when you get down to things like optimisation: that's a real black art! It doesn't take much code to implement a Pascal compiler or interpreter as it's designed to be easy to parse, so building an interpreter for a cut down version of that would be a good exercise.
I went through this line by line and re-wrote it locally in my language of choice, and it worked! I have to say, I've followed quite a few tutorials but none have been as magic as this one. I must warn people going through this in the future that he reminded us that he is building things in a simplified way, thus avoid OOP and other heavier utilizations. Thus, it is a little hard to follow as everything is one big jumbled implementation as opposed to it being broken up into SRP components. Amazing though nonetheless, I had a great time re-writing it locally to be in OOP as well :)
Thanks for another great video. It's a great introduction to people who think that writing interpreters and compilers is magic when it isn't all that hard to make a simple one. I learned this in my CS Degree in the Mid 80's and is called a recursive descent parser. There are other ways of doing it but this is probably the easiest. One small bug in your interpreter is that you can't have a # in a string literal e.g. "Hello # world" but it is easy to fix.
I think a stripped down Python would be interesting. BASIC is very very common on those kind of microcomputers, and a small subset of C has already been done. I would go for something Python-like just because it would be more original! Also, in the future it would be very very cool to build a compiler for the language, which outputs native assembly (if static typing is needed, the Python syntax for type annotations is also easier to parse than the C one!)
There is already a FORTH running on the Minimal. See the Minimal Forum for more info: minimal-cpu-system.boards.net/ It is being developed by a guy named slowcorners.
Ich bin froh dich entdeckt zu haben, super content. Ich bin auf der suche nach der Antwort auf die Frage, wie Computer überhaupt Programmiersprachen verstehen oder wie man eben von Anfang ein Computer bastelt, sodass etwas entsteht dass nach und nach Programmiersprachen versteht. Ich frag mich immer welche Vorüberlegung voran gehen muss, sodass dieses Zusammenspiel zwischen Hardware und software anfangs funktioniert und das überhaupt der weg geebnet werden kann bis da sowas wie ein compiler entsteht etc.
6:30 - I'd recommend replacing 'act' with a small class that just contains a single field, and I'd call this 'State'. Why? Because it's less clumsy than passing around the one-element list and it leaves room for doing basic scope management, as it'll later give you somewhere to keep the interpreted program's globals and local variables for the currently executing subroutine. It's easy to do and really helps with complexity management. This is essentially what Lua's interpreter does, and it makes sense even with toy interpreters.
Thanks, Keith, yes, you are right - some sort of 'state' can also do the trick and also allows to manage different reasons for a "bailout". I'd rather not use OOP here, since as I said, this piece has to be converted to very limited assembly very soon. Cheers!
I'm thinking: you could change the backend of Min to produce assembly code directly. So instead of calling the "do.."-functions, write and call the "emit..."-functions which then emit/produce assembly code. And since you already have written an assembler, this would close the cycle. What do you think about it?
what is a Main loop in MIN ? Is that func Program() with While loop where is while Next() != '\0': Block(act) and you wrote in video this ; while Look() != \0 ....so what is not Look() or Take() ..then u use Next() as endless loop? i am confused !
thanks slu4 ...it is really interesting to see source code , very cool and easy to understand even i am not python programmer at all ... just to ask ...functions as such seems that are implemented because you have test code ------------------------------------- def add_this(a, b, &c) r = a + b + c return r x = 100 print add_this(1, 10, x) .----------------------------------- which looks to me like function..do i have right ? also which python version i need , i have Portable py 3 i think all best
Hi slu4 ..it is me again...sorry if i bothering you i find int.py code and i load it into PyScripter - Portable_Python 3251 code is executed and after RUN i get this: ................................................................................. USAGE: int.py Exit code: 1 ................................................................................. so my question is : what i need to do to run your example demo.txt or test.txt ? thanks in advance