Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "match ... with ..." syntax #696

Merged
merged 7 commits into from
Jan 26, 2025
Merged

Add "match ... with ..." syntax #696

merged 7 commits into from
Jan 26, 2025

Conversation

Akuli
Copy link
Owner

@Akuli Akuli commented Jan 26, 2025

Fixes #617

Example:

match "hello" with strcmp:
    case "hello":
        printf("yass\n")

For now, the match function must return int, so you can't match with e.g. starts_with(). This might actually be a good thing, so that usage of match statement remains quite simple and it's not tempting to make things more complicated than needed.

compiler/ast.jou Outdated Show resolved Hide resolved
tests/should_succeed/match.jou Outdated Show resolved Hide resolved
tests/should_succeed/match.jou Show resolved Hide resolved
@Akuli Akuli merged commit b339b1b into main Jan 26, 2025
38 checks passed
@Akuli Akuli deleted the match-with branch January 26, 2025 16:23
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.

Match statement and strings
1 participant