1: /*
   2:  * Copyright (c) 1982 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)asscanl.h	5.1 (Berkeley) 4/30/85
   7:  */
   8: 
   9: /*
  10:  *	This file contains definitions local to the files implementing
  11:  *	the character scanner and the token buffer managers.
  12:  *	It is not intended to be shared with any other parts of the
  13:  *	assembler.
  14:  *	The file ``asscan.h'' is shared with other parts of the assembler
  15:  */
  16: #include <stdio.h>
  17: #include "as.h"
  18: #include "asscan.h"
  19: 
  20: #define EOFCHAR (-1)
  21: /*
  22:  *	The table of possible uses for each character to test set inclusion.
  23:  */
  24: #define HEXFLAG     01      /* 'x' or 'X' */
  25: #define HEXLDIGIT   02      /* 'a' .. 'f' */
  26: #define HEXUDIGIT   04      /* 'A' .. 'F' */
  27: #define ALPHA       010     /* 'A' .. 'Z', 'a' .. 'z', '_'*/
  28: #define DIGIT       020     /* '0' .. '9' */
  29: #define FLOATEXP    040     /* 'd' 'e' 'D' 'E' 'g' 'h' 'G' 'H' */
  30: #define SIGN        0100        /* '+' .. '-'*/
  31: #define REGDIGIT    0200        /* '0' .. '5' */
  32: #define SZSPECBEGIN 0400        /* 'b', 'B', 'l', 'L', 'w', 'W' */
  33: #define POINT       01000       /* '.' */
  34: #define SPACE       02000       /* '\t' or ' ' */
  35: #define BSESCAPE    04000       /* bnrtf */
  36: #define STRESCAPE   010000      /* '"', '\\', '\n' */
  37: #define OCTDIGIT    020000      /* '0' .. '7' */
  38: #define FLOATFLAG   040000      /* 'd', 'D', 'f', 'F' */
  39: 
  40: #define INCHARSET(val, kind) (charsets[val] & (kind) )
  41: /*
  42:  *	We use our own version of getchar/ungetc to get
  43:  *	some speed improvement
  44:  */
  45: extern  char    *Ginbufptr;
  46: extern  int Ginbufcnt;
  47: #define REGTOMEMBUF Ginbufptr = inbufptr, Ginbufcnt = inbufcnt
  48: #define MEMTOREGBUF inbufptr = Ginbufptr, inbufcnt = Ginbufcnt
  49: #undef getchar
  50: #define getchar() \
  51:     (inbufcnt-- > 0 ? (*inbufptr++) : \
  52:         (fillinbuffer(), \
  53:         MEMTOREGBUF, \
  54:         inbufptr[-1]))
  55: #undef ungetc
  56: #define ungetc(ch) \
  57:     (++inbufcnt, *--inbufptr = ch)
  58: 
  59: /*
  60:  *	Variables and definitions to manage the token buffering.
  61:  *	We scan (lexically analyze) a large number of tokens, and
  62:  *	then parse all of the tokens in the scan buffer.
  63:  *	This reduces procedure call overhead when the parser
  64:  *	demands a token, allows for an efficient reread during
  65:  *	the second pass, and confuses the line number reporting
  66:  *	for errors encountered in the scanner and in the parser.
  67:  */
  68: #define TOKDALLOP   8
  69: struct  tokbufdesc *bufstart;   /*where the buffer list begins*/
  70: struct  tokbufdesc *buftail;    /*last one on the list*/
  71: struct  tokbufdesc *emptybuf;   /*the one being filled*/
  72: /*
  73:  *	If we are using VM, during the second pass we reclaim the used
  74:  *	token buffers for saving the relocation information
  75:  */
  76: struct  tokbufdesc *tok_free;   /* free pool */
  77: struct  tokbufdesc *tok_temp;   /* temporary for doing list manipulation */
  78: /*
  79:  *	Other token buffer managers
  80:  */
  81: int bufno;          /*which buffer number: 0,1 for tmp file*/
  82: struct  tokbufdesc tokbuf[2];   /*our initial increment of buffers*/
  83: ptrall  tokptr;         /*where the current token comes from*/
  84: ptrall  tokub;          /*the last token in the current token buffer*/
  85: /*
  86:  *	as does not use fread and fwrite for the token buffering.
  87:  *	The token buffers are integrals of BUFSIZ
  88:  *	at all times, so we use direct read and write.
  89:  *	fread and fwrite in stdio are HORRENDOUSLY inefficient,
  90:  *	as they use putchar for each character, nested two deep in loops.
  91:  */
  92: #define writeTEST(pointer, size, nelements, ioptr) \
  93:     write(ioptr->_file, pointer, nelements * size) != nelements * size
  94: 
  95: #define readTEST(pointer, size, nelements, ioptr) \
  96:     read(ioptr->_file, pointer, nelements * size) != nelements * size
  97: 
  98: #define bskiplg(from, length) \
  99:     *(lgtype *)from = length; \
 100:     (bytetoktype *)from += sizeof(lgtype) + length
 101: 
 102: #define bskipfromto(from, to) \
 103:     *(lgtype *)from = (bytetoktype *)to - (bytetoktype *)from - sizeof(lgtype); \
 104:     (bytetoktype *)from += sizeof (lgtype) + (bytetoktype *)to - (bytetoktype *)from
 105: 
 106: #define eatskiplg(from) \
 107:     (bytetoktype *)from += sizeof(lgtype) + *(lgtype *)from
 108: 
 109: #ifdef DEBUG
 110:     ptrall  firsttoken;
 111: #endif DEBUG
 112: 
 113: /*
 114:  *	The following three variables are the slots for global
 115:  *	communication with the parser.
 116:  *	They are the semantic values associated with a particular token.
 117:  *	The token itself is the return value from yylex()
 118:  */
 119: int yylval;         /* normal semantic value */
 120: Bignum  yybignum;       /* a big number */
 121: struct  Opcode  yyopcode;   /* a structure opcode */
 122: 
 123: int newfflag;
 124: char    *newfname;
 125: int scanlineno;     /*the scanner's linenumber*/
 126: 
 127: /*
 128:  *	Definitions for sets of characters
 129:  */
 130: readonly short charsets[];
 131: readonly short type[];

Defined variables

bufno defined in line 81; used 11 times
bufstart defined in line 69; used 2 times
buftail defined in line 70; used 6 times
charsets defined in line 130; used 1 times
  • in line 40
emptybuf defined in line 71; used 27 times
firsttoken defined in line 110; used 2 times
newfflag defined in line 123; used 3 times
newfname defined in line 124; used 3 times
scanlineno defined in line 125; used 7 times
tok_free defined in line 76; used 4 times
tok_temp defined in line 77; used 3 times
tokbuf defined in line 82; used 12 times
tokptr defined in line 83; used 3 times
tokub defined in line 84; used 3 times
type defined in line 131; used 1 times
yybignum defined in line 120; used 3 times
yylval defined in line 119; used 41 times
yyopcode defined in line 121; used 4 times

Defined macros

ALPHA defined in line 27; used 56 times
BSESCAPE defined in line 35; used 6 times
DIGIT defined in line 28; used 17 times
EOFCHAR defined in line 20; used 4 times
FLOATEXP defined in line 29; used 12 times
FLOATFLAG defined in line 38; used 8 times
HEXFLAG defined in line 24; used 2 times
HEXLDIGIT defined in line 25; used 8 times
HEXUDIGIT defined in line 26; used 8 times
INCHARSET defined in line 40; used 22 times
MEMTOREGBUF defined in line 48; used 7 times
OCTDIGIT defined in line 37; used 10 times
POINT defined in line 33; used 3 times
REGDIGIT defined in line 31; used 7 times
REGTOMEMBUF defined in line 47; used 7 times
SIGN defined in line 30; used 5 times
SPACE defined in line 34; used 5 times
STRESCAPE defined in line 36; used 3 times
SZSPECBEGIN defined in line 32; used 7 times
TOKDALLOP defined in line 68; used 2 times
bskipfromto defined in line 102; used 1 times
bskiplg defined in line 98; used 1 times
eatskiplg defined in line 106; used 1 times
getchar defined in line 50; used 1 times
  • in line 49
readTEST defined in line 95; used 1 times
ungetc defined in line 56; used 18 times
writeTEST defined in line 92; used 3 times

Usage of this include

Last modified: 1985-04-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1527
Valid CSS Valid XHTML 1.0 Strict