xrpn 1.3.4 → 1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fd6c24bf0ae1e16e943aaf138b71c12d3fb91f96a76db8c4177ab4ff4a0a5f5
4
- data.tar.gz: 38e57e229c8d739f5967de726866f87b309b1e74be3e42ca65d4807ea4768ea2
3
+ metadata.gz: 257af776c59f5959ad0f647a818754cb9662a72b66bd9f57fbfd5de5ccd55bb0
4
+ data.tar.gz: 4b2e366317250288ef9adc01a82c45a18547193bc4c07c224166f03a5291e07f
5
5
  SHA512:
6
- metadata.gz: 8fda5beedc920d94a7711ad6d78908b785cd08ece3909a3e79583045300faf784c1b762640fd79fb1c9a178404b0da8199c4af9f50531a356f455fcb07b38107
7
- data.tar.gz: 678af3b283e0970dca83f62c8ad85a26a3a4902b59aa0832edbf37308fd1a7dbd25dcd4fd9e250c6ff0f6eb48b4c8ec34cf9bde22f10ad7f2b1d1f855b3e0f10
6
+ metadata.gz: 35a01b19ccfd4fdf469345356966205c656b72fff3a82c26c2809fb6938dd9cab7908e2c04976ffd3eb7b608451587d46128707c130b05875beba0caab468444
7
+ data.tar.gz: f1dd342b8f13f72e5540766ed43b7fc2cf48b0b099d3bec56fccff8e9aa745f884bad06dfe3765401d671c472968c4e0c003da4c1bf3b22fec65164270de2bc9
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # XRPN
2
+ ![Ruby](https://img.shields.io/badge/language-Ruby-red) ![Unlicense](https://img.shields.io/badge/license-Unlicense-green) ![Stay Amazing](https://img.shields.io/badge/Stay-Amazing-important)
2
3
 
3
4
  ## Introduction
4
5
 
@@ -25,10 +26,11 @@ To run XRPN, make sure the program file ("bin/xrpn") is copied or linked to a di
25
26
  The full synopsis goes like this:
26
27
  ```
27
28
  Usage: xrpn [options]
28
- -f, --file XRPN-file Specify the file to process
29
- -l, --load XRPN-file Specify a file to load, but not run
29
+ -e, --execute string Interpret string as program and run
30
+ -f, --file program Specify the file to process
31
+ -l, --load program(s) File(s) to load, but not run
30
32
  -s, --state STATE Load a State file
31
- -c, --check program Program file to check for errors
33
+ -c, --check program Program file to check for errors
32
34
  -x, --X X-value Set initial value in the X register
33
35
  -y, --Y Y-value Set initial value in the Y register
34
36
  -z, --Z Z-value Set initial value in the Z register
@@ -38,6 +40,11 @@ Usage: xrpn [options]
38
40
  --help Display LONG help text
39
41
  -v, --version Display the XRPN version number
40
42
  ```
43
+ A program can be run by supplying a program file (option -f), by supplying a string with commands separated by commas (option -e) or by starting xrpn without any options and keying in the program manually.
44
+
45
+ Using the -eoption, you could do e.g. `xrpn -e "43, sin, 1/x, prx"`.
46
+
47
+ You can also pipe a string into xrpn like this: `echo "1,2,+,4,/,prx" | xrpn`.
41
48
 
42
49
  ## FOCAL and the HP-41 system
43
50
 
data/bin/xrpn CHANGED
@@ -1,5 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
+ #
4
+ # SCRIPT INFO
5
+ # Name: XRPN - eXtended Reverse Polish Notation programming language
6
+ # Language: Pure Ruby, best viewed in VIM
7
+ # Author: Geir Isene <g@isene.com>
8
+ # Web_site: http://isene.com/
9
+ # Github: https://github.com/isene/xrpn
10
+ # License: I release all copyright claims. This code is in the public domain.
11
+ # Permission is granted to use, copy modify, distribute, and sell
12
+ # this software for any purpose. I make no guarantee about the
13
+ # suitability of this software for any purpose and I am not liable
14
+ # for any damages resulting from its use. Further, I am under no
15
+ # obligation to maintain or extend this software. It is provided
16
+ # on an 'as is' basis without any expressed or implied warranty.
3
17
 
4
18
  # GET EXTENSIONS
5
19
  require 'optparse'
@@ -33,6 +47,7 @@ optparse = OptionParser.new do |opts|
33
47
  opts.banner = "Usage: xrpn [options]"
34
48
 
35
49
  # Define the options, and what they do
50
+ opts.on('-e', '--execute string', 'Interpret string as program and run') { |e| $exe = e }
36
51
  opts.on('-f', '--file program', 'Specify the file to process') { |f| $rfile = f }
37
52
  opts.on('-l', '--load program(s)', Array, 'File(s) to load, but not run') { |l| $lfile = l }
38
53
  opts.on('-s', '--state STATE', 'Load a State file') { |s| $sfile = s }
@@ -48,6 +63,9 @@ optparse = OptionParser.new do |opts|
48
63
  end
49
64
  optparse.parse!
50
65
 
66
+ input = (STDIN.tty?) ? '' : $stdin.read
67
+ $exe = input unless input == ''
68
+
51
69
  # INITIALIZE CLASS
52
70
  @p = XRPN.new($rfile)
53
71
 
@@ -58,7 +76,8 @@ load(Dir.home+'/.xrpn/conf') if File.exist?(Dir.home+'/.xrpn/conf')
58
76
  @p.x, @p.y, @p.z, @p.t, @p.a = @x, @y, @z, @t, @a
59
77
 
60
78
  # INITIALIZE XRPN PROGRAM
61
- @p.prg[@p.pg] = ["LBL \"XRPN\"", "END"] unless $rfile # Put dummy program in page 0 if no file to run
79
+ @p.prg[@p.pg] = ["LBL \"XRPN\"", "END"] # Put dummy program in page 0 if no file/string to run
80
+ @p.prg[@p.pg] = hp_41($exe.split(",")) if $exe # Read in string as program is supplied by -e/--execute
62
81
  @p.prg[@p.pg] = hp_41(@p.prg[@p.pg]) if $rfile # Substitute HP-41 commands with XRPN commands
63
82
  if $lfile # Read file to load but not run if -l switch is used
64
83
  $lfile.each_with_index do |f, i|
data/xcmd/getfile CHANGED
@@ -3,11 +3,11 @@ class XRPN
3
3
  def getfile
4
4
  lift
5
5
  begin
6
- @x = File.read(@a)
6
+ @x = File.read(@a).chomp
7
7
  rescue
8
- return "Cannot read the file '#{a}'"
8
+ return "Cannot read the file \"#{a}\""
9
9
  end
10
10
  end
11
11
  end
12
12
 
13
- # vim:ft=ruby:
13
+ # vim:ft=ruby:
data/xcmd/getfilea CHANGED
@@ -2,11 +2,11 @@ class XRPN
2
2
  # Read any file named in Alpha into Alpha
3
3
  def getfilea
4
4
  begin
5
- @a = File.read(@a)
5
+ @a = File.read(@a).chomp
6
6
  rescue
7
- return "Cannot read the file '#{a}'"
7
+ return "Cannot read the file \"#{a}\""
8
8
  end
9
9
  end
10
10
  end
11
11
 
12
- # vim:ft=ruby:
12
+ # vim:ft=ruby:
data/xlib/_xrpn_version CHANGED
@@ -1,5 +1,5 @@
1
1
  def xrpn_version
2
- puts "XRPN version: 1.3"
2
+ puts "XRPN version: 1.5"
3
3
  end
4
4
 
5
5
  # vim:ft=ruby:
data/xrpn.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'xrpn'
3
- s.version = '1.3.4'
3
+ s.version = '1.5'
4
4
  s.licenses = ['Unlicense']
5
5
  s.summary = "XRPN - The eXtended RPN (Reverse Polish Notation) programming language"
6
- s.description = "A full programming language and environment extending the features of the venerable HP calculator programmable calculators. With XRPN you can accomplish a wide range of modern programming tasks as well as running existing HP-41 FOCAL programs directly. XRPN gives modern life to tens of thousands of old HP calculator programs and opens the possibilities to many, many more. New in 1.3.4: Added file system commands READ, OPEN, COPY, MOVE."
6
+ s.description = "A full programming language and environment extending the features of the venerable HP calculator programmable calculators. With XRPN you can accomplish a wide range of modern programming tasks as well as running existing HP-41 FOCAL programs directly. XRPN gives modern life to tens of thousands of old HP calculator programs and opens the possibilities to many, many more. New in 1.5: You can now pipe commands into xrpn or run xrpn with the -e option to supply a program from the command line. Such string must have commands separated by a comma like this: '1, 2, +, sin, 1/x, prx'"
7
7
 
8
8
  s.authors = ["Geir Isene"]
9
9
  s.email = 'g@isene.com'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xrpn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: '1.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-16 00:00:00.000000000 Z
11
+ date: 2023-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
@@ -28,8 +28,10 @@ description: 'A full programming language and environment extending the features
28
28
  the venerable HP calculator programmable calculators. With XRPN you can accomplish
29
29
  a wide range of modern programming tasks as well as running existing HP-41 FOCAL
30
30
  programs directly. XRPN gives modern life to tens of thousands of old HP calculator
31
- programs and opens the possibilities to many, many more. New in 1.3.4: Added file
32
- system commands READ, OPEN, COPY, MOVE.'
31
+ programs and opens the possibilities to many, many more. New in 1.5: You can now
32
+ pipe commands into xrpn or run xrpn with the -e option to supply a program from
33
+ the command line. Such string must have commands separated by a comma like this:
34
+ ''1, 2, +, sin, 1/x, prx'''
33
35
  email: g@isene.com
34
36
  executables:
35
37
  - xrpn
@@ -223,7 +225,6 @@ files:
223
225
  - xcmd/rclpta
224
226
  - xcmd/rclsw
225
227
  - xcmd/rdn
226
- - xcmd/read
227
228
  - xcmd/recip
228
229
  - xcmd/regmove
229
230
  - xcmd/regswap
data/xcmd/read DELETED
@@ -1,12 +0,0 @@
1
- class XRPN
2
- # Reads content of file named in Alpha into X
3
- def read
4
- begin
5
- @x = File.read(@a).chomp
6
- rescue
7
- puts "Cannot read file \"#{@a}\""
8
- end
9
- end
10
- end
11
-
12
- # vim:ft=ruby: