1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
funarglist:
{ $$ = 0; }
| funargs
{ $$ = revchain($1); }
;
funargs: expr
{ $$ = mkchain((char *)$1, CHNULL); }
| funargs SCOMMA expr
{ $$ = mkchain((char *)$3, $1); }
;
expr: uexpr
| SLPAR expr SRPAR { $$ = $2; if ($$->tag == TPRIM)
paren_used(&$$->primblock); }
| complex_const
;
uexpr: lhs
| simple_const
| expr addop expr %prec SPLUS
{ $$ = mkexpr($2, $1, $3); }
| expr SSTAR expr
{ $$ = mkexpr(OPSTAR, $1, $3); }
| expr SSLASH expr
{ $$ = mkexpr(OPSLASH, $1, $3); }
| expr SPOWER expr
{ $$ = mkexpr(OPPOWER, $1, $3); }
| addop expr %prec SSTAR
{ if($1 == OPMINUS)
$$ = mkexpr(OPNEG, $2, ENULL);
else {
$$ = $2;
if ($$->tag == TPRIM)
paren_used(&$$->primblock);
}
}
| expr relop expr %prec SEQ
{ $$ = mkexpr($2, $1, $3); }
| expr SEQV expr
{ NO66(".EQV. operator");
$$ = mkexpr(OPEQV, $1,$3); }
| expr SNEQV expr
{ NO66(".NEQV. operator");
$$ = mkexpr(OPNEQV, $1, $3); }
| expr SOR expr
{ $$ = mkexpr(OPOR, $1, $3); }
| expr SAND expr
{ $$ = mkexpr(OPAND, $1, $3); }
| SNOT expr
{ $$ = mkexpr(OPNOT, $2, ENULL); }
| expr SCONCAT expr
{ NO66("concatenation operator //");
$$ = mkexpr(OPCONCAT, $1, $3); }
;
addop: SPLUS { $$ = OPPLUS; }
| SMINUS { $$ = OPMINUS; }
;
relop: SEQ { $$ = OPEQ; }
| SGT { $$ = OPGT; }
| SLT { $$ = OPLT; }
| SGE { $$ = OPGE; }
| SLE { $$ = OPLE; }
| SNE { $$ = OPNE; }
;
lhs: name
{ $$ = mkprim($1, LBNULL, CHNULL); }
| name substring
{ NO66("substring operator :");
$$ = mkprim($1, LBNULL, $2); }
| name SLPAR funarglist SRPAR
{ $$ = mkprim($1, mklist($3), CHNULL); }
| name SLPAR funarglist SRPAR substring
{ NO66("substring operator :");
$$ = mkprim($1, mklist($3), $5); }
;
substring: SLPAR opt_expr SCOLON opt_expr SRPAR
{ $$ = mkchain((char *)$2, mkchain((char *)$4,CHNULL)); }
;
opt_expr:
{ $$ = 0; }
| expr
;
simple: name
{ if($1->vclass == CLPARAM)
$$ = (expptr) cpexpr(
( (struct Paramblock *) ($1) ) -> paramval);
}
| simple_const
;
simple_const: STRUE { $$ = mklogcon(1); }
| SFALSE { $$ = mklogcon(0); }
| SHOLLERITH { $$ = mkstrcon(toklen, token); }
| SICON = { $$ = mkintqcon(toklen, token); }
| SRCON = { $$ = mkrealcon(tyreal, token); }
| SDCON = { $$ = mkrealcon(TYDREAL, token); }
| bit_const
;
complex_const: SLPAR uexpr SCOMMA uexpr SRPAR
{ $$ = mkcxcon($2,$4); }
;
bit_const: SHEXCON
{ NOEXT("hex constant");
$$ = mkbitcon(4, toklen, token); }
| SOCTCON
{ NOEXT("octal constant");
$$ = mkbitcon(3, toklen, token); }
| SBITCON
{ NOEXT("binary constant");
$$ = mkbitcon(1, toklen, token); }
;
fexpr: unpar_fexpr
| SLPAR fexpr SRPAR
{ $$ = $2; }
;
unpar_fexpr: lhs
| simple_const
| fexpr addop fexpr %prec SPLUS
{ $$ = mkexpr($2, $1, $3); }
| fexpr SSTAR fexpr
{ $$ = mkexpr(OPSTAR, $1, $3); }
| fexpr SSLASH fexpr
{ $$ = mkexpr(OPSLASH, $1, $3); }
| fexpr SPOWER fexpr
{ $$ = mkexpr(OPPOWER, $1, $3); }
| addop fexpr %prec SSTAR
{ if($1 == OPMINUS)
$$ = mkexpr(OPNEG, $2, ENULL);
else $$ = $2;
}
| fexpr SCONCAT fexpr
{ NO66("concatenation operator //");
$$ = mkexpr(OPCONCAT, $1, $3); }
;
|