Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
20 lines (18 sloc) 544 Bytes
require "lexer"
code = <<-EOS
if 1:
print "..."
if false:
pass
print "done!"
print "The End"
EOS
p Lexer.new.tokenize(code)
# [[:IF, "if"], [:NUMBER, 1],
# [:INDENT, 2], [:IDENTIFIER, "print"], [:STRING, "..."], [:NEWLINE, "\n"],
# [:IF, "if"], [:IDENTIFIER, "false"],
# [:INDENT, 4], [:IDENTIFIER, "pass"],
# [:DEDENT, 2], [:NEWLINE, "\n"],
# [:IDENTIFIER, "print"], [:STRING, "done!"],
# [:DEDENT, 0], [:NEWLINE, "\n"],
# [:IDENTIFIER, "print"], [:STRING, "The End"]]
Something went wrong with that request. Please try again.