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

Fix incorrect keyword lexing #122

Merged
merged 1 commit into from
Jan 4, 2022
Merged

Fix incorrect keyword lexing #122

merged 1 commit into from
Jan 4, 2022

Commits on Jan 4, 2022

  1. Fix incorrect keyword lexing

    For some weird reason this line is detected as a keyword line:
    
    ```
                type: :module,
    ```
    
    Though it clearly isn't. Ripper:
    
    ```
    require 'ripper'
    
    pp Ripper.lex(<<~'EOM')
      {
        type: :module,
      }
    EOM
    ```
    
    Produces:
    
    ```
    [[[1, 0], :on_lbrace, "{", BEG|LABEL],
     [[1, 1], :on_ignored_nl, "\n", BEG|LABEL],
     [[2, 0], :on_sp, "  ", BEG|LABEL],
     [[2, 2], :on_label, "type:", ARG|LABELED],
     [[2, 7], :on_sp, " ", ARG|LABELED],
     [[2, 8], :on_symbeg, ":", FNAME],
     [[2, 9], :on_kw, "module", ENDFN],
     [[2, 15], :on_comma, ",", BEG|LABEL],
     [[2, 16], :on_ignored_nl, "\n", BEG|LABEL],
     [[3, 0], :on_rbrace, "}", END],
     [[3, 1], :on_nl, "\n", BEG],
     [[4, 0], :on_const, "EOM", CMDARG]]
    ```
    
    This is the problem line:
    
    ```
     [[2, 9], :on_kw, "module", ENDFN],
    ```
    
    Digging into the IRB source code they handled this case here ruby/ruby@776759e. Based on the description I believe this may be a bug in the lexer, but I'm not sure how to validate it.
    schneems committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    b8c6215 View commit details
    Browse the repository at this point in the history