Let's Write an Interpreter (in 168 Lines of Python)

preview_player
Показать описание
I explain the inner workings of a computer language interpreter that features code blocks, error messages, comments, integer and string variables, math expressions, if-else, while-break, print, input, and subroutine calls. I build on the fantastic work by Jack W. Crenshaw. The interpreter only uses low-level Python.

"Let's Build a Compiler" by Jack W. Crenshaw:

Minimal UART CPU System on GitHub:

Minimal User Manual and Reference:
Рекомендации по теме
Комментарии
Автор

Always viewed interpreters as beig indistinguishable from magic, this video goes a long way to demystifying the methods. Thank you

stupossibleify
Автор

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 :)

StasPakhomov-wjnn
Автор

That's very neat indeed. I love the use of a /single/ dictionary for all kinds of identifiers. That's quite cool !

RelayComputer
Автор

This is a really good video! I'm currently making my own programming language called King in JavaScript, so this was very insightful :D

eboatwright_
Автор

Wow.. brilliantly explained! Thank you sir!

BryanChance
Автор

this complicated task was done so simply!

funwithalbi
Автор

Thank you for this very informative walkthough

jimbailey
Автор

heres the entire python interpreter rewritten in python in just 1 line
exec("code")

hamzacasdasdasd
Автор

Bro has a degree on writing unreadable python code.

fusn
Автор

Yes this is very informative and awesome, Slu4 Thanks. Tiny C would be nice to see. Cheers.

alessiocaffi
Автор

Lua could be a good candidate! Or maybe micro-Lua (whatever it is... hahaha!)

xyzzyx
Автор

Hm, you do not seem to be too good in following naming conventions :)

Borszczuk
Автор

you can just tell he intentionally formatted it terribly for the 168 lines title

hahayes
Автор

Ok ..where is code of this 168 lines of python code ..?

zlatkovidlanovic
Автор

Fusing your lexer/parser/evaluator is a terrible/unscalable way to write an interpreter.

halfsourlizard
join shbcf.ru