Skip to content

Conversation

felipe-bonato
Copy link
Contributor

@felipe-bonato felipe-bonato commented Feb 2, 2025

Lexer is a classical example of usecase for coroutines.

This is a very simple and basic lexer that can lex single digit integers, "+" and "-".
Like these:

1+1
9-5+3

The example would be better if we could return values when we yield (kind of like a generator).
But it is what it is.

@rexim
Copy link
Member

rexim commented Feb 2, 2025

@felipe-bonato oh, that's actually super cool! Thank you! I'll think about returning values from yield in the meantime.

@rexim rexim merged commit c8ede46 into tsoding:main Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants