Skip to content

Instantly share code, notes, and snippets.

@peteruhnak
Created November 13, 2017 19:37
Show Gist options
  • Save peteruhnak/96d2be7c56c8bef4c6d3435378e03fc0 to your computer and use it in GitHub Desktop.
Save peteruhnak/96d2be7c56c8bef4c6d3435378e03fc0 to your computer and use it in GitHub Desktop.

RBParser node rewrite

Question

something: aSomething
    something := aSomething

[OUT]

something: aSomething
    self write: aSomething into: #something

Answer

you should try {:node :dic | ... } to handle that.

Something like:

RBParseTreeRewriter new
        replace: '`@var `{:node :dic | dic at: #varName put: node name} := `@arg'
        with: 'self write: `@arg into: `{:dic |
                RBParser parseExpression: ''#'', (dic at: #varName) }'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment