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:  *	@(#)asexpr.h	5.1 (Berkeley) 4/30/85
   7:  */
   8: 
   9: /*
  10:  *	Definitions to parse tokens
  11:  */
  12: 
  13: #define ERROR(string)       yyerror(string); goto errorfix
  14: 
  15: #define peekahead (*tokptr)
  16: 
  17: #define shift           val = yylex()
  18: #define advance     shift
  19: 
  20: #define shiftover(token)    if (val != token) { \
  21:                     shiftoerror(token); \
  22:                     goto errorfix; \
  23:                 } \
  24:                 shift
  25: 
  26: #define advanceover     shiftover
  27: 
  28: /*
  29:  *	To speed up the expression processing, we class the input tokens
  30:  *	into various sets.
  31:  *
  32:  *	We don't call the recursive descent expression analyzer if we can
  33:  *	determine by looking at the next token after the first token in
  34:  *	an expression that the expression is simple (name, integer or floating
  35:  *	point value).  Expressions with operators are parsed using the recursive
  36:  *	descent method.
  37:  */
  38: 
  39: /*
  40:  *	Functional forwards for expression utility routines
  41:  */
  42: struct  exp *combine();
  43: struct  exp *boolterm();
  44: struct  exp *term();
  45: struct  exp *factor();
  46: struct  exp *yukkyexpr();
  47: 
  48: /*
  49:  *	The set definitions
  50:  */
  51: 
  52: extern  char    tokensets[(LASTTOKEN) - (FIRSTTOKEN) + 1];
  53: 
  54: #define LINSTBEGIN  01  /*SEMI, NL, NAME*/
  55: #define EBEGOPS     02  /*LP, MINUS, TILDE*/
  56: #define YUKKYEXPRBEG    04  /*NAME, INSTn, INST0, REG, BFINT*/
  57: #define SAFEEXPRBEG 010 /*INT, FLTNUM*/
  58: #define ADDOPS      020 /*PLUS, MINUS*/
  59: #define BOOLOPS     040 /*IOR, XOR, AND*/
  60: #define MULOPS      0100    /*LSH, RSH, MUL, DIV, TILDE*/
  61: 
  62: #define INTOKSET(val, set)  (tokensets[(val)] & (set) )
  63: 
  64: inttoktype  exprparse();
  65: inttoktype  funnyreg();
  66: inttoktype  yylex();
  67: 
  68: #define expr(xp, val) { \
  69:     if ( (!INTOKSET(val, EBEGOPS)) && (!INTOKSET(peekahead, ADDOPS+BOOLOPS+MULOPS))) { \
  70:         if (INTOKSET(val, YUKKYEXPRBEG)) xp = yukkyexpr(val, yylval); \
  71:         else xp = (struct exp *) yylval; \
  72:         shift; \
  73:     } else { \
  74:         val = exprparse(val, ptrloc1xp); \
  75:         xp = loc1xp; \
  76:     } \
  77:     }
  78: 
  79: /*
  80:  *	Registers can be either of the form r0...pc, or
  81:  *	of the form % <expression>
  82:  *	NOTE:	Reizers documentation on the assembler says that it
  83:  *	can be of the form r0 + <expression>.. That's not true.
  84:  *
  85:  *	NOTE:	Reizer's yacc grammar would seem to allow an expression
  86:  *	to be: (This is undocumented)
  87:  *		a)	a register
  88:  *		b)	an Instruction (INSTn or INST0)
  89:  */
  90: 
  91: #define findreg(regno) \
  92:     if (val == REG) { \
  93:         regno = yylval; \
  94:         shift; \
  95:     } else \
  96:     if (val == REGOP) { \
  97:         shift;  /*over the REGOP*/ \
  98:         val = funnyreg(val, ptrregno); \
  99:     } \
 100:     else { ERROR ("register expected"); }

Defined macros

ADDOPS defined in line 58; used 4 times
BOOLOPS defined in line 59; used 6 times
EBEGOPS defined in line 55; used 8 times
ERROR defined in line 13; used 6 times
INTOKSET defined in line 62; used 13 times
LINSTBEGIN defined in line 54; used 5 times
MULOPS defined in line 60; used 8 times
SAFEEXPRBEG defined in line 57; used 7 times
YUKKYEXPRBEG defined in line 56; used 11 times
advance defined in line 18; never used
advanceover defined in line 26; never used
expr defined in line 68; used 23 times
findreg defined in line 91; used 5 times
peekahead defined in line 15; used 1 times
  • in line 69
shift defined in line 17; used 50 times
shiftover defined in line 20; used 26 times

Usage of this include

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