all:
mkdir -p bin
- nitc --semi-global nitin_readline.nit -o bin/nitin
+ nitc --semi-global nitin.nit -m readline -o bin/nitin
# The Nit interactive interpreter
module nitin
+import prompt
+
import nitc::interpreter
import nitc::frontend
import nitc::parser_util
return tree.n_base.as(not null)
end
- # Read an user-line with a given `prompt`
- #
- # Return `null` if end of file
- fun readline(prompt: String): nullable String do
- printn prompt
- var res = stdin.read_line
- if res == "" and stdin.eof then return null
- return res
- end
-
- # Add `text` in the history for `readline`.
- #
- # With the default implementation, the history is dropped
- fun readline_add_history(text: String) do end
-
# The last line number read by `i_parse`
var last_line = 0
s = stdin.read_line
if s == "" and stdin.eof then s = null
else
- s = readline(prompt)
+ s = sys.prompt(prompt)
end
if s == null then return null
if s == "" then
end
last_line = n.location.file.line_starts.length - 1
- readline_add_history(text.chomp)
+ prompt_add_history(text.chomp)
return n
end
end
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# Add GNU readline capabilities to nitin
-module nitin_readline
-
-import nitin
-import readline
-
-redef class ToolContext
- redef fun readline(prompt) do return sys.readline(prompt)
- redef fun readline_add_history(text) do sys.add_history(text)
-end