lib/rus3/parser/scheme_parser.rb in rus3-0.1.1 vs lib/rus3/parser/scheme_parser.rb in rus3-0.1.2

- old
+ new

@@ -153,11 +153,11 @@ case token.type when *Lexer::KEYWORDS.values r_exp = translate_ident(token.literal) when :string r_exp = token.literal - when :ident, :boolean, :number, :op_proc + when :ident, :boolean, :char, :number, :op_proc trans_method_name = "translate_#{token.type}".intern r_exp = self.send(trans_method_name, token.literal) else raise Rus3::SchemeSyntaxError, token.literal end @@ -209,9 +209,20 @@ end def translate_boolean(s_exp_literal) # literal == "#f" or #t" (s_exp_literal[1] == "f") ? "false" : "true" + end + + def translate_char(s_exp_literal) + c = s_exp_literal[2..-1] + case c + when "space" + c = " " + when "newline" + c = "\n" + end + "Char.new(\"#{c}\")" end def translate_number(s_exp_literal) if s_exp_literal.include?("/") # rational? denominator, numerator = s_exp_literal.split("/").map{|s| Kernel.eval(s)}