annotate os9/mc09/mc.c @ 133:2562c18c904e

malloc for mc2 wrong...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 06 Jan 2019 22:38:04 +0900
parents 36000611014b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #define DEBUG error(-1)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 /*#include "CCLIB.TXT"
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 */
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include <stdio.h>
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
100
990add11e9f8 add micro-c stuff
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
8 /* to avoid conflict with stdio.h */
990add11e9f8 add micro-c stuff
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
9 #define getline getline1
990add11e9f8 add micro-c stuff
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
10 #define index index1
990add11e9f8 add micro-c stuff
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
11
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #define INT (-1)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #define CHAR (-2)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #define UNSIGNED (-3)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #define POINTER (-4)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #define ARRAY (-5)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 #define STRUCT (-6)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 #define UNION (-7)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #define FUNCTION (-8)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #define EMPTY (-9)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #define STATIC (-10)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #define GOTO (-11)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #define RETURN (-12)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #define BREAK (-13)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #define CONTINUE (-14)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 #define IF (-15)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 #define ELSE (-16)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 #define FOR (-17)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 #define DO (-18)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 #define WHILE (-19)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 #define SWITCH (-20)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #define CASE (-21)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 #define DEFAULT (-22)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #define RESERVE (-23)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 #define TAG (-24)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 #define FIELD (-25)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 #define IDENT (-26)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 #define STRING (-27)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #define MACRO (-28)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 #define BLABEL (-29)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 #define FLABEL (-30)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 #define TYPEDEF (-31)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 #define SIZEOF (-32)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 #define TYPE (-33)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 #define LONG (-34)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 #define SHORT (-35)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 #define TOP 0
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 #define GDECL 1
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 #define GSDECL 2
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 #define GUDECL 3
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 #define ADECL 4
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 #define LDECL 5
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 #define LSDECL 6
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 #define LUDECL 7
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 #define STADECL 8
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 #define STAT 9
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 #define GTDECL 10
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 #define LTDECL 11
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 #define GVAR 1
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 #define RGVAR 2
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 #define CRGVAR 3
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 #define LVAR 4
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 #define RLVAR 5
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 #define CRLVAR 6
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 #define CONST 7
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 #define FNAME 8
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 #define INDIRECT 9
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 #define RINDIRECT 10
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 #define CRINDIRECT 11
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 #define ADDRESS 12
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 #define MINUS 13
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 #define LNOT 14
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 #define BNOT 15
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 #define INC 16
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 #define POSTINC 17
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 #define PREINC 18
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 #define CPOSTINC 19
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 #define CPREINC 20
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 #define DEC 21
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 #define CPOSTDEC 22
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 #define CPREDEC 23
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 #define MUL 24
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 #define UMUL 25
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 #define DIV 26
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 #define UDIV 27
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 #define MOD 28
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 #define UMOD 29
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 #define ADD 30
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 #define SUB 31
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 #define RSHIFT 32
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 #define URSHIFT 33
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 #define LSHIFT 34
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 #define ULSHIFT 35
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 #define GT 36
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 #define UGT 37
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 #define GE 38
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 #define UGE 39
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 #define LT 40
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 #define ULT 41
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 #define LE 42
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 #define ULE 43
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 #define EQ 44
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 #define NEQ 45
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 #define BAND 46
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 #define EOR 47
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 #define BOR 48
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 #define LAND 49
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 #define LOR 50
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 #define COND 51
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 #define ASS 52
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 #define CASS 53
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 #define ASSOP 54
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 #define CASSOP 55
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 #define COMMA 56
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 #define LPAR 57
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 #define RPAR 58
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 #define LBRA 59
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 #define RBRA 60
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 #define LC 61
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 #define RC 62
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 #define COLON 63
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 #define SM 64
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 #define PERIOD 65
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 #define ARROW 66
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 #define US 1
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 #define AS 100
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 #define FILERR 1
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 #define DCERR 2
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 #define STERR 3
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 #define EXERR 4
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 #define CNERR 5
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 #define CHERR 6
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 #define GSERR 7
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 #define LSERR 8
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 #define STRERR 9
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 #define LNERR 10
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 #define EOFERR 11
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 #define MCERR 12
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 #define INCERR 13
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 #define HPERR 14
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 #define TYERR 15
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 #define LVERR 16
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 #define UDERR 17
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 #define OPTION 18
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 #define GSYMS 450
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 #define LSYMS 50
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 #define HEAPSIZE 1000
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 #define CHEAPSIZE 3000
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 #define LBUFSIZE 256
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 #define FILES 3
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 int sym,ch,chsave,type,mode,gfree,lfree,mflag,lineno,glineno;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 int labelno,gpc,lvar,disp;
107
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
162 int symval,args;
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
163 long heap[HEAPSIZE];
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 int blabel,clabel,dlabel,cslabel,ilabel,control,ac,ac2,lsrc,chk,asmf;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 unsigned hash;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 char linebuf[LBUFSIZE],cheap[CHEAPSIZE],*chptr,*chptrsave;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 char name[9],*cheapp,**av,/*obuf[320],*/*sptr,escape();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 FILE *obuf;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 typedef struct nametable {
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 char nm[9];
107
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
175 int sc,ty; long dsp; } NMTBL;
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 NMTBL ntable[GSYMS+LSYMS],*nptr,*gnptr,*decl0(),*decl1(),*lsearch(),*gsearch();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 struct {int fd,ln;/*char fcb[320]*/FILE *fcb;} *filep,filestack[FILES];
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180
107
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
181 long car();
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
182 long cadr();
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
183 long caddr();
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
184 long cadddr();
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
185 void leaxpcr(NMTBL *n);
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
186 long error();
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
187 list2(long e1,long e2);
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
188 list3(long e1,long e2,long e3);
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
189 list4(long e1,long e2,long e3,long e4);
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
190
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 main(argc,argv)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 int argc;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 char **argv;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 {NMTBL *nptr;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 int i;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 char *ccout;
104
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 101
diff changeset
197 char *modname;
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 if(argc==1) exit(1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 lsrc = chk = asmf = 0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 ccout = "c.out";
104
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 101
diff changeset
201 modname = "aout";
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 ac=argc;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 av=argv;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 for (ac2=1; (ac2 < ac) && (*av[ac2] == '-'); ++ac2)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 switch (*(av[ac2]+1))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 {case 'S': case 's':
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 lsrc = 1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 case 'O': case 'o':
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 ccout = av[ac2]+2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 break;
101
15569aa4098e micro c continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
212 case 'M': case 'm':
15569aa4098e micro c continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
213 modname = av[ac2]+2;
15569aa4098e micro c continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
214 break;
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 case 'C': case 'c':
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 chk = 1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 default:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 error(OPTION);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 exit(1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 fclose(stdout);
101
15569aa4098e micro c continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
223 if (!chk) {
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 if ( (obuf = fopen(ccout,"w")) == NULL ) error(FILERR);
101
15569aa4098e micro c continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
225 else {
105
6eef99bb4771 fix runtime
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
226 /* we'l resize data area later */
133
2562c18c904e malloc for mc2 wrong...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 132
diff changeset
227 printf("\tmod _eom,_name,_tylg,_atrv,_start,1024\n"); /* os9 module header */
104
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 101
diff changeset
228 printf("_name fcs /%s/\n\tfcb 0\n",modname);
101
15569aa4098e micro c continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
229 }
15569aa4098e micro c continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
230 }
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 init();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 while(1)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 { for (nptr = &ntable[GSYMS],i=LSYMS; i--;)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 (nptr++)->sc = EMPTY;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 mode=TOP;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 while(getsym()==SM);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 mode=GDECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 args=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 decl();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 }
107
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
242 long
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 error(n)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 int n;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 { if(n == EOFERR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 if(filep!=filestack)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 { lineno=filep->ln;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 fclose(filep->fcb);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 fprintf(stderr,"End of inclusion.\n");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 --filep;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 else if(ac2!=ac)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 { fclose(filep->fcb);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 newfile();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 else if(mode == TOP)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 { fprintf(stderr,"\nCompiled %u lines.\n",glineno-1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 if (!chk) fprintf(stderr,
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 "Total internal labels : %u.\n",labelno-1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 fprintf(stderr,
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 "Total global variables : %u bytes.\n\n",gpc);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 printf("_%d\tRTS\n_INITIALIZE\tEQU\t_1\n",ilabel);
100
990add11e9f8 add micro-c stuff
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
265 printf("_GLOBALS\tEQU\t%u\n",gpc);
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 exit(0);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 fprintf(stderr,"%5d:%s.\n",lineno,
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 (n==FILERR) ? "Can't open specified file" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 (n==DCERR) ? "Declaration syntax" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 (n==STERR) ? "Statement syntax" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 (n==EXERR) ? "Expression syntax" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 (n==CNERR) ? "Constant required" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 (n==CHERR) ? "Illegal character" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 (n==GSERR) ? "Too many global symbols" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 (n==LSERR) ? "Too many local symbols" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 (n==STRERR) ? "Too many strings or macros" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 (n==LNERR) ? "Line too long" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 (n==EOFERR) ? "Unexpected end of file" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 (n==MCERR) ? "Macro syntax" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 (n==INCERR) ? "Include syntax" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 (n==HPERR) ? "Too long expression" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 (n==TYERR) ? "Type mismatch" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 (n==LVERR) ? "Lvalue required" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 (n==UDERR) ? "Undeclared identifier" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 (n==OPTION) ? "Illegal option" :
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 "Bug of compiler");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 errmsg();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 exit(1);
107
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
290 return 0;
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 errmsg()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 {char *p,*lim;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 if(lineno==0) return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 fprintf(stderr,"%s",linebuf);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 lim=(mflag?chptrsave:chptr);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 for (p=linebuf; p < lim;)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 fprintf(stderr,(*p++ == '\t') ? "\t" : " ");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 fprintf (stderr,"^\n");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 checksym(s)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 int s;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 {char *p;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 if (sym != s)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 { p=(s==RPAR) ? "')'": (s==RBRA) ? "']'": (s==SM) ? "';'":
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 (s==LPAR) ? "'('": (s==WHILE) ? "'while'":
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 (s==COLON) ? "':'": "Identifier";
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 fprintf(stderr,"%d:%s expected.\n",lineno,p);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 errmsg();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 else getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 init()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 {NMTBL *nptr;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 int i;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 for(nptr = ntable,i = GSYMS; i--;) (nptr++)->sc = EMPTY;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 reserve("int",INT);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 reserve("void",INT);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 reserve("char",CHAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 reserve("struct",STRUCT);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 reserve("union",UNION);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 reserve("unsigned",UNSIGNED);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 reserve("static",STATIC);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 reserve("goto",GOTO);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 reserve("return",RETURN);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 reserve("break",BREAK);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 reserve("continue",CONTINUE);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 reserve("if",IF);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 reserve("else",ELSE);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 reserve("for",FOR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 reserve("do",DO);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 reserve("while",WHILE);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 reserve("switch",SWITCH);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 reserve("case",CASE);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 reserve("default",DEFAULT);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 reserve("typedef",TYPEDEF);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 reserve("sizeof",SIZEOF);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 reserve("long",LONG);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 reserve("short",SHORT);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 gpc=glineno=mflag=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 gfree=ilabel=1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 labelno=2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 cheapp=cheap;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 lfree=HEAPSIZE;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 filep=filestack;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 newfile();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 getline();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 getch();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 newfile()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 { lineno=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 fprintf(stderr,"%s:\n",av[ac2]);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 if ( (filep->fcb = fopen(av[ac2++],"r")) == NULL ) error(FILERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 reserve(s,d)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 char *s;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 int d;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 {NMTBL *nptr;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 char *t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 hash=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 t=name;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 while(*t++ = *s) hash=7*(hash+*s++);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 (nptr = gsearch())->sc = RESERVE;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 nptr->dsp = d;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
366
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 decl()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 {NMTBL *n;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 int t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 if(sym==STATIC)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 if(mode==LDECL)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 mode=STADECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 else error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 else if(sym==TYPEDEF)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 if(mode==GDECL)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 mode=GTDECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 else if(mode==LDECL)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 mode=LTDECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 else error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 if((t=typespec())==0) return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 if(sym==SM) return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 type=t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 n=decl0();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 reverse(t);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 if(args||sym==LC) {fdecl(n);return;}
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 def(n);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 while(sym==COMMA)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 type=t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 n=decl0();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 reverse(t);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
398 if(args) error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 def(n);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 if(sym!=SM) error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 if(mode==GTDECL) mode=GDECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 if(mode==STADECL||mode==LTDECL) mode=LDECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 typespec()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 {int t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 switch(sym)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 {case INT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 case CHAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 t= sym;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 case STRUCT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 case UNION:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 t=sdecl(sym);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 case UNSIGNED:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 t = UNSIGNED;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 if(getsym()==INT) getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 case SHORT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 t=CHAR;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 if(getsym()==INT) getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 case LONG:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 t=INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 if(getsym()==INT) getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 default:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 if(sym==IDENT)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 if(nptr->sc==TYPE)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 { t=nptr->ty;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 else if(nptr->sc==EMPTY && gnptr->sc==TYPE)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 { t=gnptr->ty;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 if(mode==LDECL) return 0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 t= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 return t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 struct nametable *decl0()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 {NMTBL *n;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 if(sym==MUL)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 n=decl0();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 type=list2(POINTER,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 return n;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 return decl1();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 NMTBL *decl1()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 {NMTBL *n;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 int i,t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 if(sym==LPAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 n=decl0();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 else if (sym == IDENT)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 { n=nptr;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
467 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 else error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 while(1)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 if(sym==LBRA)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 if(getsym()==RBRA)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 if(mode!=ADECL) error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 type=list2(POINTER,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
476 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 { t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 i=cexpr(expr());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 checksym(RBRA);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 type=list3(ARRAY,t,i);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 else if(sym==LPAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 { if(mode==GDECL) {mode=ADECL;getsym();mode=GDECL;}
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 else getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 if(sym==RPAR) getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 { n->sc=FUNCTION;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 adecl();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 n->sc=EMPTY;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 type=list2(FUNCTION,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 else return n;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 adecl()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 { if(mode!=GDECL) error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 mode=ADECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 args= 2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 while(1)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 { if(sym!=IDENT) error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 nptr->ty = INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 nptr->sc = LVAR;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 nptr->dsp = (args += 2);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 if(getsym()!=COMMA) break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 mode=GDECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 reverse(t1)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 int t1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 {int t2,t3;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 t2=t1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 while(type!=t1)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 { t3=cadr(type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 rplacad(type,t2);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 t2=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
520 type=t3;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 type=t2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 size(t)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 int t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 { if(t==CHAR) return 1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 if(scalar(t)) return 2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 if(car(t)==STRUCT||car(t)==UNION)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 { if(cadr(t)==-1) error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 return(cadr(t));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 if(car(t)==ARRAY) return(size(cadr(t))*caddr(t));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 else error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 /*NOTREACHED*/
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 def(n)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 NMTBL *n;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
538 {int sz,nsc,ndsp,slfree,l,t,e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 if(car(type)==FUNCTION)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 { fcheck(n);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 if (n->sc!=EMPTY &&
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 (mode!=ADECL || n->sc!=LVAR || n->ty!=INT) &&
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 (mode!=GSDECL&&mode!=LSDECL || n->sc!=FIELD || n->dsp!=disp) &&
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 (mode!=GUDECL&&mode!=LUDECL || n->sc!=FIELD || n->dsp!=0) )
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 sz = size(n->ty = type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 switch(mode)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 {case GDECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 printf("%s\tEQU\t%u\n",n->nm,gpc);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 case STADECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 nsc = GVAR;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
554 ndsp = gpc;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 if(sym==ASS)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 { t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 if(!scalar(t))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 if(mode==STADECL) printf("\tBRA\t_%d\n",l=fwdlabel());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 fwddef(ilabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 slfree=lfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 e=expr1();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 if(car(e)==CONST)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 { lddim(cadr(e));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 indexy(t==CHAR?"STB":"STD",gpc);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 else if(t!=CHAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 { if(car(e)==ADDRESS&&car(cadr(e))==GVAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 leaxy(cadr(cadr(e)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 else if(car(e)==FNAME)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
572 leaxpcr((NMTBL *)cadr(e));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 else error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 stxy(gpc);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 else error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 jmp(ilabel=fwdlabel());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 if(mode==STADECL) fwddef(l);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 type=t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 gpc +=sz;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 case GSDECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 nsc = FIELD;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 ndsp = disp;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 disp += sz;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 case GUDECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 nsc = FIELD;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 ndsp = 0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 if (disp < sz) disp = sz;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 case GTDECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 nsc = TYPE;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 case ADECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 if(type==CHAR) ++(n->dsp);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 else if (!scalar(type)) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 case LDECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 nsc = LVAR;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 ndsp = (disp -= sz);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 case LSDECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 nsc = FIELD;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 ndsp = disp;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 disp += sz;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 case LUDECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 nsc = FIELD;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 ndsp = 0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 if (disp < sz) disp = sz;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
614 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 case LTDECL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 nsc = TYPE;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
618 default:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 n->sc = nsc;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 n->dsp = ndsp;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
624 sdecl(s)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 int s;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
626 {int smode,sdisp,type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
627 NMTBL *nptr0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 smode=mode;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 if (mode==GDECL || mode==GSDECL || mode==GUDECL || mode==GTDECL)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
630 mode=(s==STRUCT?GSDECL:GUDECL);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
631 else mode=(s==STRUCT?LSDECL:LUDECL);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
632 sdisp=disp;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 disp=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 if (getsym() == IDENT)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 { nptr0 = nptr;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 if (getsym() == LC)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 { if (nptr0->sc != EMPTY) error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 nptr0->sc = TAG;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
639 nptr0->ty = list2(s,-1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 while (getsym() != RC) decl();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 rplacad(type = nptr0->ty,disp);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 { if(nptr0->sc == EMPTY) nptr0=gnptr;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 if(nptr0->sc == EMPTY) error(UDERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 if(nptr0->sc != TAG) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 type = nptr0->ty;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 else if(sym==LC)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 { while(getsym() != RC) decl();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 type = list2(s,disp);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 else error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
657 disp=sdisp;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 mode=smode;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 return type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 fdecl(n)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 NMTBL *n;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 { args=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 fcheck(n);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 mode=ADECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 lfree= HEAPSIZE;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
667 while (sym!=LC) {decl(); getsym();}
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 disp=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 mode=STAT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
670 while (typeid(getsym()) || sym==STATIC || sym==TYPEDEF)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
671 { mode=LDECL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 decl();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 mode=STAT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
674 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 control=1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 printf("%s\n\tPSHS\tU\n\tLEAU\t,S\n",n->nm);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 if(disp) printf("\tLEAS\t%d,S\n",disp);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 lvar= -disp;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
679 while(sym!=RC) statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 if (control) return2();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 fcheck(n)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 NMTBL *n;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 { if(mode!=GDECL||car(type)!=FUNCTION) error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 if(n->sc==FUNCTION) compatible(n->ty,cadr(type));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 else if(n->sc!=EMPTY) error(DCERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 n->sc=FUNCTION;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 n->ty=cadr(type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
689 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
690 compatible(t1,t2)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 int t1,t2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 { if(integral(t1))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
693 { if(t1!=t2) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
695 else if(car(t1)!=car(t2)) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
696 else if((car(t1)==STRUCT || car(t1)==UNION) && cadr(t1)!=cadr(t2))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 else if(car(t1)==POINTER || car(t1)==ARRAY ||car(t1)==FUNCTION)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
699 compatible(cadr(t1),cadr(t2));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 scalar(t)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 int t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 { return(integral(t)||car(t)==POINTER);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 integral(t)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 int t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 { return(t==INT||t==CHAR||t==UNSIGNED);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
708 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
709
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 statement()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 {int slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 switch(sym)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 {case IF:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 doif();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 case WHILE:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 dowhile();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
719 case DO:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 dodo();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 case FOR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 dofor();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
725 case SWITCH:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
726 doswitch();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
728 case LC:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
729 docomp();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 case BREAK:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
732 jmp(blabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
733 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 checksym(SM);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
735 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
736 case CONTINUE:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 jmp(clabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
738 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 checksym(SM);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
740 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
741 case CASE:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 docase();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
745 case DEFAULT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
746 dodefault();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 case RETURN:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 doreturn();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
751 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 case GOTO:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 dogoto();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 case SM:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 default:if(sym==IDENT&&skipspc()==':')
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 { dolabel();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
760 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 { slfree=lfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 gexpr(expr());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
765 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 checksym(SM);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
767 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
768 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
769 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 doif()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 {int l1,l2,slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 checksym(LPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 slfree=lfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 bexpr(expr(),0,l1=fwdlabel());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
776 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
777 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
778 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 if(sym==ELSE)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
780 { if (l2 = control) jmp(l2=fwdlabel());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
781 fwddef(l1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
782 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
784 if (l2) fwddef(l2);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
785 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
786 else fwddef(l1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
787 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
788 dowhile()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
789 {int sbreak,scontinue,slfree,e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
790 sbreak=blabel;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
791 scontinue=clabel;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
792 blabel=fwdlabel();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
793 clabel=backdef();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
794 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
795 checksym(LPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
796 slfree=lfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
797 e=expr();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
798 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
799 if(sym==SM)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
800 { bexpr(e,1,clabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
801 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
802 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
803 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
804 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
805 { bexpr(e,0,blabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
806 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
807 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
808 jmp(clabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
809 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
810 fwddef(blabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
811 clabel=scontinue;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
812 blabel=sbreak;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
813 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 dodo()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 {int sbreak,scontinue,l,slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
816 sbreak=blabel;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
817 scontinue=clabel;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 blabel=fwdlabel();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 clabel=fwdlabel();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
820 l=backdef();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
821 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
822 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
823 fwddef(clabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
824 checksym(WHILE);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
825 checksym(LPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 slfree=lfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
827 bexpr(expr(),1,l);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
828 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 checksym(SM);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
831 fwddef(blabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
832 clabel=scontinue;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
833 blabel=sbreak;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
834 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
835 dofor()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
836 {int sbreak,scontinue,l,e,slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 sbreak=blabel;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
838 scontinue=clabel;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 blabel=fwdlabel();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
840 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 checksym(LPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
842 slfree=lfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
843 if(sym!=SM)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 { gexpr(expr());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
845 checksym(SM);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
847 else getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
848 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 l=backdef();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 if(sym!=SM)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
851 { bexpr(expr(),0,blabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 checksym(SM);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 else getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 if(sym==RPAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 { clabel=l;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
860 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
861 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 { clabel=fwdlabel();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 e=expr();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 fwddef(clabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 gexpr(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 jmp(l);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 fwddef(blabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 clabel=scontinue;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
873 blabel=sbreak;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
875 doswitch()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 {int sbreak,scase,sdefault,slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
877 sbreak=blabel;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
878 blabel=fwdlabel();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
879 sdefault=dlabel;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 dlabel=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 scase=cslabel;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 checksym(LPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 slfree=lfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 gexpr(expr());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
886 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
887 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 cslabel = control = 0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
889 statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
890 if(dlabel) printf("_%d\tEQU\t_%d\n",cslabel,dlabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
891 else fwddef(cslabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
892 cslabel=scase;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
893 dlabel=sdefault;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 fwddef(blabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 blabel=sbreak;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
896 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
897 docomp()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
898 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 while(sym!=RC) statement();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
900 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
901 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
902 docase()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
903 {int c,n,l,slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
904 c=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
905 n=2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
906 slfree=lfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
907 while(sym==CASE)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
908 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
909 c=list2(cexpr(expr()),c);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
910 n+=6;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
911 checksym(COLON);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
913 l=fwdlabel();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
914 if (control)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
915 { control=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 if (n>127) jmp(l);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
917 else printf("\tBRA\t_%d\n",l);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
918 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
919 if (cslabel) fwddef(cslabel);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
920 while(cadr(c))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
921 { cmpdimm(car(c));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
922 if((n-=6)>127) jcond(l,0);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
923 else printf("\tBEQ\t_%d\n",l);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 c=cadr(c);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
925 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
926 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
927 cmpdimm(car(c));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
928 jcond(cslabel=fwdlabel(),1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
929 fwddef(l);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
930 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
931 dodefault()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
932 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
933 checksym(COLON);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
934 if (dlabel) error(STERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
935 if (!cslabel) jmp(cslabel = fwdlabel());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
936 dlabel = backdef();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
937 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
938 doreturn()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
939 {int slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
940 if(getsym()==SM)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
941 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
942 return2();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
943 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
944 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
945 slfree=lfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
946 gexpr(expr());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 lfree=slfree;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
948 checksym(SM);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
949 control=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
950 switch(lvar)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
951 {case 0:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
952 ret("");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
953 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
954 case 2:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
955 ret("X,");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
956 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
957 default:unlink();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
958 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
959 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
960 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
961 return2()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
962 { control=0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
963 switch(lvar)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 {case 0:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 ret("");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
966 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 case 1:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 ret("A,");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 case 2:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 ret("D,");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
972 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
973 case 3:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
974 ret("A,X,");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
975 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
976 case 4:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
977 ret("D,X,");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
978 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
979 default:unlink();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
980 return;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
981 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 ret(reg)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
984 char *reg;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
985 { printf("\tPULS\t%sU,PC\n",reg);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
986 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
987 unlink()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 { printf("\tLEAS\t,U\n");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 ret("");
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
991 dogoto()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
992 {NMTBL *nptr0;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 nptr0=nptr;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 checksym(IDENT);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 if(nptr0->sc == BLABEL || nptr0->sc == FLABEL) jmp(nptr0->dsp);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 else if(nptr0->sc == EMPTY)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
998 { nptr0->sc = FLABEL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
999 jmp(nptr0->dsp = fwdlabel());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 else error(STERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 checksym(SM);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 dolabel()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 { if(nptr->sc == FLABEL) fwddef(nptr->dsp);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006 else if(nptr->sc != EMPTY) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1007 nptr->sc = BLABEL;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1008 nptr->dsp = backdef();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1009 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1010 checksym(COLON);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1011 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1012
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1013 expr()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1014 { return(rvalue(expr0()));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1016 expr0()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1017 {int e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018 e=expr1();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019 while(sym==COMMA) {getsym();e=list3(COMMA,e,rvalue(expr1()));}
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020 return e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022 expr1()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1023 {int e1,e2,t,op;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1024 e1=expr2();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 switch (sym)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026 {case ASS:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1027 lcheck(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1028 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 e2=rvalue(expr1());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031 if(t==CHAR) {type= INT;return(list3(CASS,e1,e2));}
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1032 type=t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033 return(list3(ASS,e1,e2));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034 case ADD+AS: case SUB+AS: case MUL+AS: case DIV+AS: case MOD+AS:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035 case RSHIFT+AS: case LSHIFT+AS: case BAND+AS: case EOR+AS: case BOR+AS:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1036 op = sym-AS;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 lcheck(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040 e2=rvalue(expr1());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041 if(!integral(type)) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042 if((t==UNSIGNED||type==UNSIGNED)&&
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1043 (op==MUL||op==DIV||op==MOD||op==RSHIFT||op==LSHIFT))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1044 op=op+US;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1045 if(t==CHAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046 { type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1047 return(list4(CASSOP,e1,e2,op));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1048 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1049 type=t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050 if(integral(t)) return(list4(ASSOP,e1,e2,op));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051 if((op!=ADD&&op!=SUB)||car(t)!=POINTER) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 e2=binop(MUL,e2,list2(CONST,size(cadr(t))),INT,UNSIGNED);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1053 type=t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054 return list4(ASSOP,e1,e2,op);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 default:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056 return(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059 expr2()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 {int e1,e2,e3,t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 e1=expr3();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 if(sym==COND)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 { e1=rvalue(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065 e2=rvalue(expr2());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 checksym(COLON);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068 e3=rvalue(expr2());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069 if(car(e1)==CONST)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070 if(cadr(e1)) {type=t;return e2;}
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 else return e3;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072 if(type==INT||t!=INT&&type==UNSIGNED) type=t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 return(list4(COND,e1,e2,e3));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1074 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1075 return(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1076 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 expr3()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 {int e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079 e=expr4();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080 while(sym==LOR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081 { e=rvalue(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 e=list3(LOR,e,rvalue(expr4()));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084 type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 return(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1087 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1088 expr4()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1089 {int e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1090 e=expr5();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1091 while(sym==LAND)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1092 { e=rvalue(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094 e=list3(LAND,e,rvalue(expr5()));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1095 type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097 return(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 expr5()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100 {int e1,e2,t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101 e1=expr6();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 while(sym==BOR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 { e1=rvalue(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106 e2=rvalue(expr6());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107 e1=binop(BOR,e1,e2,t,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1109 return(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1110 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 expr6()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112 {int e1,e2,t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113 e1=expr7();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 while(sym==EOR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 { e1=rvalue(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1117 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1118 e2=rvalue(expr7());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1119 e1=binop(EOR,e1,e2,t,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1120 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 return(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 expr7()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1124 {int e1,e2,t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1125 e1=expr8();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1126 while(sym==BAND)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1127 { e1=rvalue(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1128 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1130 e2=rvalue(expr8());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131 e1=binop(BAND,e1,e2,t,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133 return(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135 expr8()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136 {int e,op;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1137 e=expr9();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1138 while((op=sym)==EQ||op==NEQ)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1139 { e=rvalue(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1140 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1141 e=list3(op,e,rvalue(expr9()));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1142 type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1143 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1144 return e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1145 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1146 expr9()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1147 {int e1,e2,t,op;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1148 e1=expr10();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 while((op=sym)==GT||op==GE||op==LT||op==LE)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1150 { e1=rvalue(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1152 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1153 e2=rvalue(expr10());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1154 if(t==INT&&type==INT) e1=list3(op,e1,e2);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1155 else e1=list3(op+US,e1,e2);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156 type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1157 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1158 return e1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1159 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1160 expr10()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161 {int e1,e2,t,op;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1162 e1=expr11();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1163 while((op=sym)==RSHIFT||op==LSHIFT)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1164 { e1=rvalue(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1165 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1166 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1167 e2=rvalue(expr11());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1168 e1=binop(op,e1,e2,t,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1169 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1170 return e1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1171 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1172 expr11()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173 {int e1,e2,t,op;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1174 e1=expr12();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1175 while((op=sym)==ADD||op==SUB)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1176 { e1=rvalue(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1177 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1178 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1179 e2=rvalue(expr12());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1180 e1=binop(op,e1,e2,t,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1181 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1182 return e1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1183 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1184 expr12()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1185 {int e1,e2,t,op;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1186 e1=expr13();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1187 while((op=sym)==MUL||op==DIV||op==MOD)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1188 { e1=rvalue(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1189 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1190 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1191 e2=rvalue(expr13());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1192 e1=binop(op,e1,e2,t,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1193 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1194 return e1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1195 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1196 expr13()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1197 {int e,op;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1198 switch (op = sym)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1199 {case INC: case DEC:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1200 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1201 lcheck(e=expr13());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1202 if(type==CHAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1203 { type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1204 return(list2(op==INC?CPREINC:CPREDEC,e));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1205 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1206 if(integral(type))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1207 return(list3(PREINC,e,op==INC?1:-1));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1208 if(car(type)!=POINTER) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1209 return(list3(PREINC,e,
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1210 op==INC?size(cadr(type)):-size(cadr(type)) ));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211 case MUL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1212 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1213 e=rvalue(expr13());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1214 return(indop(e));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1215 case BAND:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1216 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1217 switch(car(e=expr13()))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1218 {case INDIRECT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1219 e=cadr(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1220 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1221 case GVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1222 case LVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1223 e=list2(ADDRESS,e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1224 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1225 case FNAME:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1226 return e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1227 default:error(LVERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1228 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1229 type=list2(POINTER,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1230 return e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1231 case SUB:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1232 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1233 e=rvalue(expr13());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1234 if(!integral(type)) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1235 return(car(e)==CONST?list2(CONST,-cadr(e)):list2(MINUS,e));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1236 case BNOT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1237 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1238 e=rvalue(expr13());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1239 if(!integral(type)) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1240 return(car(e)==CONST?list2(CONST,~cadr(e)):list2(BNOT,e));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1241 case LNOT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1242 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1243 return(list2(LNOT,rvalue(expr13())));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1244 case SIZEOF:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1245 if(getsym()==LPAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1246 if(typeid(getsym()))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1247 { e=list2(CONST,size(typename()));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1248 type=INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1249 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1250 return e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1251 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1252 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1253 { e=expr0();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1254 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1255 expr16(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1256 if(sym==INC||sym==DEC)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1257 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1258 if(type==CHAR) type=INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1259 else if(!scalar(type))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1260 error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1261 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1262 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1263 else expr13();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1264 e=list2(CONST,size(type));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1265 type=INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1266 return e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1267 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1268 e=expr14();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1269 if((op=sym)==INC||op==DEC)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1270 { lcheck(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1271 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1272 if(type==CHAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1273 { type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1274 return(list2(op==INC?CPOSTINC:CPOSTDEC,e));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1275 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1276 if(integral(type))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1277 return(list3(POSTINC,e,op==INC?1:-1));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1278 if(car(type)!=POINTER) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1279 return (list3(POSTINC,e,
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1280 op == INC ? size(cadr(type)): -size(cadr(type)) ));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1281 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1282 return e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1283 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1284 expr14()
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1285 {int e1,t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1286 switch(sym)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1287 {case IDENT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1288 switch(nptr->sc)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1289 {case GVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1290 e1=list2(GVAR,nptr->dsp);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1291 type=nptr->ty;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1292 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1293 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1294 case LVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1295 e1=list2(LVAR,nptr->dsp);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1296 type=nptr->ty;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1297 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1298 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299 case FUNCTION:
107
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
1300 e1=list2(FNAME,(long)nptr);
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1301 type=list2(FUNCTION,nptr->ty);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1302 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304 case EMPTY:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1305 if(getsym()==LPAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1306 { nptr->sc = FUNCTION;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1307 nptr->ty= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1308 type= list2(FUNCTION,INT);
107
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
1309 e1=expr15(list2(FNAME,(long)nptr));
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1310 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1311 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1312 default:error(UDERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1313 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1314 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1315 case STRING:
107
c5dd5c363d43 mc.c in intel64 ( LP64 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
1316 e1=list3(STRING,(long)sptr,symval);
99
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1317 type=list3(ARRAY,CHAR,symval);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1318 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1319 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1320 case CONST:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1321 type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1322 e1=list2(CONST,symval);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1323 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1324 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1325 case LPAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1326 if(typeid(getsym()))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1327 { t=typename();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1328 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1329 e1=expr13();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1330 type=t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1331 return e1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1332 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1333 e1=expr0();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1334 checksym(RPAR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1335 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1336 default:error(EXERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1337 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1338 return expr16(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1339 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1340 expr16(e1)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1341 int e1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1342 {int e2,t;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1343 while(1)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1344 if(sym==LBRA)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1345 { e1=rvalue(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1346 t=type;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1347 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1348 e2=rvalue(expr0());
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1349 checksym(RBRA);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1350 e1=binop(ADD,e1,e2,t,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1351 e1=indop(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1352 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1353 else if(sym==LPAR) e1=expr15(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1354 else if(sym==PERIOD) e1=strop(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1355 else if(sym==ARROW) e1=strop(indop(rvalue(e1)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1356 else break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1357 if(car(e1)==FNAME) type=list2(POINTER,type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1358 return e1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1359 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1360 rvalue(e)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1361 int e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1362 { if(type==CHAR)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1363 { type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1364 switch(car(e))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1365 {case GVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1366 return(list2(CRGVAR,cadr(e)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1367 case LVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1368 return(list2(CRLVAR,cadr(e)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1369 case INDIRECT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1370 return(list2(CRINDIRECT,cadr(e)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1371 default:return(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1372 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1373 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1374 if(!integral(type))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1375 if(car(type)==ARRAY)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1376 { type=list2(POINTER,cadr(type));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1377 if(car(e)==INDIRECT) return cadr(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1378 return list2(ADDRESS,e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1379 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1380 else if(car(type)!=POINTER) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1381 switch(car(e))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1382 {case GVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1383 return(list2(RGVAR,cadr(e)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1384 case LVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1385 return(list2(RLVAR,cadr(e)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1386 case INDIRECT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1387 return(list2(RINDIRECT,cadr(e)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1388 default:return(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1389 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1390 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1391 lcheck(e)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1392 int e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1393 { if(!scalar(type)||car(e)!=GVAR&&car(e)!=LVAR&&car(e)!=INDIRECT)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1394 error(LVERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1395 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1396 indop(e)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1397 int e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1398 { if(type!=INT&&type!=UNSIGNED)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1399 if(car(type)==POINTER) type=cadr(type);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1400 else error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1401 else type= CHAR;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1402 if(car(e)==ADDRESS) return(cadr(e));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1403 return(list2(INDIRECT,e));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1404 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1405 strop(e)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1406 { getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1407 if (sym!=IDENT||nptr->sc!=FIELD) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1408 if (integral(type)||car(type)!=STRUCT && car(type)!=UNION)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1409 e=rvalue(e);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1410 type = nptr->ty;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1411 switch(car(e))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1412 {case GVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1413 case LVAR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1414 e=list2(car(e),cadr(e) + nptr->dsp);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1415 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1416 case INDIRECT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1417 if(!nptr->dsp) break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1418 e=list2(INDIRECT,list3(ADD,cadr(e),list2(CONST,nptr->dsp)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1419 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1420 default:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1421 e=list2(INDIRECT,list3(ADD,e,list2(CONST,nptr->dsp)));
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1422 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1423 getsym();
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1424 return e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1425 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1426 binop(op,e1,e2,t1,t2)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1427 int op,e1,e2,t1,t2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1428 {int e;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1429 if(car(e1)==CONST&&car(e2)==CONST)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1430 { e1=cadr(e1);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1431 e2=cadr(e2);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1432 type= INT;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1433 switch(op)
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1434 {case BOR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1435 e=e1|e2;break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1436 case EOR:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1437 e=e1^e2;break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1438 case BAND:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1439 e=e1&e2;break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1440 case ADD:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1441 if(integral(t1))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1442 { if(integral(t2))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1443 e=e1+e2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1444 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1445 { if(car(t2)!=POINTER) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1446 e=size(cadr(t2))*e1+e2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1447 type=t2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1448 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1449 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1450 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1451 { if(car(t1)!=POINTER) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1452 e=e1+size(cadr(t1))*e2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1453 type=t1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1454 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1455 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1456 case SUB:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1457 if(integral(t1))
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1458 e=e1-e2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1459 else
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1460 { if(car(t1)!=POINTER) error(TYERR);
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1461 e=e1-size(cadr(t1))*e2;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1462 type=t1;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1463 }
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1464 break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1465 case MUL:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1466 e=e1*e2;break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1467 case DIV:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1468 if(!e2) error(EXERR);e=e1/e2;break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1469 case MOD:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1470 if(!e2) error(EXERR);e=e1%e2;break;
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1471 case RSHIFT:
92ed427b7f7d add micro-c by mohta
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1472 e=e1>>e2;break;
92ed427b7f7d add micro-c by moht