lex.c File Reference

#include "defs.h"
#include "tokdefs.h"
#include "p1defs.h"

Include dependency graph for lex.c:

Go to the source code of this file.

Data Structures

struct  comment_buf
struct  Inclfile
struct  Keylist
struct  Punctlist
struct  Fmtlist
struct  Dotlist

Defines

#define EOF_CHAR   26
#define BLANK   ' '
#define MYQUOTE   (2)
#define SEOF   0
#define STEOF   1
#define STINITIAL   2
#define STCONTINUE   3
#define NEWSTMT   1
#define FIRSTTOKEN   2
#define OTHERTOKEN   3
#define RETEOS   4
#define USC   (unsigned char *)
#define isalnum_(x)   anum_buf[x]
#define isalpha_(x)   (anum_buf[x] == 1)
#define COMMENT_BUF_STORE   4088

Functions

static void flush_comments Argdcl ((void))
static void putlineno (Void)
static int getcd Argdcl ((char *, int))
static void store_comment Argdcl ((char *))
int inilex (char *name)
void flline (Void)
char * lexline (int *n)
void doinclude (char *name)
LOCAL int popinclude (Void)
void p1_line_number (long line_number)
int yylex (Void)
LOCAL void contmax (Void)
LOCAL int getcds (Void)
static void bang (char *a, char *b, char *c, register char *d, register char *e)
LOCAL int getcd (register char *b, int nocont)
LOCAL void adjtoklen (int newlen)
LOCAL void crunch (Void)
LOCAL void analyz (Void)
LOCAL int getkwd (Void)
void initkey (Void)
LOCAL int hexcheck (int key)
LOCAL int gettok (Void)
static void store_comment (char *str)
static void flush_comments (Void)
void unclassifiable (Void)
void endcheck (Void)

Variables

LOCAL int stkey
static int needwkey
ftnint yystno
flag intonly
int new_dcl
LOCAL long int stno
LOCAL long int nxtstno
LOCAL int parlev
LOCAL int parseen
LOCAL int expcom
LOCAL int expeql
LOCAL char * nextch
LOCAL char * lastch
LOCAL char * nextcd = NULL
LOCAL char * endcd
LOCAL long prevlin
LOCAL long thislin
LOCAL int code
LOCAL int lexstate = NEWSTMT
LOCAL char * sbuf
LOCAL char * send
LOCAL char * shend
LOCAL int maxcont
LOCAL int nincl = 0
LOCAL long firstline
LOCAL char * infname1
LOCAL char * infname2
LOCAL char * laststb
LOCAL char * stb0
int addftnsrc
static char ** linestart
LOCAL int ncont
LOCAL char comstart [Table_size]
static char anum_buf [Table_size]
static comment_bufcbfirst
static comment_bufcbcur
static char * cbinit
static char * cbnext
static char * cblast
flag use_bs
static char * lastfile = "??"
static char * lastfile0 = "?"
static char fbuf [P1_FILENAME_MAX]
static long lastline
LOCAL struct Inclfileinclp = NULL
LOCAL struct Keylistkeystart [26]
LOCAL struct Keylistkeyend [26]
static struct Punctlist puncts []
LOCAL struct Dotlist dots []
LOCAL struct Keylist keys []
LOCAL char * stbuf [3]


Define Documentation

#define BLANK   ' '

Definition at line 41 of file lex.c.

Referenced by getcd().

#define COMMENT_BUF_STORE   4088

Definition at line 95 of file lex.c.

Referenced by store_comment().

#define EOF_CHAR   26

Definition at line 37 of file lex.c.

Referenced by getcd(), and initkey().

#define FIRSTTOKEN   2

Definition at line 54 of file lex.c.

Referenced by yylex().

#define isalnum_ ( x   )     anum_buf[x]

Definition at line 92 of file lex.c.

#define isalpha_ ( x   )     (anum_buf[x] == 1)

Definition at line 93 of file lex.c.

Referenced by analyz(), getkwd(), and gettok().

#define MYQUOTE   (2)

Definition at line 42 of file lex.c.

Referenced by analyz(), crunch(), gettok(), and unclassifiable().

#define NEWSTMT   1

Definition at line 53 of file lex.c.

Referenced by inilex(), and yylex().

#define OTHERTOKEN   3

Definition at line 55 of file lex.c.

Referenced by yylex().

#define RETEOS   4

Definition at line 56 of file lex.c.

Referenced by endcheck(), flline(), and yylex().

#define SEOF   0

Definition at line 43 of file lex.c.

Referenced by yylex().

#define STCONTINUE   3

Definition at line 49 of file lex.c.

Referenced by getcd(), and getcds().

#define STEOF   1

Definition at line 47 of file lex.c.

Referenced by getcd(), getcds(), and yylex().

#define STINITIAL   2

Definition at line 48 of file lex.c.

Referenced by getcd(), and getcds().

#define USC   (unsigned char *)

Definition at line 89 of file lex.c.

Referenced by analyz(), getkwd(), and gettok().


Function Documentation

LOCAL void adjtoklen ( int  newlen  ) 

Definition at line 1055 of file lex.c.

References maxtoklen, realloc(), and token.

Referenced by crunch().

01057 {
01058         while(maxtoklen < newlen)
01059                 maxtoklen = 2*maxtoklen + 2;
01060         if (token = (char *)realloc(token, maxtoklen))
01061                 return;
01062         fprintf(stderr, "adjtoklen: realloc(%d) failure!\n", maxtoklen);
01063         exit(2);
01064         }

Here is the call graph for this function:

Here is the caller graph for this function:

LOCAL void analyz ( Void   ) 

Definition at line 1210 of file lex.c.

References err, expcom, expeql, getkwd(), i, isalpha_, lastch, MYQUOTE, needwkey, nextch, parlev, parseen, SARITHIF, SASGOTO, sbuf, SCOMPGOTO, SDO, SGOTO, SLET, SLOGIF, stkey, SUNKNOWN, and USC.

Referenced by yylex().

01211 {
01212         register char *i;
01213 
01214         if(parlev != 0)
01215         {
01216                 err("unbalanced parentheses, statement skipped");
01217                 stkey = SUNKNOWN;
01218                 lastch = sbuf - 1; /* prevent double error msg */
01219                 return;
01220         }
01221         if(nextch+2<=lastch && nextch[0]=='i' && nextch[1]=='f' && nextch[2]=='(')
01222         {
01223                 /* assignment or if statement -- look at character after balancing paren */
01224                 parlev = 1;
01225                 for(i=nextch+3 ; i<=lastch; ++i)
01226                         if(*i == (MYQUOTE))
01227                         {
01228                                 while(*++i != MYQUOTE)
01229                                         ;
01230                         }
01231                         else if(*i == '(')
01232                                 ++parlev;
01233                         else if(*i == ')')
01234                         {
01235                                 if(--parlev == 0)
01236                                         break;
01237                         }
01238                 if(i >= lastch)
01239                         stkey = SLOGIF;
01240                 else if(i[1] == '=')
01241                         stkey = SLET;
01242                 else if( isdigit(i[1]) )
01243                         stkey = SARITHIF;
01244                 else    stkey = SLOGIF;
01245                 if(stkey != SLET)
01246                         nextch += 2;
01247         }
01248         else if(expeql) /* may be an assignment */
01249         {
01250                 if(expcom && nextch<lastch &&
01251                     nextch[0]=='d' && nextch[1]=='o')
01252                 {
01253                         stkey = SDO;
01254                         nextch += 2;
01255                 }
01256                 else    stkey = SLET;
01257         }
01258         else if (parseen && nextch + 7 < lastch
01259                         && nextch[2] != 'u' /* screen out "double..." early */
01260                         && nextch[0] == 'd' && nextch[1] == 'o'
01261                         && ((nextch[2] >= '0' && nextch[2] <= '9')
01262                                 || nextch[2] == ','
01263                                 || nextch[2] == 'w'))
01264                 {
01265                 stkey = SDO;
01266                 nextch += 2;
01267                 needwkey = 1;
01268                 }
01269         /* otherwise search for keyword */
01270         else    {
01271                 stkey = getkwd();
01272                 if(stkey==SGOTO && lastch>=nextch)
01273                         if(nextch[0]=='(')
01274                                 stkey = SCOMPGOTO;
01275                         else if(isalpha_(* USC nextch))
01276                                 stkey = SASGOTO;
01277         }
01278         parlev = 0;
01279 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void store_comment Argdcl ( (char *)   )  [static]

static int getcd Argdcl ( (char *, int  )  [static]

static void flush_comments Argdcl ( (void)   )  [static]

static void bang ( char *  a,
char *  b,
char *  c,
register char *  d,
register char *  e 
) [static]

Definition at line 671 of file lex.c.

References buf, COMMENT_BUFFER_SIZE, p, and store_comment().

Referenced by crunch(), and getcd().

00674 {
00675         char buf[COMMENT_BUFFER_SIZE + 1];
00676         register char *p, *pe;
00677 
00678         p = buf;
00679         pe = buf + COMMENT_BUFFER_SIZE;
00680         *pe = 0;
00681         while(a < b)
00682                 if (!(*p++ = *a++))
00683                         p[-1] = 0;
00684         if (b < c)
00685                 *p++ = '\t';
00686         while(d < e) {
00687                 if (!(*p++ = *d++))
00688                         p[-1] = ' ';
00689                 if (p == pe) {
00690                         store_comment(buf);
00691                         p = buf;
00692                         }
00693                 }
00694         if (p > buf) {
00695                 while(--p >= buf && *p == ' ');
00696                 p[1] = 0;
00697                 store_comment(buf);
00698                 }
00699         }

Here is the call graph for this function:

Here is the caller graph for this function:

LOCAL void contmax ( Void   ) 

Definition at line 578 of file lex.c.

References lineno, many(), maxcontin, and thislin.

Referenced by crunch(), and getcds().

00579 {
00580         lineno = thislin;
00581         many("continuation lines", 'C', maxcontin);
00582         }

Here is the call graph for this function:

Here is the caller graph for this function:

LOCAL void crunch ( Void   ) 

Definition at line 1070 of file lex.c.

References addftnsrc, adjtoklen(), bang(), contmax(), err, erri(), escapes, expcom, expeql, i, j, j1, lastch, len, linestart, maxcont, maxtoklen, MYQUOTE, needwkey, new_dcl, nextch, parlev, parseen, quote, sbuf, and shiftcase.

Referenced by yylex().

01071 {
01072         register char *i, *j, *j0, *j1, *prvstr;
01073         int k, ten, nh, nh0, quote;
01074 
01075         /* i is the next input character to be looked at
01076            j is the next output character */
01077 
01078         new_dcl = needwkey = parlev = parseen = 0;
01079         expcom = 0;     /* exposed ','s */
01080         expeql = 0;     /* exposed equal signs */
01081         j = sbuf;
01082         prvstr = sbuf;
01083         k = 0;
01084         for(i=sbuf ; i<=lastch ; ++i)
01085         {
01086                 if(isspace(*i) )
01087                         continue;
01088                 if (*i == '!') {
01089                         while(i >= linestart[k])
01090                                 if (++k >= maxcont)
01091                                         contmax();
01092                         j0 = linestart[k];
01093                         if (!addftnsrc)
01094                                 bang(sbuf,sbuf,sbuf,i+1,j0);
01095                         i = j0-1;
01096                         continue;
01097                         }
01098 
01099 /* Keep everything in a quoted string */
01100 
01101                 if(*i=='\'' ||  *i=='"')
01102                 {
01103                         int len = 0;
01104 
01105                         quote = *i;
01106                         *j = MYQUOTE; /* special marker */
01107                         for(;;)
01108                         {
01109                                 if(++i > lastch)
01110                                 {
01111                                         err("unbalanced quotes; closing quote supplied");
01112                                         if (j >= lastch)
01113                                                 j = lastch - 1;
01114                                         break;
01115                                 }
01116                                 if(*i == quote)
01117                                         if(i<lastch && i[1]==quote) ++i;
01118                                         else break;
01119                                 else if(*i=='\\' && i<lastch && use_bs) {
01120                                         ++i;
01121                                         *i = escapes[*(unsigned char *)i];
01122                                         }
01123                                 *++j = *i;
01124                                 len++;
01125                         } /* for (;;) */
01126 
01127                         if ((len = j - sbuf) > maxtoklen)
01128                                 adjtoklen(len);
01129                         j[1] = MYQUOTE;
01130                         j += 2;
01131                         prvstr = j;
01132                 }
01133                 else if( (*i=='h' || *i=='H')  && j>prvstr)     /* test for Hollerith strings */
01134                 {
01135                         j0 = j - 1;
01136                         if( ! isdigit(*j0)) goto copychar;
01137                         nh = *j0 - '0';
01138                         ten = 10;
01139                         j1 = prvstr;
01140                         if (j1 > sbuf && j1[-1] == MYQUOTE)
01141                                 --j1;
01142                         if (j1+4 < j)
01143                                 j1 = j-4;
01144                         for(;;) {
01145                                 if (j0-- <= j1)
01146                                         goto copychar;
01147                                 if( ! isdigit(*j0 ) ) break;
01148                                 nh += ten * (*j0-'0');
01149                                 ten*=10;
01150                                 }
01151 /* A Hollerith string must be preceded by a punctuation mark.
01152    '*' is possible only as repetition factor in a data statement
01153    not, in particular, in character*2h .
01154    To avoid some confusion with missing commas in FORMAT statements,
01155    treat a preceding string as a punctuation mark.
01156  */
01157 
01158                         if( !(*j0=='*'&&sbuf[0]=='d') && *j0!='/'
01159                         && *j0!='(' && *j0!=',' && *j0!='=' && *j0!='.'
01160                         && *j0 != MYQUOTE)
01161                                 goto copychar;
01162                         nh0 = nh;
01163                         if(i+nh > lastch)
01164                         {
01165                                 erri("%dH too big", nh);
01166                                 nh = lastch - i;
01167                                 nh0 = -1;
01168                         }
01169                         if (nh > maxtoklen)
01170                                 adjtoklen(nh);
01171                         j0[1] = MYQUOTE; /* special marker */
01172                         j = j0 + 1;
01173                         while(nh-- > 0)
01174                         {
01175                                 if (++i > lastch) {
01176  hol_overflow:
01177                                         if (nh0 >= 0)
01178                                           erri("escapes make %dH too big",
01179                                                 nh0);
01180                                         break;
01181                                         }
01182                                 if(*i == '\\' && use_bs) {
01183                                         if (++i > lastch)
01184                                                 goto hol_overflow;
01185                                         *i = escapes[*(unsigned char *)i];
01186                                         }
01187                                 *++j = *i;
01188                         }
01189                         j[1] = MYQUOTE;
01190                         j+=2;
01191                         prvstr = j;
01192                 }
01193                 else    {
01194                         if(*i == '(') parseen = ++parlev;
01195                         else if(*i == ')') --parlev;
01196                         else if(parlev == 0)
01197                                 if(*i == '=') expeql = 1;
01198                                 else if(*i == ',') expcom = 1;
01199 copychar:               /*not a string or space -- copy, shifting case if necessary */
01200                         if(shiftcase && isupper(*i))
01201                                 *j++ = tolower(*i);
01202                         else    *j++ = *i;
01203                 }
01204         }
01205         lastch = j - 1;
01206         nextch = sbuf;
01207 }

Here is the call graph for this function:

Here is the caller graph for this function:

void doinclude ( char *  name  ) 

Definition at line 308 of file lex.c.

References ALLOC, Alloc(), code, copyn(), diagfile, done, endcd, err_lineno, Fatal(), free(), I, Iargs, Inclfile::inclcode, Inclfile::inclfp, Inclfile::incllen, Inclfile::incllinp, Inclfile::incllno, Inclfile::inclname, Inclfile::inclnext, inclp, Inclfile::inclstno, infile, infname, j, lineno, MAXINCLUDES, nextcd, nincl, NULL, nxtstno, prevlin, putlineno(), s, t, textread, and thislin.

Referenced by inilex(), and yyparse().

00310 {
00311         FILEP fp;
00312         struct Inclfile *t;
00313         char *name0, *lastslash, *s, *s0, *temp;
00314         int j, k;
00315         chainp I;
00316         extern chainp Iargs;
00317 
00318         err_lineno = -1;
00319         if(inclp)
00320         {
00321                 inclp->incllno = thislin;
00322                 inclp->inclcode = code;
00323                 inclp->inclstno = nxtstno;
00324                 if(nextcd && (j = endcd - nextcd) > 0)
00325                         inclp->incllinp = copyn(inclp->incllen = j, nextcd);
00326                 else
00327                         inclp->incllinp = 0;
00328         }
00329         nextcd = NULL;
00330 
00331         if(++nincl >= MAXINCLUDES)
00332                 Fatal("includes nested too deep");
00333         if(name[0] == '\0')
00334                 fp = stdin;
00335         else if(name[0] == '/' || inclp == NULL
00336 #ifdef MSDOS
00337                 || name[0] == '\\'
00338                 || name[1] == ':'
00339 #endif
00340                 )
00341                 fp = fopen(name, textread);
00342         else {
00343                 lastslash = NULL;
00344                 s = s0 = inclp->inclname;
00345 #ifdef MSDOS
00346                 if (s[1] == ':')
00347                         lastslash = s + 1;
00348 #endif
00349                 for(; *s ; ++s)
00350                         if(*s == '/'
00351 #ifdef MSDOS
00352                         || *s == '\\'
00353 #endif
00354                         )
00355                                 lastslash = s;
00356                 name0 = name;
00357                 if(lastslash) {
00358                         k = lastslash - s0 + 1;
00359                         temp = Alloc(k + strlen(name) + 1);
00360                         strncpy(temp, s0, k);
00361                         strcpy(temp+k, name);
00362                         name = temp;
00363                         }
00364                 fp = fopen(name, textread);
00365                 if (!fp && (I = Iargs)) {
00366                         k = strlen(name0) + 2;
00367                         for(; I; I = I->nextp) {
00368                                 j = strlen(s = I->datap);
00369                                 name = Alloc(j + k);
00370                                 strcpy(name, s);
00371                                 switch(s[j-1]) {
00372                                         case '/':
00373 #ifdef MSDOS
00374                                         case ':':
00375                                         case '\\':
00376 #endif
00377                                                 break;
00378                                         default:
00379                                                 name[j++] = '/';
00380                                         }
00381                                 strcpy(name+j, name0);
00382                                 if (fp = fopen(name, textread)) {
00383                                         free(name0);
00384                                         goto havefp;
00385                                         }
00386                                 free(name);
00387                                 name = name0;
00388                                 }
00389                         }
00390                 }
00391         if (fp)
00392         {
00393  havefp:
00394                 t = inclp;
00395                 inclp = ALLOC(Inclfile);
00396                 inclp->inclnext = t;
00397                 prevlin = thislin = lineno = 0;
00398                 infname = inclp->inclname = name;
00399                 infile = inclp->inclfp = fp;
00400                 lastline = 0;
00401                 putlineno();
00402                 lastline = 0;
00403         }
00404         else
00405         {
00406                 fprintf(diagfile, "Cannot open file %s\n", name);
00407                 done(1);
00408         }
00409 }

Here is the call graph for this function:

Here is the caller graph for this function:

void endcheck ( Void   ) 

Definition at line 1744 of file lex.c.

References lastch, lexstate, RETEOS, and warn().

Referenced by yyparse().

01745 {
01746         if (nextch <= lastch)
01747                 warn("ignoring text after \"end\".");
01748         lexstate = RETEOS;
01749         }

Here is the call graph for this function:

Here is the caller graph for this function:

void flline ( Void   ) 

Definition at line 281 of file lex.c.

References lexstate, and RETEOS.

Referenced by setfmt(), and yyparse().

00282 {
00283         lexstate = RETEOS;
00284 }

Here is the caller graph for this function:

static void flush_comments ( Void   )  [static]

Definition at line 1700 of file lex.c.

References comment_buf::buf, cbcur, cbfirst, cbinit, cbnext, last, comment_buf::last, comment_buf::next, p1_comment(), s, and s1.

Referenced by getcds(), store_comment(), and yylex().

01701 {
01702         register char *s, *s1;
01703         register comment_buf *cb;
01704         if (cbnext == cbinit)
01705                 return;
01706         cbcur->last = cbnext;
01707         for(cb = cbfirst;; cb = cb->next) {
01708                 for(s = cb->buf; s < cb->last; s = s1) {
01709                         /* compute s1 = new s value first, since */
01710                         /* p1_comment may insert nulls into s */
01711                         s1 = s + strlen(s) + 1;
01712                         p1_comment(s);
01713                         }
01714                 if (cb == cbcur)
01715                         break;
01716                 }
01717         cbcur = cbfirst;
01718         cbnext = cbinit;
01719         cblast = cbnext + COMMENT_BUF_STORE;
01720         }

Here is the call graph for this function:

Here is the caller graph for this function:

LOCAL int getcd ( register char *  b,
int  nocont 
)

Definition at line 713 of file lex.c.

References addftnsrc, Alloc(), bang(), BLANK, COMMENT_BUFFER_SIZE, comstart, endcd, EOF_CHAR, errstr(), firstline, free(), i, infile, infname, infname1, L, laststb, lineno, NO, nxtstno, p, send, shend, stb0, STCONTINUE, STEOF, STINITIAL, store_comment(), Table_size, thislin, top, ungetc(), warn72, and YES.

Referenced by getcds().

00715 {
00716         register int c;
00717         register char *p, *bend;
00718         int speclin;            /* Special line - true when the line is allowed
00719                                    to have more than 66 characters (e.g. the
00720                                    "&" shorthand for continuation, use of a "\t"
00721                                    to skip part of the label columns) */
00722         static char a[6];       /* Statement label buffer */
00723         static char *aend       = a+6;
00724         static char *stb, *stbend;
00725         static int nst;
00726         char *atend, *endcd0;
00727         extern int warn72;
00728         char buf72[24];
00729         int amp, i;
00730         char storage[COMMENT_BUFFER_SIZE + 1];
00731         char *pointer;
00732         long L;
00733 
00734 top:
00735         endcd = b;
00736         bend = b+66;
00737         amp = speclin = NO;
00738         atend = aend;
00739 
00740 /* Handle the continuation shorthand of "&" in the first column, which stands
00741    for "     x" */
00742 
00743         if( (c = getc(infile)) == '&')
00744         {
00745                 a[0] = c;
00746                 a[1] = 0;
00747                 a[5] = 'x';
00748                 amp = speclin = YES;
00749                 bend = send;
00750                 p = aend;
00751         }
00752 
00753 /* Handle the Comment cards (a 'C', 'c', '*', or '!' in the first column). */
00754 
00755         else if(comstart[c & (Table_size-1)])
00756         {
00757                 if (feof (infile)
00758 #ifdef EOF_CHAR
00759                          || c == EOF_CHAR
00760 #endif
00761                                         )
00762                     return STEOF;
00763 
00764                 if (c == '#') {
00765                         *endcd++ = c;
00766                         while((c = getc(infile)) != '\n')
00767                                 if (c == EOF)
00768                                         return STEOF;
00769                                 else if (endcd < shend)
00770                                         *endcd++ = c;
00771                         ++thislin;
00772                         *endcd = 0;
00773                         if (b[1] == ' ')
00774                                 p = b + 2;
00775                         else if (!strncmp(b,"#line ",6))
00776                                 p = b + 6;
00777                         else {
00778  bad_cpp:
00779                                 lineno = thislin;
00780                                 errstr("Bad # line: \"%s\"", b);
00781                                 goto top;
00782                                 }
00783                         if (*p < '1' || *p > '9')
00784                                 goto bad_cpp;
00785                         L = *p - '0';
00786                         while((c = *++p) >= '0' && c <= '9')
00787                                 L = 10*L + c - '0';
00788                         while(c == ' ')
00789                                 c = *++p;
00790                         if (!c) {
00791                                 /* accept "# 1234" */
00792                                 thislin = L - 1;
00793                                 goto top;
00794                                 }
00795                         if (c != '"')
00796                                 goto bad_cpp;
00797                         bend = p;
00798                         while(*++p != '"')
00799                                 if (!*p)
00800                                         goto bad_cpp;
00801                         *p = 0;
00802                         i = p - bend++;
00803                         thislin = L - 1;
00804                         if (!infname1 || strcmp(infname1, bend)) {
00805                                 if (infname1)
00806                                         free(infname1);
00807                                 if (infname && !strcmp(infname, bend)) {
00808                                         infname1 = 0;
00809                                         goto top;
00810                                         }
00811                                 lastfile = 0;
00812                                 infname1 = Alloc(i);
00813                                 strcpy(infname1, bend);
00814                                 if (!infname) {
00815                                         infname = infname1;
00816                                         infname1 = 0;
00817                                         }
00818                                 }
00819                         goto top;
00820                         }
00821 
00822                 storage[COMMENT_BUFFER_SIZE] = c = '\0';
00823                 pointer = storage;
00824                 while( !feof (infile) && (*pointer++ = c = getc(infile)) != '\n') {
00825 
00826 /* Handle obscure end of file conditions on many machines */
00827 
00828                         if (feof (infile) && (c == '\377' || c == EOF)) {
00829                             pointer--;
00830                             break;
00831                         } /* if (feof (infile)) */
00832 
00833                         if (c == '\0')
00834                                 *(pointer - 1) = ' ';
00835 
00836                         if (pointer == &storage[COMMENT_BUFFER_SIZE]) {
00837                                 store_comment (storage);
00838                                 pointer = storage;
00839                         } /* if (pointer == BUFFER_SIZE) */
00840                 } /* while */
00841 
00842                 if (pointer > storage) {
00843                     if (c == '\n')
00844 
00845 /* Get rid of the newline */
00846 
00847                         pointer[-1] = 0;
00848                     else
00849                         *pointer = 0;
00850 
00851                     store_comment (storage);
00852                 } /* if */
00853 
00854                 if (feof (infile))
00855                     if (c != '\n')      /* To allow the line index to
00856                                            increment correctly */
00857                         return STEOF;
00858 
00859                 ++thislin;
00860                 goto top;
00861         }
00862 
00863         else if(c != EOF)
00864         {
00865 
00866 /* Load buffer   a   with the statement label */
00867 
00868                 /* a tab in columns 1-6 skips to column 7 */
00869                 ungetc(c, infile);
00870                 for(p=a; p<aend && (c=getc(infile)) != '\n' && c!=EOF; )
00871                         if(c == '\t')
00872 
00873 /* The tab character translates into blank characters in the statement label */
00874 
00875                         {
00876                                 atend = p;
00877                                 while(p < aend)
00878                                         *p++ = BLANK;
00879                                 speclin = YES;
00880                                 bend = send;
00881                         }
00882                         else
00883                                 *p++ = c;
00884         }
00885 
00886 /* By now we've read either a continuation character or the statement label
00887    field */
00888 
00889         if(c == EOF)
00890                 return(STEOF);
00891 
00892 /* The next 'if' block handles lines that have fewer than 7 characters */
00893 
00894         if(c == '\n')
00895         {
00896                 while(p < aend)
00897                         *p++ = BLANK;
00898 
00899 /* Blank out the buffer on lines which are not longer than 66 characters */
00900 
00901                 endcd0 = endcd;
00902                 if( ! speclin )
00903                         while(endcd < bend)
00904                                 *endcd++ = BLANK;
00905         }
00906         else    {       /* read body of line */
00907                 if (warn72 & 2) {
00908                         speclin = YES;
00909                         bend = send;
00910                         }
00911                 while( endcd<bend && (c=getc(infile)) != '\n' && c!=EOF )
00912                         *endcd++ = c;
00913                 if(c == EOF)
00914                         return(STEOF);
00915 
00916 /* Drop any extra characters on the input card; this usually means those after
00917    column 72 */
00918 
00919                 if(c != '\n')
00920                 {
00921                         i = 0;
00922                         while( (c=getc(infile)) != '\n' && c != EOF)
00923                                 if (i < 23 && c != '\r')
00924                                         buf72[i++] = c;
00925                         if (warn72 && i && !speclin) {
00926                                 buf72[i] = 0;
00927                                 if (i >= 23)
00928                                         strcpy(buf72+20, "...");
00929                                 lineno = thislin + 1;
00930                                 errstr("text after column 72: %s", buf72);
00931                                 }
00932                         if(c == EOF)
00933                                 return(STEOF);
00934                 }
00935 
00936                 endcd0 = endcd;
00937                 if( ! speclin )
00938                         while(endcd < bend)
00939                                 *endcd++ = BLANK;
00940         }
00941 
00942 /* The flow of control usually gets to this line (unless an earlier RETURN has
00943    been taken) */
00944 
00945         ++thislin;
00946 
00947         /* Fortran 77 specifies that a 0 in column 6 */
00948         /* does not signify continuation */
00949 
00950         if( !isspace(a[5]) && a[5]!='0') {
00951                 if (!amp)
00952                         for(p = a; p < aend;)
00953                                 if (*p++ == '!' && p != aend)
00954                                         goto initcheck;
00955                 if (addftnsrc && stb) {
00956                         if (stbend > stb + 7) { /* otherwise forget col 1-6 */
00957                                 /* kludge around funny p1gets behavior */
00958                                 *stb++ = '$';
00959                                 if (amp)
00960                                         *stb++ = '&';
00961                                 else
00962                                         for(p = a; p < atend;)
00963                                                 *stb++ = *p++;
00964                                 }
00965                         if (endcd0 - b > stbend - stb) {
00966                                 if (stb > stbend)
00967                                         stb = stbend;
00968                                 endcd0 = b + (stbend - stb);
00969                                 }
00970                         for(p = b; p < endcd0;)
00971                                 *stb++ = *p++;
00972                         *stb++ = '\n';
00973                         *stb = 0;
00974                         }
00975                 if (nocont) {
00976                         lineno = thislin;
00977                         errstr("illegal continuation card (starts \"%.6s\")",a);
00978                         }
00979                 else if (!amp && strncmp(a,"     ",5)) {
00980                         lineno = thislin;
00981                         errstr("labeled continuation line (starts \"%.6s\")",a);
00982                         }
00983                 return(STCONTINUE);
00984                 }
00985 initcheck:
00986         for(p=a; p<atend; ++p)
00987                 if( !isspace(*p) ) {
00988                         if (*p++ != '!')
00989                                 goto initline;
00990                         bang(p, atend, aend, b, endcd);
00991                         goto top;
00992                         }
00993         for(p = b ; p<endcd ; ++p)
00994                 if( !isspace(*p) ) {
00995                         if (*p++ != '!')
00996                                 goto initline;
00997                         bang(a, a, a, p, endcd);
00998                         goto top;
00999                         }
01000 
01001 /* Skip over blank cards by reading the next one right away */
01002 
01003         goto top;
01004 
01005 initline:
01006         if (!lastline)
01007                 lastline = thislin;
01008         if (addftnsrc) {
01009                 nst = (nst+1)%3;
01010                 if (!laststb && stb0)
01011                         laststb = stb0;
01012                 stb0 = stb = stbuf[nst];
01013                 *stb++ = '$';   /* kludge around funny p1gets behavior */
01014                 stbend = stb + sizeof(stbuf[0])-2;
01015                 for(p = a; p < atend;)
01016                         *stb++ = *p++;
01017                 if (atend < aend)
01018                         *stb++ = '\t';
01019                 for(p = b; p < endcd0;)
01020                         *stb++ = *p++;
01021                 *stb++ = '\n';
01022                 *stb = 0;
01023                 }
01024 
01025 /* Set   nxtstno   equal to the integer value of the statement label */
01026 
01027         nxtstno = 0;
01028         bend = a + 5;
01029         for(p = a ; p < bend ; ++p)
01030                 if( !isspace(*p) )
01031                         if(isdigit(*p))
01032                                 nxtstno = 10*nxtstno + (*p - '0');
01033                         else if (*p == '!') {
01034                                 if (!addftnsrc)
01035                                         bang(p+1,atend,aend,b,endcd);
01036                                 endcd = b;
01037                                 break;
01038                                 }
01039                         else    {
01040                                 lineno = thislin;
01041                                 errstr(
01042                                 "nondigit in statement label field \"%.5s\"", a);
01043                                 nxtstno = 0;
01044                                 break;
01045                         }
01046         firstline = thislin;
01047         return(STINITIAL);
01048 }

Here is the call graph for this function:

Here is the caller graph for this function:

LOCAL int getcds ( Void   ) 

Definition at line 590 of file lex.c.

References code, contmax(), endcd, errext(), flush_comments(), free(), getcd(), Inclfile::inclname, inclp, infname, infname1, infname2, lastch, lineno, linestart, maxcont, ncont, nextcd, nextch, noextflag, NULL, nxtstno, p, popinclude(), prevlin, sbuf, send, STCONTINUE, STEOF, STINITIAL, stno, thislin, and top.

Referenced by yylex().

00591 {
00592         register char *p, *q;
00593 
00594         flush_comments ();
00595 top:
00596         if(nextcd == NULL)
00597         {
00598                 code = getcd( nextcd = sbuf, 1 );
00599                 stno = nxtstno;
00600                 prevlin = thislin;
00601         }
00602         if(code == STEOF)
00603                 if( popinclude() )
00604                         goto top;
00605                 else
00606                         return(STEOF);
00607 
00608         if(code == STCONTINUE)
00609         {
00610                 lineno = thislin;
00611                 nextcd = NULL;
00612                 goto top;
00613         }
00614 
00615 /* Get rid of unused space at the head of the buffer */
00616 
00617         if(nextcd > sbuf)
00618         {
00619                 q = nextcd;
00620                 p = sbuf;
00621                 while(q < endcd)
00622                         *p++ = *q++;
00623                 endcd = p;
00624         }
00625 
00626 /* Be aware that the input (i.e. the string at the address   nextcd)   is NOT
00627    NULL-terminated */
00628 
00629 /* This loop merges all continuations into one long statement, AND puts the next
00630    card to be read at the end of the buffer (i.e. it stores the look-ahead card
00631    when there's room) */
00632 
00633         ncont = 0;
00634         for(;;) {
00635                 nextcd = endcd;
00636                 if (ncont >= maxcont || nextcd+66 > send)
00637                         contmax();
00638                 linestart[ncont++] = nextcd;
00639                 if ((code = getcd(nextcd,0)) != STCONTINUE)
00640                         break;
00641                 if (ncont == 20 && noextflag) {
00642                         lineno = thislin;
00643                         errext("more than 19 continuation lines");
00644                         }
00645                 }
00646         nextch = sbuf;
00647         lastch = nextcd - 1;
00648 
00649         lineno = prevlin;
00650         prevlin = thislin;
00651         if (infname2) {
00652                 free(infname);
00653                 infname = infname2;
00654                 if (inclp)
00655                         inclp->inclname = infname;
00656                 }
00657         infname2 = infname1;
00658         infname1 = 0;
00659         return(STINITIAL);
00660 }

Here is the call graph for this function:

Here is the caller graph for this function:

LOCAL int getkwd ( Void   ) 

Definition at line 1284 of file lex.c.

References errstr(), i, isalpha_, j, keyend, keystart, lastch, letter, nextch, no66flag, pend, pk, SUNKNOWN, and USC.

Referenced by analyz(), and gettok().

01285 {
01286         register char *i, *j;
01287         register struct Keylist *pk, *pend;
01288         int k;
01289 
01290         if(! isalpha_(* USC nextch) )
01291                 return(SUNKNOWN);
01292         k = letter(nextch[0]);
01293         if(pk = keystart[k])
01294                 for(pend = keyend[k] ; pk<=pend ; ++pk )
01295                 {
01296                         i = pk->keyname;
01297                         j = nextch;
01298                         while(*++i==*++j && *i!='\0')
01299                                 ;
01300                         if(*i=='\0' && j<=lastch+1)
01301                         {
01302                                 nextch = j;
01303                                 if(no66flag && pk->notinf66)
01304                                         errstr("Not a Fortran 66 keyword: %s",
01305                                             pk->keyname);
01306                                 return(pk->keyval);
01307                         }
01308                 }
01309         return(SUNKNOWN);
01310 }

Here is the call graph for this function:

Here is the caller graph for this function:

LOCAL int gettok ( Void   ) 

Definition at line 1396 of file lex.c.

References errext(), getkwd(), hexcheck(), i, isalpha_, j, lastch, MYQUOTE, n1, needkwd, new_dcl, nextch, NOEXT, noextflag, p, parlev, pp, puncts, SCONCAT, SEQ, SGE, SHOLLERITH, SLE, SLPAR, SNE, SPOWER, SRPAR, SSLASHD, token, toklen, USC, and val.

Referenced by yylex().

01397 {
01398         int havdot, havexp, havdbl;
01399         int radix, val;
01400         struct Punctlist *pp;
01401         struct Dotlist *pd;
01402         register int ch;
01403         static char     Exp_mi[] = "X**-Y treated as X**(-Y)",
01404                         Exp_pl[] = "X**+Y treated as X**(+Y)";
01405 
01406         char *i, *j, *n1, *p;
01407 
01408         ch = * USC nextch;
01409         if(ch == (MYQUOTE))
01410         {
01411                 ++nextch;
01412                 p = token;
01413                 while(*nextch != MYQUOTE)
01414                         *p++ = *nextch++;
01415                 toklen = p - token;
01416                 *p = 0;
01417                 /* allow octal, binary, hex constants of the form 'abc'x (etc.) */
01418                 if (++nextch <= lastch && isalpha_(val = * USC nextch)) {
01419                         ++nextch;
01420                         return hexcheck(val);
01421                         }
01422                 return (SHOLLERITH);
01423         }
01424 
01425         if(needkwd)
01426         {
01427                 needkwd = 0;
01428                 return( getkwd() );
01429         }
01430 
01431         for(pp=puncts; pp->punchar; ++pp)
01432                 if(ch == pp->punchar) {
01433                         val = pp->punval;
01434                         if (++nextch <= lastch)
01435                             switch(ch) {
01436                                 case '/':
01437                                         switch(*nextch) {
01438                                           case '/':
01439                                                 nextch++;
01440                                                 val = SCONCAT;
01441                                                 break;
01442                                           case '=':
01443                                                 goto sne;
01444                                           default:
01445                                                 if (new_dcl && parlev == 0)
01446                                                         val = SSLASHD;
01447                                           }
01448                                         return val;
01449                                 case '*':
01450                                         if (*nextch == '*') {
01451                                                 nextch++;
01452                                                 if (noextflag
01453                                                  && nextch <= lastch)
01454                                                         switch(*nextch) {
01455                                                           case '-':
01456                                                                 errext(Exp_mi);
01457                                                                 break;
01458                                                           case '+':
01459                                                                 errext(Exp_pl);
01460                                                                 }
01461                                                 return SPOWER;
01462                                                 }
01463                                         break;
01464                                 case '<':
01465                                         switch(*nextch) {
01466                                           case '=':
01467                                                 nextch++;
01468                                                 val = SLE;
01469                                                 break;
01470                                           case '>':
01471  sne:
01472                                                 nextch++;
01473                                                 val = SNE;
01474                                           }
01475                                         goto extchk;
01476                                 case '=':
01477                                         if (*nextch == '=') {
01478                                                 nextch++;
01479                                                 val = SEQ;
01480                                                 goto extchk;
01481                                                 }
01482                                         break;
01483                                 case '>':
01484                                         if (*nextch == '=') {
01485                                                 nextch++;
01486                                                 val = SGE;
01487                                                 }
01488  extchk:
01489                                         NOEXT("Fortran 8x comparison operator");
01490                                         return val;
01491                                 }
01492                         else if (ch == '/' && new_dcl && parlev == 0)
01493                                 return SSLASHD;
01494                         switch(val) {
01495                                 case SLPAR:
01496                                         ++parlev;
01497                                         break;
01498                                 case SRPAR:
01499                                         --parlev;
01500                                 }
01501                         return(val);
01502                         }
01503         if(ch == '.')
01504                 if(nextch >= lastch) goto badchar;
01505                 else if(isdigit(nextch[1])) goto numconst;
01506                 else    {
01507                         for(pd=dots ; (j=pd->dotname) ; ++pd)
01508                         {
01509                                 for(i=nextch+1 ; i<=lastch ; ++i)
01510                                         if(*i != *j) break;
01511                                         else if(*i != '.') ++j;
01512                                         else    {
01513                                                 nextch = i+1;
01514                                                 return(pd->dotval);
01515                                         }
01516                         }
01517                         goto badchar;
01518                 }
01519         if( isalpha_(ch) )
01520         {
01521                 p = token;
01522                 *p++ = *nextch++;
01523                 while(nextch<=lastch)
01524                         if( isalnum_(* USC nextch) )
01525                                 *p++ = *nextch++;
01526                         else break;
01527                 toklen = p - token;
01528                 *p = 0;
01529                 if (needwkey) {
01530                         needwkey = 0;
01531                         if (toklen == 5
01532                                 && nextch <= lastch && *nextch == '(' /*)*/
01533                                 && !strcmp(token,"while"))
01534                         return(SWHILE);
01535                         }
01536                 if(inioctl && nextch<=lastch && *nextch=='=')
01537                 {
01538                         ++nextch;
01539                         return(SNAMEEQ);
01540                 }
01541                 if(toklen>8 && eqn(8,token,"function")
01542                 && isalpha_(* USC (token+8)) &&
01543                     nextch<lastch && nextch[0]=='(' &&
01544                     (nextch[1]==')' || isalpha_(* USC (nextch+1))) )
01545                 {
01546                         nextch -= (toklen - 8);
01547                         return(SFUNCTION);
01548                 }
01549 
01550                 if(toklen > MAXNAMELEN)
01551                 {
01552                         char buff[2*MAXNAMELEN+50];
01553                         if (toklen >= MAXNAMELEN+10)
01554                             sprintf(buff,
01555                                 "name %.*s... too long, truncated to %.*s",
01556                                 MAXNAMELEN+6, token, MAXNAMELEN, token);
01557                         else
01558                             sprintf(buff,
01559                                 "name %s too long, truncated to %.*s",
01560                                 token, MAXNAMELEN, token);
01561                         err(buff);
01562                         toklen = MAXNAMELEN;
01563                         token[MAXNAMELEN] = '\0';
01564                 }
01565                 if(toklen==1 && *nextch==MYQUOTE) {
01566                         val = token[0];
01567                         ++nextch;
01568                         for(p = token ; *nextch!=MYQUOTE ; )
01569                                 *p++ = *nextch++;
01570                         ++nextch;
01571                         toklen = p - token;
01572                         *p = 0;
01573                         return hexcheck(val);
01574                 }
01575                 return(SNAME);
01576         }
01577 
01578         if (isdigit(ch)) {
01579 
01580                 /* Check for NAG's special hex constant */
01581 
01582                 if (nextch[1] == '#' && nextch < lastch
01583                 ||  nextch[2] == '#' && isdigit(nextch[1])
01584                                      && lastch - nextch >= 2) {
01585 
01586                     radix = atoi (nextch);
01587                     if (*++nextch != '#')
01588                         nextch++;
01589                     if (radix != 2 && radix != 8 && radix != 16) {
01590                         erri("invalid base %d for constant, defaulting to hex",
01591                                 radix);
01592                         radix = 16;
01593                     } /* if */
01594                     if (++nextch > lastch)
01595                         goto badchar;
01596                     for (p = token; hextoi(*nextch) < radix;) {
01597                         *p++ = *nextch++;
01598                         if (nextch > lastch)
01599                                 break;
01600                         }
01601                     toklen = p - token;
01602                     *p = 0;
01603                     return (radix == 16) ? SHEXCON : ((radix == 8) ? SOCTCON :
01604                             SBITCON);
01605                     }
01606                 }
01607         else
01608                 goto badchar;
01609 numconst:
01610         havdot = NO;
01611         havexp = NO;
01612         havdbl = NO;
01613         for(n1 = nextch ; nextch<=lastch ; ++nextch)
01614         {
01615                 if(*nextch == '.')
01616                         if(havdot) break;
01617                         else if(nextch+2<=lastch && isalpha_(* USC (nextch+1))
01618                             && isalpha_(* USC (nextch+2)))
01619                                 break;
01620                         else    havdot = YES;
01621                 else if( ! isdigit(* USC nextch) ) {
01622                         if( !intonly && (*nextch=='d' || *nextch=='e') ) {
01623                                 p = nextch;
01624                                 havexp = YES;
01625                                 if(*nextch == 'd')
01626                                         havdbl = YES;
01627                                 if(nextch<lastch)
01628                                         if(nextch[1]=='+' || nextch[1]=='-')
01629                                                 ++nextch;
01630                                 if( ! isdigit(*++nextch) ) {
01631                                         nextch = p;
01632                                         havdbl = havexp = NO;
01633                                         break;
01634                                         }
01635                                 for(++nextch ;
01636                                     nextch<=lastch && isdigit(* USC nextch);
01637                                     ++nextch);
01638                                 }
01639                         break;
01640                         }
01641         }
01642         p = token;
01643         i = n1;
01644         while(i < nextch)
01645                 *p++ = *i++;
01646         toklen = p - token;
01647         *p = 0;
01648         if(havdbl) return(SDCON);
01649         if(havdot || havexp) return(SRCON);
01650         return(SICON);
01651 badchar:
01652         sbuf[0] = *nextch++;
01653         return(SUNKNOWN);
01654 }

Here is the call graph for this function:

Here is the caller graph for this function:

LOCAL int hexcheck ( int  key  ) 

Definition at line 1352 of file lex.c.

References err, errstr(), hextoi, p, SBITCON, SHEXCON, SNAME, SOCTCON, and token.

Referenced by gettok().

01354 {
01355         register int radix;
01356         register char *p;
01357         char *kind;
01358 
01359         switch(key) {
01360                 case 'z':
01361                 case 'Z':
01362                 case 'x':
01363                 case 'X':
01364                         radix = 16;
01365                         key = SHEXCON;
01366                         kind = "hexadecimal";
01367                         break;
01368                 case 'o':
01369                 case 'O':
01370                         radix = 8;
01371                         key = SOCTCON;
01372                         kind = "octal";
01373                         break;
01374                 case 'b':
01375                 case 'B':
01376                         radix = 2;
01377                         key = SBITCON;
01378                         kind = "binary";
01379                         break;
01380                 default:
01381                         err("bad bit identifier");
01382                         return(SNAME);
01383                 }
01384         for(p = token; *p; p++)
01385                 if (hextoi(*p) >= radix) {
01386                         errstr("invalid %s character", kind);
01387                         break;
01388                         }
01389         return key;
01390         }

Here is the call graph for this function:

Here is the caller graph for this function:

int inilex ( char *  name  ) 

Definition at line 264 of file lex.c.

References Alloc(), doinclude(), inclp, lexstate, NEWSTMT, nincl, NO, NULL, and P1_STMTBUFSIZE.

Referenced by main().

00266 {
00267         stbuf[0] = Alloc(3*P1_STMTBUFSIZE);
00268         stbuf[1] = stbuf[0] + P1_STMTBUFSIZE;
00269         stbuf[2] = stbuf[1] + P1_STMTBUFSIZE;
00270         nincl = 0;
00271         inclp = NULL;
00272         doinclude(name);
00273         lexstate = NEWSTMT;
00274         return(NO);
00275 }

Here is the call graph for this function:

Here is the caller graph for this function:

void initkey ( Void   ) 

Definition at line 1313 of file lex.c.

References anum_buf, ckalloc(), comstart, EOF_CHAR, i, j, keyend, keys, keystart, letter, linestart, MAX_SHARPLINE_LEN, maxcont, maxcontin, NULL, p, s, sbuf, send, and shend.

Referenced by main().

01314 {
01315         register struct Keylist *p;
01316         register int i,j;
01317         register char *s;
01318 
01319         for(i = 0 ; i<26 ; ++i)
01320                 keystart[i] = NULL;
01321 
01322         for(p = keys ; p->keyname ; ++p) {
01323                 j = letter(p->keyname[0]);
01324                 if(keystart[j] == NULL)
01325                         keystart[j] = p;
01326                 keyend[j] = p;
01327                 }
01328         i = (maxcontin + 2) * 66;
01329         sbuf = (char *)ckalloc(i + 70 + MAX_SHARPLINE_LEN);
01330         send = sbuf + i;
01331         shend = send + MAX_SHARPLINE_LEN;
01332         maxcont = maxcontin + 1;
01333         linestart = (char **)ckalloc(maxcont*sizeof(char*));
01334         comstart['c'] = comstart['C'] = comstart['*'] = comstart['!'] =
01335         comstart['#'] = 1;
01336 #ifdef EOF_CHAR
01337         comstart[EOF_CHAR] = 1;
01338 #endif
01339         s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
01340         while(i = *s++)
01341                 anum_buf[i] = 1;
01342         s = "0123456789";
01343         while(i = *s++)
01344                 anum_buf[i] = 2;
01345         }

Here is the call graph for this function:

Here is the caller graph for this function:

char* lexline ( int n  ) 

Definition at line 293 of file lex.c.

References lastch, and nextch.

Referenced by setfmt().

00295 {
00296         *n = (lastch - nextch) + 1;
00297         return(nextch);
00298 }

Here is the caller graph for this function:

void p1_line_number ( long  line_number  ) 

Definition at line 463 of file lex.c.

References lastfile0, P1_FILENAME, P1_SET_LINE, p1puts(), and pass1_file.

Referenced by enddcl(), and putlineno().

00465 {
00466         if (lastfile != lastfile0) {
00467                 p1puts(P1_FILENAME, fbuf);
00468                 lastfile0 = lastfile;
00469                 }
00470         fprintf(pass1_file, "%d: %ld\n", P1_SET_LINE, line_number);
00471         }

Here is the call graph for this function:

Here is the caller graph for this function:

LOCAL int popinclude ( Void   ) 

Definition at line 415 of file lex.c.

References clf(), code, endcd, err_lineno, free(), Inclfile::inclnext, inclp, infile, infname, lineno, nextcd, nincl, NO, NULL, nxtstno, p, prevlin, putlineno(), sbuf, stno, t, thislin, and YES.

Referenced by getcds().

00416 {
00417         struct Inclfile *t;
00418         register char *p;
00419         register int k;
00420 
00421         if(infile != stdin)
00422                 clf(&infile, infname, 1);       /* Close the input file */
00423         free(infname);
00424 
00425         --nincl;
00426         err_lineno = -1;
00427         t = inclp->inclnext;
00428         free( (charptr) inclp);
00429         inclp = t;
00430         if(inclp == NULL) {
00431                 infname = 0;
00432                 return(NO);
00433                 }
00434 
00435         infile = inclp->inclfp;
00436         infname = inclp->inclname;
00437         lineno = prevlin = thislin = inclp->incllno;
00438         code = inclp->inclcode;
00439         stno = nxtstno = inclp->inclstno;
00440         if(inclp->incllinp)
00441         {
00442                 lastline = 0;
00443                 putlineno();
00444                 lastline = lineno;
00445                 endcd = nextcd = sbuf;
00446                 k = inclp->incllen;
00447                 p = inclp->incllinp;
00448                 while(--k >= 0)
00449                         *endcd++ = *p++;
00450                 free( (charptr) (inclp->incllinp) );
00451         }
00452         else
00453                 nextcd = NULL;
00454         return(YES);
00455 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void putlineno ( Void   )  [static]

Definition at line 474 of file lex.c.

References addftnsrc, firstline, gflag, infname, laststb, P1_FORTRAN, p1_line_number(), p1puts(), s1, and stb0.

Referenced by doinclude(), popinclude(), and yylex().

00475 {
00476         extern int gflag;
00477         register char *s0, *s1;
00478 
00479         if (gflag) {
00480                 if (lastline)
00481                         p1_line_number(lastline);
00482                 lastline = firstline;
00483                 if (lastfile != infname)
00484                         if (lastfile = infname) {
00485                                 strncpy(fbuf, lastfile, sizeof(fbuf));
00486                                 fbuf[sizeof(fbuf)-1] = 0;
00487                                 }
00488                         else
00489                                 fbuf[0] = 0;
00490                 }
00491         if (addftnsrc) {
00492                 if (laststb && *laststb) {
00493                         for(s1 = laststb; *s1; s1++) {
00494                                 for(s0 = s1; *s1 != '\n'; s1++)
00495                                         if (*s1 == '*' && s1[1] == '/')
00496                                                 *s1 = '+';
00497                                 *s1 = 0;
00498                                 p1puts(P1_FORTRAN, s0);
00499                                 }
00500                         *laststb = 0;   /* prevent trouble after EOF */
00501                         }
00502                 laststb = stb0;
00503                 }
00504         }

Here is the call graph for this function:

Here is the caller graph for this function:

static void store_comment ( char *  str  )  [static]

Definition at line 1663 of file lex.c.

References Alloc(), comment_buf::buf, cbcur, cbfirst, cbinit, cblast, cbnext, COMMENT_BUF_STORE, flush_comments(), comment_buf::last, len, comment_buf::next, nextcd, p1_comment(), and sbuf.

Referenced by bang(), and getcd().

01665 {
01666         int len;
01667         comment_buf *ncb;
01668 
01669         if (nextcd == sbuf) {
01670                 flush_comments();
01671                 p1_comment(str);
01672                 return;
01673                 }
01674         len = strlen(str) + 1;
01675         if (cbnext + len > cblast) {
01676                 ncb = 0;
01677                 if (cbcur) {
01678                         cbcur->last = cbnext;
01679                         ncb = cbcur->next;
01680                         }
01681                 if (!ncb) {
01682                         ncb = (comment_buf *) Alloc(sizeof(comment_buf));
01683                         if (cbcur)
01684                                 cbcur->next = ncb;
01685                         else {
01686                                 cbfirst = ncb;
01687                                 cbinit = ncb->buf;
01688                                 }
01689                         ncb->next = 0;
01690                         }
01691                 cbcur = ncb;
01692                 cbnext = ncb->buf;
01693                 cblast = cbnext + COMMENT_BUF_STORE;
01694                 }
01695         strcpy(cbnext, str);
01696         cbnext += len;
01697         }

Here is the call graph for this function:

Here is the caller graph for this function:

void unclassifiable ( Void   ) 

Definition at line 1723 of file lex.c.

References errstr(), lastch, MYQUOTE, s, and sbuf.

Referenced by yyparse().

01724 {
01725         register char *s, *se;
01726 
01727         s = sbuf;
01728         se = lastch;
01729         if (se < sbuf)
01730                 return;
01731         lastch = s - 1;
01732         if (++se - s > 10)
01733                 se = s + 10;
01734         for(; s < se; s++)
01735                 if (*s == MYQUOTE) {
01736                         se = s;
01737                         break;
01738                         }
01739         *se = 0;
01740         errstr("unclassifiable statement (starts \"%s\")", sbuf);
01741         }

Here is the call graph for this function:

Here is the caller graph for this function:

int yylex ( Void   ) 

Definition at line 507 of file lex.c.

References analyz(), crunch(), fatali(), first, FIRSTTOKEN, flush_comments(), getcds(), gettok(), intonly, lastch, lexstate, NEWSTMT, nextch, nxtstno, OTHERTOKEN, parlev, putlineno(), RETEOS, retval(), SASSIGN, SDO, SELSEIF, SEOF, SEOS, SLABEL, SLOGIF, STEOF, stkey, stno, STO, toklen, and yystno.

Referenced by yylex1().

00508 {
00509         static int  tokno;
00510         int retval;
00511 
00512         switch(lexstate)
00513         {
00514         case NEWSTMT :  /* need a new statement */
00515                 retval = getcds();
00516                 putlineno();
00517                 if(retval == STEOF) {
00518                         retval = SEOF;
00519                         break;
00520                 } /* if getcds() == STEOF */
00521                 crunch();
00522                 tokno = 0;
00523                 lexstate = FIRSTTOKEN;
00524                 yystno = stno;
00525                 stno = nxtstno;
00526                 toklen = 0;
00527                 retval = SLABEL;
00528                 break;
00529 
00530 first:
00531         case FIRSTTOKEN :       /* first step on a statement */
00532                 analyz();
00533                 lexstate = OTHERTOKEN;
00534                 tokno = 1;
00535                 retval = stkey;
00536                 break;
00537 
00538         case OTHERTOKEN :       /* return next token */
00539                 if(nextch > lastch)
00540                         goto reteos;
00541                 ++tokno;
00542                 if( (stkey==SLOGIF || stkey==SELSEIF) && parlev==0 && tokno>3)
00543                         goto first;
00544 
00545                 if(stkey==SASSIGN && tokno==3 && nextch<lastch &&
00546                     nextch[0]=='t' && nextch[1]=='o')
00547                 {
00548                         nextch+=2;
00549                         retval = STO;
00550                         break;
00551                 }
00552                 if (tokno == 2 && stkey == SDO) {
00553                         intonly = 1;
00554                         retval = gettok();
00555                         intonly = 0;
00556                         }
00557                 else
00558                         retval = gettok();
00559                 break;
00560 
00561 reteos:
00562         case RETEOS:
00563                 lexstate = NEWSTMT;
00564                 retval = SEOS;
00565                 break;
00566         default:
00567                 fatali("impossible lexstate %d", lexstate);
00568                 break;
00569         }
00570 
00571         if (retval == SEOF)
00572             flush_comments ();
00573 
00574         return retval;
00575 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int addftnsrc

Definition at line 79 of file main.c.

Referenced by crunch(), getcd(), and putlineno().

char anum_buf[Table_size] [static]

Definition at line 91 of file lex.c.

Referenced by initkey().

comment_buf * cbcur [static]

Definition at line 102 of file lex.c.

Referenced by flush_comments(), and store_comment().

comment_buf* cbfirst [static]

Definition at line 102 of file lex.c.

Referenced by flush_comments(), and store_comment().

char* cbinit [static]

Definition at line 103 of file lex.c.

Referenced by flush_comments(), and store_comment().

char * cblast [static]

Definition at line 103 of file lex.c.

Referenced by store_comment().

char * cbnext [static]

Definition at line 103 of file lex.c.

Referenced by flush_comments(), and store_comment().

LOCAL int code

Definition at line 76 of file lex.c.

Referenced by doinclude(), example3(), FindLanguageCode(), GetBasType(), getcds(), GetForType(), is_dead_key(), LWZReadByte_(), MChoicePage(), MDialogPage(), popinclude(), putcxeq(), SendScilabJob(), SGetCDec(), SGetForDec(), SGetForType(), SGetForTypeAbrev(), SGetForTypeBConvert(), SGetForTypeStack(), SGetSciType(), troisieme_exemple(), and x_render_char().

LOCAL char comstart[Table_size]

Definition at line 88 of file lex.c.

Referenced by getcd(), and initkey().

LOCAL struct Dotlist dots[]

Initial value:

{
        "and.", SAND,
            "or.", SOR,
            "not.", SNOT,
            "true.", STRUE,
            "false.", SFALSE,
            "eq.", SEQ,
            "ne.", SNE,
            "lt.", SLT,
            "le.", SLE,
            "gt.", SGT,
            "ge.", SGE,
            "neqv.", SNEQV,
            "eqv.", SEQV,
            0, 0 }

Definition at line 175 of file lex.c.

LOCAL char* endcd

Definition at line 73 of file lex.c.

Referenced by doinclude(), getcd(), getcds(), and popinclude().

LOCAL int expcom

Definition at line 68 of file lex.c.

Referenced by analyz(), and crunch().

LOCAL int expeql

Definition at line 69 of file lex.c.

Referenced by analyz(), and crunch().

char fbuf[P1_FILENAME_MAX] [static]

Definition at line 107 of file lex.c.

LOCAL long firstline

Definition at line 83 of file lex.c.

Referenced by getcd(), and putlineno().

LOCAL struct Inclfile* inclp = NULL

Definition at line 136 of file lex.c.

Referenced by doinclude(), getcds(), inilex(), and popinclude().

LOCAL char* infname1

Definition at line 84 of file lex.c.

Referenced by getcd(), and getcds().

LOCAL char * infname2

Definition at line 84 of file lex.c.

Referenced by getcds().

flag intonly

Definition at line 62 of file lex.c.

Referenced by yylex(), and yyparse().

LOCAL struct Keylist * keyend[26]

Definition at line 154 of file lex.c.

Referenced by getkwd(), and initkey().

LOCAL struct Keylist keys[]

Definition at line 192 of file lex.c.

Referenced by initkey().

LOCAL struct Keylist* keystart[26]

Definition at line 154 of file lex.c.

Referenced by getkwd(), and initkey().

LOCAL char* lastch

Definition at line 71 of file lex.c.

Referenced by analyz(), crunch(), endcheck(), getcds(), getkwd(), gettok(), lexline(), unclassifiable(), and yylex().

char* lastfile = "??" [static]

Definition at line 106 of file lex.c.

char * lastfile0 = "?" [static]

Definition at line 106 of file lex.c.

Referenced by p1_line_number().

long lastline [static]

Definition at line 108 of file lex.c.

LOCAL char * laststb

Definition at line 84 of file lex.c.

Referenced by getcd(), and putlineno().

LOCAL int lexstate = NEWSTMT

Definition at line 77 of file lex.c.

Referenced by endcheck(), flline(), inilex(), and yylex().

char** linestart [static]

Definition at line 86 of file lex.c.

Referenced by crunch(), getcds(), and initkey().

LOCAL int maxcont

Definition at line 81 of file lex.c.

Referenced by crunch(), getcds(), and initkey().

LOCAL int ncont

Definition at line 87 of file lex.c.

Referenced by contourI(), getcds(), and PaintTriangle().

int needwkey [static]

Definition at line 60 of file lex.c.

Referenced by analyz(), and crunch().

int new_dcl

Definition at line 111 of file gram.c.

Referenced by crunch(), gettok(), and yyparse().

LOCAL char* nextcd = NULL

Definition at line 72 of file lex.c.

Referenced by doinclude(), getcds(), popinclude(), and store_comment().

LOCAL char* nextch

Definition at line 70 of file lex.c.

Referenced by analyz(), crunch(), getcds(), getkwd(), gettok(), lexline(), and yylex().

LOCAL int nincl = 0

Definition at line 82 of file lex.c.

Referenced by doinclude(), inilex(), and popinclude().

LOCAL long int nxtstno

Definition at line 65 of file lex.c.

Referenced by doinclude(), getcd(), getcds(), popinclude(), and yylex().

LOCAL int parlev

Definition at line 66 of file lex.c.

Referenced by analyz(), crunch(), gettok(), and yylex().

LOCAL int parseen

Definition at line 67 of file lex.c.

Referenced by analyz(), and crunch().

LOCAL long prevlin

Definition at line 74 of file lex.c.

Referenced by doinclude(), getcds(), and popinclude().

struct Punctlist puncts[] [static]

Initial value:

{
        '(', SLPAR,
        ')', SRPAR,
        '=', SEQUALS,
        ',', SCOMMA,
        '+', SPLUS,
        '-', SMINUS,
        '*', SSTAR,
        '/', SSLASH,
        '$', SCURRENCY,
        ':', SCOLON,
        '<', SLT,
        '>', SGT,
        0, 0 }

Definition at line 159 of file lex.c.

Referenced by gettok().

LOCAL char* sbuf

Definition at line 78 of file lex.c.

Referenced by analyz(), crunch(), getcds(), initkey(), popinclude(), store_comment(), and unclassifiable().

LOCAL char* send

Definition at line 79 of file lex.c.

Referenced by getcd(), getcds(), and initkey().

LOCAL char* shend

Definition at line 80 of file lex.c.

Referenced by getcd(), and initkey().

LOCAL char * stb0

Definition at line 84 of file lex.c.

Referenced by getcd(), and putlineno().

LOCAL char* stbuf[3]

Definition at line 257 of file lex.c.

LOCAL int stkey

Definition at line 59 of file lex.c.

Referenced by analyz(), and yylex().

LOCAL long int stno

Definition at line 64 of file lex.c.

Referenced by exassign(), getcds(), popinclude(), and yylex().

LOCAL long thislin

Definition at line 75 of file lex.c.

Referenced by contmax(), doinclude(), getcd(), getcds(), and popinclude().

flag use_bs

Definition at line 49 of file main.c.

ftnint yystno

Definition at line 61 of file lex.c.

Referenced by yylex(), and yyparse().


Generated on Sun Mar 4 15:08:40 2007 for Scilab [trunk] by  doxygen 1.5.1