projects
/
unix-history
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dcb1686
)
BSD 4_3 development
author
CSRG
<csrg@ucbvax.Berkeley.EDU>
Sat, 26 Feb 1983 03:58:26 +0000
(19:58 -0800)
committer
CSRG
<csrg@ucbvax.Berkeley.EDU>
Sat, 26 Feb 1983 03:58:26 +0000
(19:58 -0800)
Work on file usr/contrib/icon/book/19/fix.icn
Synthesized-from: CSRG/cd1/4.3
usr/contrib/icon/book/19/fix.icn
[new file with mode: 0644]
patch
|
blob
diff --git a/usr/contrib/icon/book/19/fix.icn
b/usr/contrib/icon/book/19/fix.icn
new file mode 100644
(file)
index 0000000..
faf63e5
--- /dev/null
+++ b/
usr/contrib/icon/book/19/fix.icn
@@ -0,0
+1,24
@@
+procedure main()
+ while write(fix(read()))
+end
+
+procedure fix(exp)
+ while exp ?:= 2(="(",tab(bal(')')),pos(-1))
+ return lassoc(exp,'+-' | '*/') | rassoc(exp,'^') | exp
+end
+
+procedure lassoc(exp,op)
+ local j
+ return exp ? {
+ every j := bal(op)
+ form(tab(\j),move(1),tab(0))
+ }
+end
+
+procedure rassoc(exp,op)
+ return exp ? form(tab(bal(op)),move(1),tab(0))
+end
+
+procedure form(arg1,op,arg2)
+ return op || "(" || fix(arg1) || "," || fix(arg2) || ")"
+end