-
-
Save orendon/0de311cfaf3c4cd5a0797c15c0d04db8 to your computer and use it in GitHub Desktop.
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
codigo = " p 'hello world' " | |
pp Ripper.lex(codigo) # Paso 1, Tokenizacion | |
# [[[1, 0], :on_sp, " "], | |
# [[1, 1], :on_ident, "p"], | |
# [[1, 2], :on_sp, " "], | |
# [[1, 3], :on_tstring_beg, "'"], | |
# [[1, 4], :on_tstring_content, "hello world"], | |
# [[1, 15], :on_tstring_end, "'"], | |
# [[1, 16], :on_sp, " "]] | |
pp Ripper.sexp(codigo) # Paso 2, Parseo | |
# [:program, | |
# [[:command, | |
# [:@ident, "p", [1, 1]], | |
# [:args_add_block, | |
# [[:string_literal, | |
# [:string_content, [:@tstring_content, "hello world", [1, 4]]]]], | |
# false]]]] | |
puts RubyVM::InstructionSequence.compile(codigo).disasm # Compilacion y ejecucion a bajo nivel | |
# == disasm: <RubyVM::InstructionSequence:<compiled>@<compiled>>========== | |
# 0000 trace 1 ( 1) | |
# 0002 putself | |
# 0003 putstring "hello world" | |
# 0005 opt_send_without_block <callinfo!mid:p, argc:1, FCALL|ARGS_SIMPLE> | |
# | |
# 0007 leave |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment