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

Simple pattern support + integer ranges #106

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

joennlae
Copy link
Contributor

@joennlae joennlae commented Dec 1, 2024

This PR introduces simple regex pattern support + integer ranges.

@Ubospica
Copy link
Collaborator

Ubospica commented Dec 4, 2024

@joennlae Thanks for your contribution! Sorry for not replying to you in time, and I will review the code later today

Copy link
Collaborator

@Ubospica Ubospica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall look great to me. Thanks for your contribution!

@@ -652,6 +654,122 @@ std::string JSONSchemaConverter::VisitAny(
kBasicArray + " | " + kBasicObject;
}

std::string generateRangeRegex(std::optional<int> start, std::optional<int> end) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make generateRangeRegex a static member function of JSONSchemaConverter, and follow the naming conversion (GenerateRangeRegex)?

std::string converted_regex = RegexToEBNF(range_regex, false);
return converted_regex; // not " " for numbers
}
} catch (const std::exception& e) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the usage of try-catch block and std::exception. The reason is we maintain a typescript binding running in WASM, which has not supported exceptions yet. Just throw an error at the error line.

@Ubospica Ubospica self-requested a review December 6, 2024 06:07
@Ubospica
Copy link
Collaborator

Ubospica commented Dec 6, 2024

We can merge this PR now, and I will update according to the above comments in a new PR. Thanks @joennlae!

@Ubospica Ubospica merged commit adb76d2 into mlc-ai:main Dec 6, 2024
1 check passed
Ubospica added a commit that referenced this pull request Dec 6, 2024
This PR updates the changes in #106. It removes the try-catch block, and make GenerateRangeRegex a static member function.
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