xrpn 1.3.5 → 1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -3
- data/bin/xrpn +28 -5
- data/xlib/_xrpn_version +1 -1
- data/xrpn.gemspec +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eaeb18f29172b8e96f6f06ef04d3be02c30296f13b3f7f67a30fae7791ba464
|
4
|
+
data.tar.gz: d5807637849f72490dd5ec06357d3b7f8de1024850dd87954fdf2d69e1cdb6b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d150e537776c8ffb9a0e1324a132b9fece173abbea78b23b329b082774d07da3e80d028a0098edf59655a10b983cc65df063ff5c57e8795c28e75a86756bb530
|
7
|
+
data.tar.gz: ac92b3b15c37ddb86b921a4fbfa30ff3ac38237325747a1cd4b5ebcfce85bbd23634b284af332c76ebc7366457baa02ad86e9868fb5a879d726a1cc8d786a248
|
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
|
-
-
|
29
|
-
-
|
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
|
-
|
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,10 @@ optparse = OptionParser.new do |opts|
|
|
48
63
|
end
|
49
64
|
optparse.parse!
|
50
65
|
|
66
|
+
# HANDLE INPUT FROM STDIN (PIPE) OR STRING VIA -e
|
67
|
+
input = (STDIN.tty?) ? '' : $stdin.read
|
68
|
+
$exe = input unless input == ''
|
69
|
+
|
51
70
|
# INITIALIZE CLASS
|
52
71
|
@p = XRPN.new($rfile)
|
53
72
|
|
@@ -58,7 +77,8 @@ load(Dir.home+'/.xrpn/conf') if File.exist?(Dir.home+'/.xrpn/conf')
|
|
58
77
|
@p.x, @p.y, @p.z, @p.t, @p.a = @x, @y, @z, @t, @a
|
59
78
|
|
60
79
|
# INITIALIZE XRPN PROGRAM
|
61
|
-
@p.prg[@p.pg] = ["LBL \"XRPN\"", "END"]
|
80
|
+
@p.prg[@p.pg] = ["LBL \"XRPN\"", "END"] # Put dummy program in page 0 if no file/string to run
|
81
|
+
@p.prg[@p.pg] = hp_41($exe.split(",")) if $exe # Read in string as program is supplied by -e/--execute
|
62
82
|
@p.prg[@p.pg] = hp_41(@p.prg[@p.pg]) if $rfile # Substitute HP-41 commands with XRPN commands
|
63
83
|
if $lfile # Read file to load but not run if -l switch is used
|
64
84
|
$lfile.each_with_index do |f, i|
|
@@ -66,6 +86,8 @@ if $lfile # Read file to load but
|
|
66
86
|
@p.prg[i] = hp_41(@p.prg[i])
|
67
87
|
end
|
68
88
|
end
|
89
|
+
@p.prg[@p.pg].push("END") unless @p.prg[@p.pg].last.upcase == "END"
|
90
|
+
|
69
91
|
read_state($sfile) if $sfile # Read state file in ~.xrpn/ if -s switch is used
|
70
92
|
$debug = true if $lfile or $sfile # Do not run loaded program or program in state file
|
71
93
|
|
@@ -88,13 +110,13 @@ until @p.pc == @p.prg[@p.pg].length do
|
|
88
110
|
@p.x = @line.to_f
|
89
111
|
@p.flg["22"] = true # Number has been entered
|
90
112
|
@p.flg["23"] = false
|
91
|
-
elsif @line.match(/^>?".*"/) # If an Alpha string is supplied
|
92
|
-
if @line.match(/^"\|/)
|
113
|
+
elsif @line.match(/^>?["'].*["']/) # If an Alpha string is supplied
|
114
|
+
if @line.match(/^["']\|/)
|
93
115
|
@p.a += @line.sub(/\|-?/, '').gsub(/\"/, '') # Append to Alpha if "|abc", "|-abc"
|
94
|
-
elsif @line.match(/^>"/)
|
116
|
+
elsif @line.match(/^>["']/)
|
95
117
|
@p.a += @line.sub(/>/, '').gsub(/\"/, '') # Append to Alpha if >"abc"
|
96
118
|
else
|
97
|
-
@p.a = @line.gsub(
|
119
|
+
@p.a = @line.gsub(/["']/, '') # ...or set Alpha to the supplied string
|
98
120
|
end
|
99
121
|
@p.flg["22"] = false
|
100
122
|
@p.flg["23"] = true # String has been entered
|
@@ -106,6 +128,7 @@ until @p.pc == @p.prg[@p.pg].length do
|
|
106
128
|
l1 = "" if l1 == nil
|
107
129
|
if not $cmd.include?(l1.downcase) # Catch unknown command
|
108
130
|
puts "No such command: #{l1}"
|
131
|
+
exit if $exe
|
109
132
|
@p.stop
|
110
133
|
elsif XRPN.method_defined?(l1.downcase) # Or execute the command with either 1 or 2 parts
|
111
134
|
begin
|
data/xlib/_xrpn_version
CHANGED
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
|
+
s.version = '1.6'
|
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.
|
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.6: Added the option to use single-quotes for Alpha entry. Added the safety-catch of adding an END to programs that does not have and END as the last line."
|
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.
|
4
|
+
version: '1.6'
|
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-
|
11
|
+
date: 2023-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|
@@ -28,8 +28,9 @@ 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.
|
32
|
-
|
31
|
+
programs and opens the possibilities to many, many more. New in 1.6: Added the option
|
32
|
+
to use single-quotes for Alpha entry. Added the safety-catch of adding an END to
|
33
|
+
programs that does not have and END as the last line.'
|
33
34
|
email: g@isene.com
|
34
35
|
executables:
|
35
36
|
- xrpn
|