Share your repls and programming experiences

← Back to all posts
A Lexer
DynamicSquid (4622)

So I'm making a programming language and the first step is the lexer I think. So here's my lexer. It's not the best, and I'll probably scrap this and make a better one, but I just started out and don't really know what I'm doing.

For the input, just enter a variable initialization like this:

// it only supports these three types right now

int answer = 10;
bool lightSwitch = false;
char letter = 's';

I'm still working in the parser though.

ChezCoder (1588)

noice! i recommend regex for lexing the tokens

DynamicSquid (4622)

@ChezCoder oh yeah, I used regex for the numbers, but I guess I could also use it for the others as well

ChezCoder (1588)

@DynamicSquid can i help you with your language?

DynamicSquid (4622)

@ChezCoder oh yeah sure! that'd be awesome! want me to invite you to the repl?