rpl 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/rpl +24 -13
- data/lib/rpl.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 745f492092d7e5dd03c90ca25ee5de900832730342075295a8f9d190734ed4d4
|
4
|
+
data.tar.gz: b7a56161fcf77d5b90b015e4bc67ba3a770605aba261c46f40adfbac1232daa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4df6860f009ab1ae4c957000e98fd7f39be60c2d9370ab0626a60e71a84625b14e9d5bb9142c53d178d602b2654ec95ade37d4bf03825245a318d7da9f5a6296
|
7
|
+
data.tar.gz: 19f365a0e10430051ba6ca75cbe55d4504fb3ef2e6d778e4114d335f20c558f7921b9921b949caf11eb3fccb1538f014f3c2a396421648fee0035fa8eac08f67
|
data/bin/rpl
CHANGED
@@ -3,34 +3,42 @@
|
|
3
3
|
|
4
4
|
require 'English'
|
5
5
|
require 'optparse'
|
6
|
-
require '
|
6
|
+
require 'reline'
|
7
7
|
|
8
8
|
require 'rpl'
|
9
9
|
|
10
10
|
class RplRepl
|
11
11
|
def initialize( interpreter: Rpl.new )
|
12
|
+
begin
|
13
|
+
@stty_save = `stty -g`.chomp
|
14
|
+
rescue Error => e
|
15
|
+
puts "Couldn't get terminal characteristics"
|
16
|
+
pp e
|
17
|
+
end
|
18
|
+
|
12
19
|
@interpreter = interpreter
|
13
20
|
end
|
14
21
|
|
15
22
|
def run
|
16
23
|
print_stack unless @interpreter.stack.empty?
|
17
24
|
|
18
|
-
|
25
|
+
Reline.completion_proc = proc do |s|
|
19
26
|
( @interpreter.dictionary.words.keys + @interpreter.dictionary.vars.keys ).grep(/^#{Regexp.escape(s)}/)
|
20
27
|
end
|
21
|
-
|
28
|
+
Reline.completion_append_character = ' '
|
22
29
|
|
23
30
|
prefill = ''
|
24
31
|
loop do
|
25
|
-
|
26
|
-
|
32
|
+
unless prefill.empty?
|
33
|
+
Reline.pre_input_hook = lambda do
|
34
|
+
Reline.insert_text( prefill.to_s )
|
35
|
+
Reline.redisplay
|
27
36
|
|
28
|
-
|
29
|
-
|
30
|
-
Readline.redisplay
|
37
|
+
Reline.pre_input_hook = nil
|
38
|
+
end
|
31
39
|
end
|
32
40
|
|
33
|
-
input =
|
41
|
+
input = Reline.readline( ' ', true )
|
34
42
|
|
35
43
|
break if input.nil? || input.strip == 'quit'
|
36
44
|
|
@@ -39,12 +47,11 @@ class RplRepl
|
|
39
47
|
if input.strip == 'edit'
|
40
48
|
prefill = @interpreter.stack.pop.to_s
|
41
49
|
elsif input.strip == 'history'
|
42
|
-
|
43
|
-
|
44
|
-
end
|
50
|
+
history = Reline::HISTORY.map { |line| "\"#{line}\"" }.join(' ')
|
51
|
+
@interpreter.run( "{ #{history} }" )
|
45
52
|
elsif input.empty?
|
46
53
|
# Remove blank lines from history
|
47
|
-
|
54
|
+
Reline::HISTORY.pop
|
48
55
|
else
|
49
56
|
begin
|
50
57
|
@interpreter.run( input )
|
@@ -54,6 +61,10 @@ class RplRepl
|
|
54
61
|
end
|
55
62
|
|
56
63
|
print_stack
|
64
|
+
rescue Interrupt
|
65
|
+
puts '^C'
|
66
|
+
`stty #{@stty_save}` if @stty_save
|
67
|
+
exit 0
|
57
68
|
end
|
58
69
|
end
|
59
70
|
|
data/lib/rpl.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gwenhael Le Moine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A language inspired by HP's RPL and https://github.com/louisrubet/rpn/
|
14
14
|
email: gwenhael@le-moine.org
|