-
Notifications
You must be signed in to change notification settings - Fork 18k
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
proposal: regexp: add CompileSyntax #14078
Comments
Can you give an example of why somebody might want to do that? |
The reason I wanted it is that I'm building regexp ASTs from tagged struct fields. So I look through the fields of a struct and build a But also it seems that if you're going to expose |
Another use case would be if you wanted to use a custom |
@ianlancetaylor Ping. The immediate use case for this is constructing regexp ASTs from struct tag fields. But I do think this request is more general than my one use case: why have machinery for describing a regexp as an AST, and machinery for executing regular expressions, but no way to bridge the divide? |
Sorry, we're not processing proposals right now due to Go 1.6 release work. I will say that this is not the trivial thing it looks like. |
The regexp/syntax package is really an internal package that appeared before the official internal mechanism launched. Changes for outside users are therefore strongly discouraged. |
Currently there is, I believe, no way to turn a
syntax.Regex
AST into an executableregexp.Regex
from outside the regexp package. How about addingto the regexp package?
The implementation would be mostly trivial because the first step in
regexp.Compile
is already to build asyntax.Regexp
.The regexp.Regexp struct does have an
expr string
field, which could be populated withast.String()
inCompileSyntax
.If people agree that this is a good idea then I'm happy to make the CL.
The text was updated successfully, but these errors were encountered: