aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/texpand/mkrules.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /pkg/utilities/nttools/texpand/mkrules.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/utilities/nttools/texpand/mkrules.x')
-rw-r--r--pkg/utilities/nttools/texpand/mkrules.x48
1 files changed, 48 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/texpand/mkrules.x b/pkg/utilities/nttools/texpand/mkrules.x
new file mode 100644
index 00000000..c1dd3aad
--- /dev/null
+++ b/pkg/utilities/nttools/texpand/mkrules.x
@@ -0,0 +1,48 @@
+define SZ_COLVAL SZ_LINE
+
+# MKRULES -- Add a new rule to the target and action tables
+#
+# B.Simon 25-Apr-88 Original
+
+procedure mkrules (work, target, action)
+
+pointer work # i: Table containing parser results
+pointer target # i: Table containing patterns to be matched
+pointer action # i: Table containing possible expansions
+#--
+int nwork, naction, ntarget, iwork, iaction
+
+int numstack()
+
+errchk movtbrow, putstacki
+
+begin
+ # Check for null rules
+
+ nwork = numstack (work)
+ if (nwork <= 0)
+ return
+
+ # Move the first row from the work table to the target table
+
+ call pushstack (target)
+ naction = numstack (action)
+ ntarget = numstack (target)
+
+ call movtbrow (work, 1, target, ntarget)
+ call putstacki (target, "_FIRST", naction+1)
+ call putstacki (target, "_LAST", naction+nwork-1)
+ call putstacki (target, "_USED", NO)
+
+ # Move the remaining rows to the action table
+
+ iaction = naction
+ do iwork = 2, nwork {
+ call pushstack (action)
+ iaction = iaction + 1
+ call movtbrow (work, iwork, action, iaction)
+ }
+
+ call tbrdel (work, 1, nwork)
+
+end