Skip to content

Handle multi-line pattern matching expression#111

Open
adsharma wants to merge 2 commits intowe-like-parsers:mainfrom
adsharma:tokenize_pattern_match
Open

Handle multi-line pattern matching expression#111
adsharma wants to merge 2 commits intowe-like-parsers:mainfrom
adsharma:tokenize_pattern_match

Conversation

@adsharma
Copy link

@adsharma adsharma commented Apr 1, 2025

This is necessary to support an alternative python syntax.

# Proposed match_expr using the keyword pmatch
def test(num, num2):
    a = pmatch num:
        1: "One"
        2: "Two"
        3: pmatch num2:
           1: "One"
           2: "Two"
           3: "Three"
        _: "Number not between 1 and 3"
    return a

Details in the issue. Solution implemented handles it similar to how python's builtin tokenizer handles multi-line expressions involving parens.

Fixes #107

@0dminnimda
Copy link
Contributor

I'd be good to add the failing test in the test cases

@adsharma
Copy link
Author

adsharma commented Apr 1, 2025

@0dminnimda the test case fails before the changes and passes after.

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.

python.gram Rust/C++/Borgo compatible match syntax: parse without delimiters

2 participants