Please review any and all PUBLIC repositories, groups and associate files. These allow anyone on the Internet to access without authentication. Repository and group owners are responsible for their content and permission settings. Go to your project(s), click on Settings > General and expand the "Visibility, project features, permissions" to change this setting.

Commit e27bd695 authored by Mike Collins's avatar Mike Collins

File Clean up. Removed files with .o and ~ at end of file names. Moved hanoi...

File Clean up.  Removed files with .o and ~ at end of file names.  Moved hanoi example from bin to examples.
parent f6292103
-- Hanoi tower problem
#MAIN
OPEN S ' ';
$Count:=4; -- Count of rings in first tower
S<<' Rings count =' $Count ;
$STATE:=#INIT($Count); -- Global variable
#VIDEOSHOW(T);
#H( $Count 1 3 );
##
#H
$Num $From $To
/
S<< ' $Num $From $To =' $Num $From $To ;
IF $Num=1 ->
S << 'FROM' $From 'TO ' $To;
#VIDEOMOVE ($From $To);
#VIDEOSHOW (T)
ELSIF T->
$Middle := 6-$From-$To ;
#H( $Num-1 $From $Middle );
#H( 1 $From $To );
#H( $Num-1 $Middle $To )
FI / ##
#INIT $Count
/ $V:=(.
<. LEN : COPY($Count), BODY : (.COPY($Count).) .>
<. LEN : 0 , BODY : (.0.) .>
<. LEN : 0 , BODY : (.0.) .> .);
LOOP
IF $Count=1 -> BREAK FI;
$Count:=COPY($Count-1);
$V[1].BODY!.:=$Count;
$V[2].BODY!.:=0;
$V[3].BODY!.:=0;
END;
RETURN $V;
/ ##
#VIDEOMOVE
$From $To
/
$S_from := LAST #MAIN $STATE [$From];
$S_to := LAST #MAIN $STATE [$To];
$Ring:=COPY( $S_from.BODY[$S_from.LEN]);
$S_from.BODY[$S_from.LEN]:=0;
$S_from.LEN+:=-1;
$S_to.LEN+:=1;
$S_to.BODY[$S_to.LEN]:=$Ring;
/
##
#VIDEOSHOW
/ $X:=LAST #MAIN $STATE;
$I:=1;
LOOP
S<<$I ' ';
#STR($X[1].BODY[-$I]);
S<]' ';
#STR($X[2].BODY[-$I]) ;
S<]' ';
#STR($X[3].BODY[-$I]);
IF $I>=LAST #MAIN $Count -> BREAK;FI;
$I+:=1;
END;
S<<;
#CALL_PAS(1 '<<<<<>>>>>>')/##
#STR
$N
/ $E:=LAST #MAIN $Count-$N;
#FILL(' ' $E);
#FILL('O' 2*$N);
#FILL(' ' $E)/ ##
#FILL
$SYM $CNT
/LOOP
$CNT:=$CNT-1;
IF $CNT<0 -> BREAK FI;
S<]@$SYM;
END;
/##
#!/bin/bash -f
$rig/anrig -p N.TMP
$rig/genrigd S -p N.TMP
cc -w -I{$rig}/../include -I. xcrg.c xcrg_0.c -o hanoi $rig/../lib/riglib.a -lm
rm -f xcrg_0.c xcrg_0.o
rm -f xcrg.c xcrg.o xcrga.h xcrg.h
rm -f *.RC2 *.RC4 RIGCOMP.TMP N.TMP
Operations with real values in Rigal
=======================================
NOTE:
This description presents implementation of
operations with real values in Rigal in
MS-DOS (Turbo-Pascal based) and UNIX (C - based)
variants, starting from Rigal V.2.34 and UNIX Rigal V.4.45.
Read carefully parts regarding UNIX and MS-DOS.
Old such description was for MS-DOS version
only. Unix description exists only starting from version
4.45.
Limitations of Turbo Pascal
===========================
MS-DOS Rigal is implemented via Pascal real run time library. The
following sequence of characters is accepted by Pascal VAL
procedure as a real number:
(* space *) [ (+!-) ] (* digits1 *) [ '.' (* digit2 *) ]
[ (e!E) [ (+!-) ] (* digit3 *) ]
The context constraints are that:
digit1+digit2<37 ( limited number of digits )
The absolute value of digits1.digits2E[-]digits3 must be
in 2.9e-39 ... 1.7e38
We assume that UNIX C has no such constraints.
Input real number from lexical analyzer
=======================================
We call real numbers stored in Rigal memory as #FATOMs. Use
built-in Rigal predicate #FATOM to recognize them. They
can be read by the lexical analyzer from its input as
sequences of characters that must match following grammar
rule
(+ digits1 +)
( '.' (* digit2 *) [ (e!E) [ (+!-) ] (* digit3 *) ]
! (e!E) [ (+!-) ] (* digit3 *) )
and it must be acceptable by procedure VAL (see above).
IN MS-DOS:
=========
If #FATOM is read then it is stored in 8-byte-length atom, 6
bytes are occupied by standard representation of REAL type
in Pascal. In other two bytes number of digits before dot
and number of digits after the dot are stored. If the input
number was in exponential form then these bytes contain
zeros.
IN UNIX:
=======
If #FATOM is read then it is stored in 8-byte-length atom,
assuming that sizeof(double)=8. The information about the
number of digits before the dot and number of digits after
the dot are _NOT_ stored.
Since standard 6 (or 8)-byte representation is stored, only 10 (13)
digits are valid.
Non-matching in MS-DOS scaner
=============================
If the input value matches grammar and does not match "VAL
rules" then atom with type #KEYWORD is produced (it is
used for diagnostic purposes). Normally #FATOM is produced.
Output of real numbers
======================
Statements PRINT, <<, ,<], built-in rules #IMPLODE and
#EXPLODE output real numbers in "exponential" form,
like the %E format in UNIX, or simple WRITE() in Pascal.
Sd.ddddddddddEZdd
S is space or '-'
d are digits (exactly 10 digits after dot)
E is character 'E'
Z is '+' or '-'
Real numbers in traditional operators
=====================================
If you use real numbers in traditional arithmetical
operators and comparisons, all #FATOMs are accepted the
same way as NULL. It corresponds to 0 value. If you compare
#FATOMs with '=', their internal representation (with 6
or 8 bytes long code) will be compared. Therefore, there
is no sense in such operations.
Ways to create #FATOM
=====================
#CALL_PAS(80 S any_string)
returns #FATOM if the string value matches "VAL rule".
Otherwise NULL is returned.
#CALL_PAS(80 I integer)
returns #FATOM. Integer value can be arbitrary.
Ways to get information from #FATOM
===================================
( THIS APPLIES TO MS_DOS VARIANT ONLY !)
======================================
#CALL_PAS(80 D #FATOM) returns pair
(. digits_before digits_after .)
for FATOM values that were entered through the
lexical analyzer. If the number was entered in exponential
style (with character, 'E'), value (. 0 0 .) is returned.
If the value was obtained by #CALL_PAS(80..), NULL is
returned. There is no other ways to create #FATOM.
NOTE:
If you have entered #FATOM to variable $X via lexical
analyzer, you can output it with the same number of digits
before and after the point (if it was not exponential
style) as it was read by lexical analyser:
$D:=#CALL_PAS(80 D $X);
IF $D AND ($D[1]+$D[2]>0) ->
$REZ:=#CALL_PAS(80 Z $X ($D[1]+$D[2]+1)*100+$D[2])
ELSIF T->
$REZ:=#CALL_PAS(80 V $X)
FI;
Conversions (MS-DOS VARIANT ONLY)
=================================
#CALL_PAS(80 T #FATOM)
returns #NUMBER - whole part of real value. If the
number is not in -2147483648..2147483647 then NULL is
returned.
#CALL_PAS(80 Z #FATOM D*100+A)
returns formatted string with the value of the real
number. "A" can be positive or negative.
If "A" is arbitrary NEGATIVE number then exponential form
is produced in following form:
Sd.dEZdd (e.g. -7.7E01)
S is space or '-' Z is '-' or '+'
If D>=9 then additional digits are added after the point,
but not more than 10 digits.
If "A" is 0 then integer value is produced, possible with
'-'.
If "A" is positive, it specifies number of digits after
the point. Non-exponential form is produced.
Zeros are appended after point if necessary. The
number of digits after the point cannot be larger than 11.
After all cases discussed above, if "D" is larger than the
new string, RIGAL adds spaces from the left side of the
string. The result string length is not less than "D".
#CALL_PAS(80 R #FATOM p)
- returns rounded value of real number. The number is
rounded such way that digits after p-th position after the
dot must be set to zeros. E.g. 23.1415 rounded at 2 nd
position must be 23.140000.
If p is not positive, it is accepted as 0. If absolute
value of real*(10 in p-th degree) is larger than 1e37 then
NULL is returned.
#CALL_PAS(80 V #FATOM)
- creates string from real number in form
[-]d.ddddddddddESdd
S is '+' or '-'
Conversions (UNIX VARIANT ONLY)
=================================
#CALL_PAS(80 F #FATOM FORMAT_STRING)
returns formatted string with UNIX C the _arbitrary_ format
(allowed in UNIX C sprintf function) you specified,
for example #CALL_PAS(80 F $A 'A=%.9e');
Note, however, that this option is _not_ ported to MS-DOS.
#CALL_PAS(80 Z #FATOM D*100+A)
returns formatted string with the value of the real
number. "A" _must_ be positive.
If "A" is 0 then integer value is produced, possible with
'-'.
If "A" is positive, it specifies number of digits after
the point. Non-exponential form is produced.
Zeros are appended after point if necessary. The
number of digits after the point cannot be larger than 11.
After all cases discussed above, if "D" is larger than the
new string, RIGAL adds spaces from the left side of the
string. The result string length is not less than "D".
#CALL_PAS(80 V #FATOM)
returns formatted string with UNIX C %E format.
Mathematical operations
=======================
#CALL_PAS(80 op #FATOM #FATOM)
Operations "op" can be '+','-', '*','/', '<','>',
'<=','>=', '<>','='
In MS-DOS if '+' or '-' applied, absolute value of the arguments
must be less than 6.2e37 otherwise NULL is returned.
In MS-DOS if '*' or '-' applied, absolute value of the result must
be between 1.6e-38..6.2e37 and the second argument of '/' is
not 0, otherwise NULL is returned.
If '<','>','<=','>=','<>','=' are applied, one of the
arguments is returned to indicate 'true', NULL is returned
to indicate 'false' Note that it is BAD and DANGEROUS STYLE to check the
results of real arithmetic using '=' or '<>' operations,
because the computer never calculates precise results. You
can compare two real numbers only after some conversion,
e.g. using #CALL_PAS(80 V ...).
#CALL_PAS(80 Q #FATOM) returns square root if argument is
not negative, NULL otherwise.
#CALL_PAS(80 X #FATOM) returns exponential ( e in r-th
degree) of the argument.
#CALL_PAS(80 L #FATOM) returns natural logarithm if the
argument is positive, otherwise NULL.
Mathematical operations for UNIX only
=====================================
#CALL_PAS(80 op #FATOM)
where op = tSIN, tCOS, tTAN, tASIN, tACOS, tATAN.
call corresponding functions from UNIX libm library.
Common note about #CALL_PAS(80..).
=================================
It has no run time diagnostic.
If wrong types of arguments of wrong number of arguments
or wrong operation name is given, NULL is returned.
If #CALL_PAS(80...) produces a #FATOM, it is 6 (or 8) bytes long
and it has _no_ information about the digits before and after
the dot.
You can learn more details about #CALL_PAS(80) from
source files USE80.PAS and SERVICES.PAS in MS-DOS,
usemod.c, sevice.c in UNIX C.
/*#define xxx printf("lin=%d file=%s\n",__LINE__,__FILE__);*/
#define xxx ;
int g_argc;
Char ** g_argv;
typedef union v {
a sa; /* s -adres */
longint nu;
boolean bo;
a at; /* a -adres */
} v;
boolean debugrule; /* to be used in future */
Char filebuf[2048];
/************ definitions in c1 ***************/
extern Void er PP((long n));
/* kod o{ibki */
extern Void errstr PP((long n, Char *s));
extern Void crlist PP((long *l));
/* p2c: c1.z, line 471:
* Note: Turbo Pascal conditional compilation directive was ignored [218] */
/* sozdatx pustoj spisok */
/*$ifdef xx*/
/*extern Void d PP((long r, long s));*/
extern Void d PP((long status_r ,char * rulename,long rulenum,long param,boolean success));
extern Void d1 PP((long r));
/*$endif*/
extern Void addel PP((long sel, boolean not_atomic, long xsel, long ob, long *tr_));
extern long numval PP((long ob));
/* nomer wstr.prawila */
extern Void bltin PP((v *rr, boolean *success, long arg, long n));
/* a-adres */
extern Void mkatom PP((long k, char atype, long *r));
/*************** c2 *****************/
extern Void concop PP((long *a1, long a2));
extern Void indxop PP((long xx, boolean isobject, long xa, long l, long *rez));
extern Void selop PP((long xn, boolean not_atomic, long xa, long tr_, long *rez));
extern Void setind PP((long xx, boolean isobject, long xa, long l, long rez));
extern Void setsel PP((long xn, boolean not_atomic, long xa, long tr_, long rez));
extern Void addnum PP((long *a1, long a2));
extern Void copyop PP((long ob, long *rez));
/* ******************* c3 ******************* */
#define max_digit 10
extern Void epilog PV();
extern Void prolog PV();
/* a-adr.imeni fajla*/
/* s-adr.wyw.obxekta*/
/* s now.stroki*/
/* s probelami*/
extern Void outxt PP((long fname, long arg, boolean nl, boolean blanks));
/* a-adr.imeni fajla*/
/* wywodimyj atom*/
/* s now.stroki*/
/* s probelami*/
extern Void outatm PP((long fname, Char *arg, boolean nl, boolean blanks));
/* a-adres imeni fajla*/
/* s-adr.*/
extern Void opn PP((long fname, long fspec));
/* 0-load,1 -save*/
extern Void loasav PP((v *p, long f, long paz));
extern Void explod PP((long kk, long *rez));
extern Void implod PP((ptr_ *pl, long *rez));
extern Void bltin1 PP((long *rez, boolean *success, ptr_ *pl, long n));
/* a-adr.*/
extern Void clsfil PP((long fname));
/**************** c4 ******************* */
/* cequ(=), cnequ(<>) */
extern boolean eqop PP((long o, long a1, long a2));
extern Void varpat PP((ptr_ *pl, char tip, long *rez, boolean *success));
extern Void atmpat PP((long aconval, ptr_ *pl, long *rez, boolean *success));
extern boolean eqnum PP((long m1, long n));
extern boolean eqatom PP((long m1, long atm));
/* kod operacii */
extern boolean compare PP((long op, long a1, long a2));
This diff is collapsed.
rig_lint
l_anal
l_operat
l_instr
l_patt
l_patt2
l_patt3
l_exprs
l_expr1
l_closur
l_check
#!/bin/csh -f
$rig/anrig -p N.TMP
$rig/genrigd S -p N.TMP
cc -w -O -I{$rig}/../include -I. xcrg.c xcrg_0.c\
xcrg_1.c\
xcrg_2.c\
xcrg_3.c\
xcrg_4.c\
xcrg_5.c\
xcrg_6.c\
xcrg_7.c\
xcrg_8.c\
xcrg_9.c\
xcrg_10.c\
-o rig_lint\
$rig/../lib/riglib.a -lm
rm -f xcrg_0.c xcrg_0.o
rm -f xcrg_1.c xcrg_1.o
rm -f xcrg_2.c xcrg_2.o
rm -f xcrg_3.c xcrg_3.o
rm -f xcrg_4.c xcrg_4.o
rm -f xcrg_5.c xcrg_5.o
rm -f xcrg_6.c xcrg_6.o
rm -f xcrg_7.c xcrg_7.o
rm -f xcrg_8.c xcrg_8.o
rm -f xcrg_9.c xcrg_9.o
rm -f xcrg_10.c xcrg_10.o
rm -f xcrg.c xcrg.o xcrga.h xcrg.h
rm -f *.RC2 *.RC4 RIGCOMP.TMP N.TMP
#
# MAKEFILE for Rigal in C, version 4.45.1
#
# C compiler to use (Compiler path can be changed by the user)
CCFLAGS = -g
PCA = cc $(CCFLAGS) -c -D xsun=1 -I../include/
# Specify -DLE for Little-endian architectures (Big-endian is default)!
# Specify -Dbbs for BBS-version of scaner (LaTeX version is default)!
LIBS = -lm
# This is for sin, cos, sqrt etc.
# Other things are usually not changed by the user
.INIT: check$(rig)
# -------------------------------------------------
# MACRO DEFINITIONS
# -----------------------------------------------
# Object files for "rc"
RCF_SRC = defsun3.o ley_.o nef2.o ou2.o sevice.o
# They are in src/ subdirectory
# Object files for "ic"
ICF_SRC = cim.o defsun3.o erm.o ic.o ley_.o scan.o scanmif.o usemod.o nef2.o ou2.o sevice.o
# Object files for "rc -c" (library)
CCF_SRC = defsun3.o ley_.o scan.o scanmif.o usemod.o c1.o c2.o c3.o c4.o nef2.o ou2.o sevice.o
DISTLIB = defsun3.c ley_.c scan.c scanmif.c usemod.c c1.c c2.c c3.c c4.c nef2.c ou2.c sevice.c
# All include files
INCLIB_SRC = ../include/c1.h ../include/define.h \
../include/defpage.h ../include/ley.h \
../include/scan.h ../include/cim.h \
../include/def180.h ../include/nef2.h\
../include/usemod.h ../include/globrig.h
#--------------------------------------------------------
# TARGET DEFINITIONS
#---------------------------------------------------------
# Normally builds all necessary after unpack and performs test.
normal: bins ../lib/riglib.a ../bin/anrig ../bin/genrigd ../bin/rig_lint test clean
bins: bin ../bin/rc ../bin/ic ../bin/v
bin:
-mkdir ../bin
../bin/rc:$(RCF_SRC) rc_.o
cc $(CCFLAGS) -o ../bin/rc rc_.o $(RCF_SRC)
../bin/ic:$(ICF_SRC)
cc $(CCFLAGS) -o ../bin/ic $(ICF_SRC) $(LIBS)
../bin/v:$(RCF_SRC) v.o
cc $(CCFLAGS) -o ../bin/v v.o $(RCF_SRC) $(LIBS)
../lib/riglib.a:$(CCF_SRC)
@echo '*Starting creating library'
-mkdir ../lib
-rm -f ../lib/riglib.a
ar rv ../lib/riglib.a $(CCF_SRC)
-ranlib ../lib/riglib.a
@echo '*Library created'
../bin/anrig:$(INCLIB_SRC) ../lib/riglib.a
cc $(CCFLAGS) -w \
-Ianrig/ -I../include/\
anrig/xcrg.c anrig/xcrg_0.c\
anrig/xcrg_1.c\
anrig/xcrg_2.c\
anrig/xcrg_3.c\
anrig/xcrg_4.c\
anrig/xcrg_5.c\
anrig/xcrg_6.c\
anrig/xcrg_7.c\
anrig/xcrg_8.c\
anrig/xcrg_9.c\
-o ../bin/anrig ../lib/riglib.a $(LIBS)
-rm -f anrig/*.o
../bin/genrigd:$(INCLIB_SRC) ../lib/riglib.a
cc $(CCFLAGS) -w \
-Igenrig/ -I../include/\
genrig/xcrg.c\
genrig/xcrg_1.c\
genrig/xcrg_2.c\
genrig/xcrg_3.c\
genrig/xcrg_4.c\
genrig/xcrg_5.c\
genrig/xcrg_6.c\
genrig/xcrg_7.c\
genrig/xcrg_8.c\
genrig/xcrg_9.c\
genrig/xcrg_10.c\
-o ../bin/genrigd ../lib/riglib.a $(LIBS)
-rm -f genrig/*.o
../bin/rig_lint: ../lint/rig_lint.rig ../bin/rc ../lib/riglib.a ../bin/anrig ../bin/genrigd
(cd ../lint;../bin/rc rig_lint -c -P '-O';cd ..)
-mv ../lint/rig_lint ../bin/
test: ../test/rigcrf.rig ../bin/rc ../lib/riglib.a ../bin/anrig ../bin/genrigd
(cd ../test;\
$(rig)/rc rigcrf;\
$(rig)/ic rigcrf rigcrf;\
$(rig)/rc rigcrf -c;\
rigcrf rigcrf)
##------------------ Hidden possibilities
z: anrigz genrigz
anrigz:
(cd anrig;\
../../bin/rc anrig;\
../../bin/anrig;\
../../bin/genrigd S -p N.TMP;\
/bin/rm *.RC2 *.RC4 *.TMP)
genrigz:
(cd genrig;\
../../bin/rc genrigd;\
../../bin/anrig;\
../../bin/genrigd S -p N.TMP;\
/bin/rm *.RC2 *.RC4 *.TMP)
##---------------------------------------
VERSION = 445.2
tar: clean
-rm -f ../rigsc.$(VERSION).tar.Z
(cd ..;tar -cvf rigsc.$(VERSION).tar include src examples lint doc test)
compress ../rigsc.$(VERSION).tar
cp ../rigsc.$(VERSION).tar.Z /info/ftp/pub/labs/pelab/rigal/
##--------------------------------------
clean:
mv ../test/rigcrf.rig .
-rm -f *.o */*.o *.RC2 */*.RC2 *.RC4 */*.RC4 */*.rsc ../lint/*.o ../lint/*.RC2 ../lint/*.RC4 \
../examples/hanoi ../*/*.rsc ../*/*.out ../*/*/*.out ../test/*
mv rigcrf.rig ../test/
##--------------------------------------
.c.o: $(INCLIB_SRC)
$(PCA) $< -o $@
check:
@echo '********************************************************'
@echo '*' User ERROR: you have not set \"rig\" environment variable to $(PWD)/../bin
@echo '********************************************************'
____FATAL___ERROR___
check$(rig):
@echo VARIABLE rig have been set to $(rig)
@echo ---------------------------------------
##----------------------------------------
# Prepare distribution
mkdist$(RFILE)$(RDIR):
@echo '*** to prepare for distribution write make mkdist RFILE=fff RDIR=/u/vaden/xyz/xyz/'
mkdist:
(cd $(RDIR);\
$(rig)/rc $(RFILE);\
$(rig)/anrig;\
$(rig)/genrigd S -p N.TMP;\
/bin/rm *.RC2 *.RC4 *.TMP)
cp ../include/* $(RDIR)
cp $(DISTLIB) $(RDIR)
(cd $(RDIR);\
echo 'cc -O -w -D xsun=1 ' $(DISTLIB) ' xc*.c -o ' $(RFILE) $(LIBS) > cmd)
mkdist2:
(cd $(RDIR);\
cc -O -w -D xsun=1 $(DISTLIB) xc*.c -o $(RFILE) $(LIBS) ;/bin/rm *.o)
This diff is collapsed.
#include "globrig.h"
#include "define.h"
#include "defpage.h"
#include "nef2.h"
#include "c1.h"
boolean eqatom(m1, atm)
long m1, atm;
{
mpd x;
atomdescriptor *WITH;
if (m1 == null_)
return false;
else {
pointr(m1, &x.sa);
WITH = x.sad;
return (((1L << ((long)WITH->dtype)) & (((1L << ((long)keyword + 1)) -
(1L << ((long)atom))) | (1L << ((long)fatom)))) != 0 &&
WITH->name == atm);
}
}
Void varpat(pl, tip, rez, success)
ptr_ *pl;
char tip;
long *rez;
boolean *success;
{
mpd x;
atomdescriptor *WITH;
*rez = pl->cel;
if (pl->nel == 0 || *rez == null_)
*success = false;
else {
pointr(*rez, &x.sa);
WITH = x.sad;
*success = (WITH->dtype == tip);
}
if (*success) {
if (pl->ptrtype != ptrtree)
next(pl);
} else
*rez = null_;
} /* varpat */
Void atmpat(aconval, pl, rez, success)
long aconval;
ptr_ *pl;
long *rez;
boolean *success;
{
mpd x;
atomdescriptor *WITH;