aboutsummaryrefslogtreecommitdiff
path: root/unix/boot/spp/rpp/rpprat/unstak.r
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /unix/boot/spp/rpp/rpprat/unstak.r
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'unix/boot/spp/rpp/rpprat/unstak.r')
-rw-r--r--unix/boot/spp/rpp/rpprat/unstak.r42
1 files changed, 42 insertions, 0 deletions
diff --git a/unix/boot/spp/rpp/rpprat/unstak.r b/unix/boot/spp/rpp/rpprat/unstak.r
new file mode 100644
index 00000000..ec8a6eef
--- /dev/null
+++ b/unix/boot/spp/rpp/rpprat/unstak.r
@@ -0,0 +1,42 @@
+include defs
+
+# unstak - unstack at end of statement
+
+define IFSTMT 999
+
+
+subroutine unstak (sp, lextyp, labval, token)
+
+integer labval(MAXSTACK), lextyp(MAXSTACK)
+integer sp, token, type
+
+ for (; sp > 1; sp=sp-1) {
+ type = lextyp(sp)
+ if ((type == LEXIFERR | type == LEXIFNOERR) & token == LEXTHEN)
+ break
+ if (type == LEXIF | type == LEXIFERR | type == LEXIFNOERR)
+ type = IFSTMT
+ if (type == LBRACE | type == LEXSWITCH)
+ break
+ if (type == IFSTMT & token == LEXELSE)
+ break
+
+ if (type == IFSTMT) {
+ call indent (-1)
+ call outcon (labval(sp))
+ } else if (type == LEXELSE | type == LEXIFELSE) {
+ if (sp > 2)
+ sp = sp - 1
+ if (type != LEXIFELSE)
+ call indent (-1)
+ call outcon (labval(sp) + 1)
+ } else if (type == LEXDO)
+ call dostat (labval(sp))
+ else if (type == LEXWHILE)
+ call whiles (labval(sp))
+ else if (type == LEXFOR)
+ call fors (labval(sp))
+ else if (type == LEXREPEAT)
+ call untils (labval(sp), token)
+ }
+end