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