Simple Math Interpreter in Python (1/4) - Lexer

preview_player
Показать описание
In this short series, we are going to be writing a simple interpreter in Python that can understand and process basic math calculations.

This is useful to learn how to write a program that can understand a human-readable format, and this knowledge can be expanded to creating your own data language, programming language, etc.

In the first 3 episodes of this series we will write the lexer, the parser and the interpreter. Those are the fundamental steps to writing any interpreter.

In the final episode (optional), we will add unit testing to our language, so that we can guarantee everything is still working if we make changes in the future.

If you enjoy the video, don't forget to leave a like! And subscribe so you don't any of my future videos.

Special thanks to my top Patreon supporter: Helge Sverre Hessevik Liseth
Рекомендации по теме
Комментарии
Автор

This was the most FUN tutorial I ever followed. Explanation was great and code ran with no errors first time! Its definitely not a beginner tutorial. Thanks for amazing video!

voil
Автор

If a second decimal point is detected, it should raise an error, otherwise "2.2." will return [Number:2.2, Number:0.0]


Thank you for the great videos though! Implementing this in Java was pretty easy so far.

minutes
Автор

Great vedio I think it's much better than the earlier vedios of this series

himanshusrivastava
Автор

Thanks for the update about interpreter with python. This video is less complicated than 2-3 years python interpreter video.

tictactoc
Автор

This video was very helpful! I watched through the intro and I was like ok, i'll try it. Then I came back with a working lexer! :D

eboatwright_
Автор

Could you please do a series on how one would create an interpreter for set theory? In set theory there are more complex syntax because of the collections like: { 1, 2, 3} representing one set.

divanvanzyl
Автор

i started programming in python then move to C then move to haskell and i did this in haskell, now i am watching this cos i forgot python

javierivantorres
Автор

4:58
The generic "any" function in python has nothing to do with types. It's a function that returns true if any elements of its (iterable) argument are truthy.

cycrothelargeplanet
Автор

Structural pattern matching with the match case they introduced in Python 3.10 will make building compilers much easier
Also, is there any reason compilers can't have autocorrect built in to reduce syntax errors?

RobinPageGaming
Автор

Could this lexer be used the same way as the basic lexer you made? (what i am kinda asking is this just a updated version in a way?)

lemonglataitor
Автор

do i need to learn python to make this series, or

yousefmohammed
Автор

Please don’t just pasting in a bunch of code make the video simply longer ‘cause if you do this it’s annoying to pause the video to type it

alexanderthorbrugge
Автор

I have a question. If I want to use the dot token in other use in the language like range selection. Then how do I recognize int vs floating number.

sukivirus
Автор

I am having an error it says Lexer has no attribute current_char


Please help

DivyanshuLohani
Автор

Not working :(

Error:

Traceback (most recent call last):

print(list(tokens))
, line 17, in generate_tokens
while self.current_char != None:

NameError: name 'self' is not defined

kotodobryt
join shbcf.ru