Skip to content
0:00 / 0:00

#lexer#interpreter#python

Make YOUR OWN Programming Language - EP 1 - Lexer

CodePulse

46K subscribers • 1 video on Hallway

YouTube

Beginner. No background in the topic needed.

563K views7 years ago2 recommendations

Programming languagesComputer sciencePythonCompilers and interpreters

This tutorial demonstrates how to build a basic lexer in Python to tokenize input for a custom programming language.

Hello and welcome to the first episode on how to create your VERY OWN programming language in Python. We will be using Python3 in this series, but feel free to follow along with any other language. The language that we will be creating will be our own implementation of BASIC. In the first three videos we will be focusing on adding numbers and operators. After that we will expand our language to support the rest of the language features, such as strings, variables, if statements, for statements and functions. In this first episode we create the lexer, which breaks up our input into a list of what we call tokens. We can then use those tokens in the next video to further analyze the code. If you have any questions or problems, don't hesitate to leave a comment below! And don't forget to leave a like if you enjoy the video :) LINKS Python3 - python.org/downloads/ BASIC language - en.wikipedia.org/wiki/BASIC What is __repr__ - bit.do/eCm93 This series is loosely based on ruslanspivak.com/lsbasi-part1/ ALL CODE IS ON GITHUB github.com/davidcallanan/py-basicinterp bitchute channel: bitchute.com/CodePulse bitchute referral code: codepulse Uncle Bob Clean Architecture book: read.amazon.co.uk/kp/embed?asin=B075LRM681&preview=newtab&li… (affiliate link)

Why it's here

2 people recommend this

What people say. Recommended as a highly accessible video series for learning how to build an interpreter from scratch.

u/hecitehiin r/ProgrammingLanguages • Recommends

On “How to write a programming language?”

About resources, read Crafting Interpreters. Try the book, if you can follow him through both theory and code, you are ready otherwise learn about the stuff you don't know and continue. While I like the aforementioned more there's also this book. If you prefer video format check this playlist out.

u/lookmeatin r/ProgrammingLanguages • Recommends

On “Q: How does interpreted languages (e.g. Python) work?”

You'd be surprised, but you're pretty close to it, it's not a stupid way at all. That said you can probably speed it up a lot more and you'll struggle with some issues. TL;DR: Here's a good guide on how to do this, won't solve everything but should get you over the harder bump. This one is good because it shows you how most parts are made and how they work (and I strongly recommend you use them). After that video series you can look at something like this which is a guide using libraries that are pretty optimized and good at what they do, as a Lexer, Parser, etc. Generally the first step is to pass it through a tokenizer. Which converts the text into a list of tokens. Similar to how you…

u/Treechcerin r/C_Programming • Mentions

On “Dio: Small Programming language made in C version 0.1.0 release”

I've watch first 3 episodes or so from this YouTube series. I also used some other resources, like stack overflow or Wikipedia... Also, I've read first few pages from 'crafting interpreters' I think it's called. So most of the stuff I've made is probably bad because I "invented" them.