Method: Emfrp::Interpreter#process_repl_line

Defined in:
lib/emfrp/interpreter/interpreter.rb

#process_repl_line(line) ⇒ Object

-> true-like(abnormal-term) / false-like(normal-term)



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/emfrp/interpreter/interpreter.rb', line 116

def process_repl_line(line)
  readline_id = proceed_readline_id()
  @last_status = case line
  when /^\s*(data|func|type)\s(.*)$/
    append_def(readline_id, line)
  when /^[a-z][a-zA-Z0-9]*\s*=(.*)$/
    append_def(readline_id, "data #{line}")
  when /^\s*\:([a-z\-]+)\s*(.*)$/
    @last_command = $1
    command_exec($1, $2, readline_id)
  when /^\s*\:\s+(.*)$/
    if @last_command
      command_exec(@last_command, $1, readline_id)
    else
      puts "Error: there isn't a last-executed command"
      :recall_last_executed_error
    end
  when ""
    nil
  else
    if exp = str_to_exp(line)
      val = Evaluater.eval_exp(@top, exp)
      puts "#{Evaluater.value_to_s(val)} : #{exp[:typing].inspect.colorize(:green)}"
      nil
    else
      :eval_error
    end
  end
end