|
|
1.1 ! root 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[];
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.