Python List Comprehension for Better Error Reporting in My Language — Porth Ep.02

preview_player
Показать описание
References:

Support:

Feel free to use this video to make highlights and upload them to YouTube (also please put the link to this channel in the description)
Рекомендации по теме
Комментарии
Автор

Im only on episode 2 but i love the programming language creation series. You earned my sub!

Dman
Автор

24:12 i like how he worked with C for so long that he automatically calling things like that dangerous

flleaf
Автор

Regex matching in python returns the start and end index of the match. So that might could be helpful here.

friendlygrass
Автор

I know I'm late and that this language is pretty advanced already, but for those who are late like me, just know that lexing should'n've been that complicated. The snipped below should accomplish the same.

def lexline(line):
x = []
for token in line.split():
col = line.index(token)
x.append((col, token))
return x

def lex(filename):
with open(filename, "r") as f:
return [(filename, str(row + 1), str(col + 1), token)
for row, line in enumerate(f.readlines())
for col, token in lexline(line)]

lencone
Автор

At some point, you will run out of possible combinations of available integer values to sum to 420 or 69

alexandersnow
Автор

I'm now writing my compiler for the programming language I designed back when I was in high school(I'm mostly 19...), I'm writing it in Python, I could have used C or Rust or even C++ but I prefer to use Python.

YannBOYERDev
Автор

Watching you after a long while, boy have you lost some weight.

neonblood
Автор

Брат, ты топовый! Сделай пожалуйста пару уроков на питоне для таких тупых как я! На английском ваще классно, так даже понятней 👍👍👍

MuravaDnevnik
Автор

What happens when I put "34 35 36 + ." In source file, will it sum up the things?

Maik.iptoux
Автор

Hey Tsoding, what keyboard do you use?

pizzapanni
Автор

I wish porth was written in C instead of python

andy_lamax
Автор

26:57 what i would do here is change the first argument into a function. then you can do various things (where some . methods are surrounded by underscores): ' '.eq - this is the method which, when you call it on something, tells you whether ' ' is equal to it. Another function: str.iswhitespace - this, when you call it on a string, returns true for whitespace. by abstracting the function in this way, to take a function as an argument, you can also repurpose the function for other things, like taking integers (str.isdigit or '0123456789'.contains), or taking arbitrary clusters of chars (yourchars.contains)

MrRyanroberson