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

+ ruby-[parse, rewrite]: add legacy switches #699

merged 1 commit into from May 26, 2020


Copy link

marcandre commented May 26, 2020

This PR adds switches to ruby-parse and ruby-rewrite to turn off emit_lambda, etc.

I thought that --legacy would be an easy to remember switch and also added --legacy-lambda, etc. just because.

Usecase: The actual AST printed / passed on to rewriter is quite important, so these switches should be available. In particular, rubocop currently does not turn them on, so writing/debugging cops using ruby-parse is much more error prone.

New help look like:

$ ruby-parse -h
Usage: ruby-parse [options] FILE|DIRECTORY...
        --18                         Parse as Ruby 1.8.7 would
        --19                         Parse as Ruby 1.9.3 would
        --20                         Parse as Ruby 2.0 would
        --21                         Parse as Ruby 2.1 would
        --22                         Parse as Ruby 2.2 would
        --23                         Parse as Ruby 2.3 would
        --24                         Parse as Ruby 2.4 would
        --25                         Parse as Ruby 2.5 would
        --26                         Parse as Ruby 2.6 would
        --27                         Parse as Ruby 2.7 would
        --28                         Parse as Ruby 2.8 would
        --mac                        Parse as MacRuby 0.12 would
        --ios                        Parse as mid-2015 RubyMotion would
        --legacy                     Parse with all legacy modes
        --legacy-lambda              Parse with legacy mode for emit_lambda
        --legacy-procarg0            Parse with legacy mode for emit_procarg0
        --legacy-encoding            Parse with legacy mode for emit_encoding
        --legacy-index               Parse with legacy mode for emit_index
        --legacy-arg-inside-procarg0 Parse with legacy mode for emit_arg_inside_procarg0
    -w, --warnings                   Enable warnings
    -B, --benchmark                  Benchmark the processor
    -e fragment                      Process a fragment of Ruby code
    -L, --locate                     Explain how source maps for AST nodes are laid out
    -E, --explain                    Explain how the source is tokenized
        --emit-ruby                  Emit S-expressions as valid Ruby code
        --emit-json                  Emit S-expressions as valid JSON
    -h, --help                       Display this help message and exit
    -V, --version                    Output version information and exit

  If you specify a DIRECTORY, then all *.rb files are fetched
  from it recursively and appended to the file list.

  The default parsing mode is for current Ruby (2.7.1).
Copy link
Contributor Author

marcandre commented May 26, 2020

(If this is accepted, a release would be much appreciated)

Copy link

iliabylich left a comment


@iliabylich iliabylich changed the title Add legacy switches to `ruby-parse` and `ruby-rewrite` + ruby-[parse, rewrite]: add legacy switches May 26, 2020
@iliabylich iliabylich merged commit 996c820 into whitequark:master May 26, 2020
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Copy link

iliabylich commented May 26, 2020

Copy link
Contributor Author

marcandre commented May 26, 2020

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.