-
-
Save JayTeeSF/6747856479055a4f0544 to your computer and use it in GitHub Desktop.
Crystal REPL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "./compiler/crystal/**" | |
while line = gets | |
compiler = Crystal::Compiler.new | |
program = Crystal::Program.new | |
program.target_machine = compiler.target_machine | |
prelude = program.normalize(Crystal::Require.new("prelude")) | |
parser = Crystal::Parser.new("(#{line}).inspect") | |
node = parser.parse | |
node = program.normalize(node) | |
node = Crystal::Expressions.new([prelude, node]) | |
node = program.normalize(node) | |
node = program.infer_type(node) | |
# pp node.type | |
res = program.evaluate(node) | |
puts res.to_string | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment