Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created January 20, 2020 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baweaver/d0e40f6de6223dcbc9b7872c41f93225 to your computer and use it in GitHub Desktop.
Save baweaver/d0e40f6de6223dcbc9b7872c41f93225 to your computer and use it in GitHub Desktop.
# 1 + 1
AstBuilder.build('1 + 1').to_ast.source
=> "1 + 1"
# From s-expressions
ast = AstBuilder.build { s(:send, s(:int, 1), :+, s(:int, 1)) }.to_ast
=> s(:send, s(:int, 1), :+, s(:int, 1))
# Current
ast.source
# NoMethodError: undefined method `expression' for nil:NilClass
# Want
'1 + 1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment