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
ERROR
defined in line
13; used 6 times
expr
defined in line
68; used 23 times
- in /usr/src/bin/as/asparse.c line
207,
216,
231,
265,
317,
323,
382,
405-410(2),
417,
475,
521,
528-535(3),
610,
617-620(2),
677,
697,
734,
805,
963
shift
defined in line
17; used 50 times
- in line 18,
24,
72,
94-97(2)
- in /usr/src/bin/as/asexpr.c line
226,
241,
255,
271-288(5)
- in /usr/src/bin/as/asparse.c line
106,
126-129(2),
142,
184,
197,
206,
212,
227,
254,
263,
304,
370,
381,
404,
431,
467-474(3),
608,
652,
673,
696,
704,
716,
751,
763,
776,
795,
804,
812,
819,
898,
913-915(2),
934-938(2)
shiftover
defined in line
20; used 26 times
- in line 26
- in /usr/src/bin/as/asparse.c line
135,
199,
214-215(2),
229-230(2),
256,
322,
409,
416,
527-533(3),
616-619(2),
655,
663,
675-676(2),
737-739(2),
793,
814,
821,
852
Usage of this include