1: #
   2: /*
   3:  * pi - Pascal interpreter code translator
   4:  *
   5:  * Charles Haley, Bill Joy UCB
   6:  * Version 1.1 February 1978
   7:  *
   8:  *
   9:  * pxp - Pascal execution profiler
  10:  *
  11:  * Bill Joy UCB
  12:  * Version 1.1 February 1978
  13:  */
  14: 
  15: #include "y.tab.h"
  16: /*
  17:  * INPUT/OUTPUT
  18:  */
  19: 
  20: /*
  21:  * The buffer for the input file is normally "ibuf".
  22:  * When files are included, however, this may be
  23:  * pushed down in the stack of currently active
  24:  * files. For this reason, the pointer ibp always
  25:  * references the i/o buffer of the current input file.
  26:  */
  27: int ibuf[259], *ibp;
  28: 
  29: /*
  30:  * Line and token buffers.  Charbuf is the character buffer for
  31:  * input lines, token the buffer for tokens returned
  32:  * by the scanner.  CBSIZE defines the maximum line
  33:  * length allowed on input and is doubtless too small.
  34:  * The token buffer should be a local array in yylex.
  35:  */
  36: #define CBSIZE 161
  37: 
  38: char    charbuf[CBSIZE], *bufp, token[CBSIZE];
  39: 
  40: #define digit(c)    (c >= '0' && c <= '9')
  41: #define alph(c)     ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
  42: 
  43: /*
  44:  * Flag to prevent reprinting current line after
  45:  * an error.
  46:  */
  47: char    yyprtd;
  48: 
  49: /*
  50:  * The following variables are maintained by
  51:  * the scanner in the file lex and used in scanning
  52:  * and in parsing.
  53:  *
  54:  * The variable yychar is the current scanner character.
  55:  * Currently, the scanner must be called as
  56:  *	yychar = yylex()
  57:  * even though it should set yychar itself.
  58:  * Yychar has value YEOF at end of file, and negative value if
  59:  * there is no yychar, e.g. after a shift in the parser.
  60:  *
  61:  * The variable yycol is the current column in the line whose number
  62:  * is given by yyline.  Yyecol and yyeline give the position for an
  63:  * error message to flag, usually the start of an input token.
  64:  * Yylval is the semantic return from the scanner.
  65:  *
  66:  * In fact all of these variables are "per token".
  67:  * In the usual case, only the copies in the scanner token structure
  68:  * 'Y' are used, and the #defines below serve to make them look
  69:  * like variables.
  70:  *
  71:  * For the purposes of the error recovery, however, they are copied
  72:  * and restored quite freely.  For the error recovery also, the
  73:  * file name which the input line this token is on and the seek
  74:  * pointer of this line in its source file are saved as yyefile
  75:  * and yyseekp.  The global variable yylinpt is the seek pointer
  76:  * of the current input line.
  77:  */
  78: int yycol;
  79: int yyline;
  80: int yyseqid;
  81: int yysavc;
  82: int yylinpt;
  83: 
  84: /* *** NOTE ***
  85:  * It would be much better to not have the Yyeline and Yyefile
  86:  * in the scanner structure and to have a mechanism for mapping
  87:  * seqid's to these globally.
  88:  */
  89: struct yytok {
  90:     int Yychar;
  91:     int Yylval;
  92:     int Yyecol;
  93:     int Yyeline;
  94:     int Yyseekp;
  95:     char    *Yyefile;
  96:     int Yyeseqid;
  97: } Y, OY;
  98: 
  99: #define yychar  Y.Yychar
 100: #define yylval  Y.Yylval
 101: #define yyecol  Y.Yyecol
 102: #define yyeline Y.Yyeline
 103: #define yyseekp Y.Yyseekp
 104: #define yyefile Y.Yyefile
 105: #define yyeseqid Y.Yyeseqid
 106: 
 107: /*
 108:  * Yyval is the semantic value returned by a reduction.
 109:  * It is what "$$" is expanded to by yacc.
 110:  */
 111: int *Ps, *yyval;
 112: 
 113: /*
 114:  * N is the length of a reduction.
 115:  * Used externally by "lineof" to get the left and
 116:  * right margins for a reduction.
 117:  */
 118: int N;
 119: /*
 120:  * Definitions for looking up keywords.
 121:  * The keyword array is called yykey, and
 122:  * lastkey points at the end of it.
 123:  */
 124: char    *lastkey;
 125: 
 126: struct kwtab {
 127:     char    *kw_str;
 128:     int kw_val;
 129: } yykey[];
 130: 
 131: /*
 132:  * ERROR RECOVERY EXTERNALS
 133:  */
 134: 
 135: #define CLIMIT  40  /* see yyrecover.c */
 136: long    tokname();
 137: long    charname();
 138: 
 139: char    *classes[];
 140: 
 141: /*
 142:  * Tokens which yacc doesn't define
 143:  */
 144: #define YEOF    0
 145: #define ERROR   256
 146: 
 147: /*
 148:  * Limit on the number of syntax errors
 149:  */
 150: #define MAXSYNERR   100
 151: 
 152: /*
 153:  * Big costs
 154:  */
 155: #define HUGE        50
 156: #define INFINITY    100
 157: 
 158: /*
 159:  * Kinds of panics
 160:  */
 161: #define PDECL   0
 162: #define PSTAT   1
 163: #define PEXPR   2
 164: #define PPROG   3
 165: 
 166: #define yyresume()  yyResume = 1;
 167: 
 168: char    yyResume;
 169: 
 170: char    dquote;
 171: 
 172: char    errout;
 173: 
 174: /*
 175:  * Yyidwant and yyidhave are the namelist classes
 176:  * of identifiers associated with a identifier reduce
 177:  * error, set before the recovery is called.
 178:  * Since they may be set again during the forward move
 179:  * they must be saved by yyrecover, which uses them in printing
 180:  * error messages.
 181:  */
 182: int yyidhave, yyidwant;
 183: 
 184: /*
 185:  * The variables yy*shifts are used to prevent looping and the printing
 186:  * of spurious messages in the parser.  Yyshifts gives the number of
 187:  * true input shifts since the last corrective action.  YyOshifts
 188:  * is the value of yyshifts before it was last cleared, and is used
 189:  * by yyPerror in yypanic.c to suppress messages.
 190:  *
 191:  * Yytshifts counts true input shifts.  It is used to prevent looping
 192:  * inserting unique symbols.  If yytshifts == yyTshifts (local to
 193:  * yyrecover.c) then there has been no shift over true input since
 194:  * the last unique symbol insertion.  We refuse, in this case,
 195:  * to insert more unique symbols so as to prevent looping.
 196:  *
 197:  * The recovery cannot loop because it guarantees the progress of the
 198:  * parse, i.e.:
 199:  *
 200:  *	1) Any insertion guarantees to shift over 2 symbols, a replacement
 201:  *	   over one symbol.
 202:  *
 203:  *	2) Unique symbol insertions are limited to one for each true
 204:  *	   symbol of input, or "safe" insertion of the keywords "end"
 205:  *	   and "until" at zero cost (safe since these are know to match
 206:  *	   stack that cannot have been generated - e.g. "begin" or "repeat")
 207:  *
 208:  *	3) We never panic more than once from a given state without
 209:  *	   shifting over input, i.e. we force the parse stack to shrink
 210:  *	   after each unsuccessful panic.
 211:  */
 212: int yyshifts, yyOshifts;
 213: unsigned yytshifts;
 214: 
 215: #ifdef PXP
 216: 
 217: /*
 218:  * Identifier class definitions
 219:  */
 220: #define UNDEF   0
 221: #define CONST   1
 222: #define TYPE    2
 223: #define VAR 3
 224: #define ARRAY   4
 225: #define PTRFILE 5
 226: #define RECORD  6
 227: #define FIELD   7
 228: #define PROC    8
 229: #define FUNC    9
 230: #define FVAR    10
 231: #define REF 11
 232: #define PTR 12
 233: #define FILE    13
 234: #define SET 14
 235: #define RANGE   15
 236: #define LABEL   16
 237: #define WITHPTR 17
 238: #define SCAL    18
 239: #define STR 19
 240: #define PROG    20
 241: #define IMPROPER 21
 242: 
 243: /*
 244:  * COMMENT FORMATTING DEFINITIONS
 245:  */
 246: 
 247: /*
 248:  * Count of tokens on this input line
 249:  * Note that this can be off if input is not syntactically correct.
 250:  */
 251: int yytokcnt;
 252: int yywhcnt;
 253: 
 254: /*
 255:  * Types of comments
 256:  */
 257: #define CLMARG  0
 258: #define CALIGN  1
 259: #define CTRAIL  2
 260: #define CRMARG  3
 261: #define CSRMARG 4
 262: #define CNL 5
 263: #define CNLBL   6
 264: #define CFORM   7
 265: #define CINCLUD 8
 266: 
 267: /*
 268:  * Comment structure
 269:  * Cmhp is the head of the current list of comments
 270:  */
 271: struct comment {
 272:     struct  comment *cmnext;
 273:     int cmdelim;
 274:     struct  commline *cml;
 275:     int cmjust;
 276:     int cmseqid;
 277: } *cmhp;
 278: 
 279: /*
 280:  * Structure for holding a comment line
 281:  */
 282: struct commline {
 283:     char    *cmtext;
 284:     int cmcol;  /* Only used for first line of comment currently */
 285:     struct  commline *cml;
 286: };
 287: 
 288: struct W {
 289:     int Wseqid;
 290:     int Wcol;
 291: } yyw[MAXDEPTH + 1], *yypw;
 292: 
 293: #define commform()  quickcomm(CFORM)
 294: #define commnl()    quickcomm(CNL)
 295: #define commnlbl()  quickcomm(CNLBL)
 296: #endif

Defined variables

N defined in line 118; used 6 times
Y defined in line 97; used 29 times
bufp defined in line 38; used 5 times
classes defined in line 139; used 12 times
cmhp defined in line 277; used 10 times
dquote defined in line 170; used 2 times
ibp defined in line 27; used 9 times
ibuf defined in line 27; used 2 times
lastkey defined in line 124; used 2 times
yyResume defined in line 168; used 2 times
yyidhave defined in line 182; used 8 times
yyidwant defined in line 182; used 5 times
yyprtd defined in line 47; used 4 times
yysavc defined in line 81; used 11 times
yyval defined in line 111; used 3 times
yyw defined in line 291; used 1 times
yywhcnt defined in line 252; used 4 times

Defined struct's

W defined in line 288; never used
comment defined in line 271; used 14 times
commline defined in line 282; used 11 times
kwtab defined in line 126; used 4 times

Defined macros

ARRAY defined in line 224; used 1 times
CALIGN defined in line 258; used 2 times
CBSIZE defined in line 36; used 5 times
CFORM defined in line 264; used 2 times
CINCLUD defined in line 265; used 1 times
CLMARG defined in line 257; used 1 times
CNL defined in line 262; used 2 times
CNLBL defined in line 263; used 2 times
CONST defined in line 221; used 2 times
CRMARG defined in line 260; used 1 times
CSRMARG defined in line 261; never used
CTRAIL defined in line 259; used 1 times
FIELD defined in line 227; used 3 times
FILE defined in line 233; used 1 times
FUNC defined in line 229; used 1 times
FVAR defined in line 230; used 2 times
HUGE defined in line 155; never used
IMPROPER defined in line 241; used 1 times
LABEL defined in line 236; never used
MAXSYNERR defined in line 150; used 1 times
PDECL defined in line 161; used 8 times
PEXPR defined in line 163; used 4 times
PPROG defined in line 164; used 3 times
PROC defined in line 228; never used
PROG defined in line 240; never used
PSTAT defined in line 162; used 5 times
PTR defined in line 232; used 2 times
PTRFILE defined in line 225; never used
RANGE defined in line 235; never used
RECORD defined in line 226; used 1 times
REF defined in line 231; used 1 times
SCAL defined in line 238; never used
SET defined in line 234; never used
STR defined in line 239; never used
TYPE defined in line 222; never used
UNDEF defined in line 220; never used
VAR defined in line 223; used 2 times
WITHPTR defined in line 237; never used
alph defined in line 41; used 1 times
commnl defined in line 294; used 2 times
digit defined in line 40; used 7 times
yyecol defined in line 101; used 3 times
yyefile defined in line 104; used 3 times
yyeseqid defined in line 105; used 4 times
yyresume defined in line 166; never used
yyseekp defined in line 103; used 3 times

Usage of this include

Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1869
Valid CSS Valid XHTML 1.0 Strict