/************************************************************************ * gettok -- returns a token * * * * useage i = gettok(string) * * where i is the type * * string is the token * * note gettok uses scan, and takes care of definitions * * * * program log: * * 30-Jul-79 original code by G. Beckmann * * 18-Aug-79 modified to look for negative numbers * ************************************************************************/ integer function gettok(string) include ratfor.def character string(MAXTOKEN),defn(HUGESIZE) logical find integer scan repeat [ #a forever loop i = scan(string) gettok = i #the initial assumption if(i == LEXIDENT) #if it is an identifier if(find(string,defn)) [ #look it up if(defn(1) < 0) [ #if it is a special case gettok = defn(1)#return what was gotten break ] call pbstr(defn) #else push it back ] else if(length(string) > MAXFORVAR) #for names with more call longnm(string) else break else break ] if(gettok == LEXSPECIAL) #really a long identifier gettok = LEXIDENT else if(string(1) == MINUS) { #could be negative number if(scan(defn) == LEXNUMBER) { call concat(string,defn) gettok = LEXNUMBER } else call pbstr(defn) } return end /************************************************************************ * longnm -- handles names with more than six characters * * * * useage call longnm(str) * * where str is the ascii string containing the name * * * * coded by G Beckmann, 6-Aug-79 * * 7-Feb-80 fix in generation of longnames above 99, MSS and MAP. * ************************************************************************/ subroutine longnm(str) character str(MAXTOKEN),num(MAXTOKEN),name(MAXFORVARNAME) common/longnm/numnam #conversion number,init to 0 include flags.cmm data name/MAXFORVARNAME * DIG_0/ name(MAXFORVARNAME) = EOS numnam = numnam + 1 #calculate conversion number call ita(numnam,num) #convert it ot ascii j = length(num) #determine its length if (j > MAXFORVAR - 1) #if more than max chars allowed -1 call synerr(W_6_CH_VAR) #don't convert! else [ #put the number in place for(i = MAXFORVAR;j > 0;i = i - 1) [ name(i) = num(j) j = j - 1 ] if(str(1) == UNDERLINE) name(1) = BIG_A #force legal name else name(1) = str(1) #force the letter into place if(write_long_names) { #print out long names? write(NAME_LUN,100)(name(i),i=1,MAXFORVAR),(str(i),i=1, length(str)) 100 format(MAXFORVAR a1,2x,MAXLINE a1) } if(!instal(str,name)) #define it call synerr(W_6_CH_VAR) else call pbstr(str) #push it back and let scan find it ] return end