Skip to content

Pretty-print regular expression options #62

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

Closed
flavorjones opened this issue Apr 28, 2022 · 1 comment · Fixed by #66
Closed

Pretty-print regular expression options #62

flavorjones opened this issue Apr 28, 2022 · 1 comment · Fixed by #66

Comments

@flavorjones
Copy link

Given the trivial program

/asdf/
/asdf/i
/asdf/m
/asdf/x
/asdf/o
/asdf/imxo

the pretty-print for each of these regular expressions literals is identical:

(program
  (statements
    ((regexp_literal ((tstring_content "asdf"))),
      (regexp_literal ((tstring_content "asdf"))),
      (regexp_literal ((tstring_content "asdf"))),
      (regexp_literal ((tstring_content "asdf"))),
      (regexp_literal ((tstring_content "asdf"))),
      (regexp_literal ((tstring_content "asdf"))))))

even though they have different options (which are present in the AST node as part of the ending attribute).

I'm happy to submit a PR to change this behavior if you a) think it would be valuable, and b) would be so kind as to suggest the sexp structure you'd like to emit in this case.

@kddnewton
Copy link
Member

Please do! I would add it to the visit_regexp_literal method with a field call. Something like field("options", node.ending[1..-1]) should do the trick. (ending in this case is the close of the regex, so it could start with / or } or > or whatever else.)

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 a pull request may close this issue.

2 participants