version 1.6, 1999/09/14 08:30:20 |
version 1.7, 1999/09/14 08:35:16 |
|
|
|
|
int |
int |
expr(expbuf) |
expr(expbuf) |
char *expbuf; |
char *expbuf; |
{ |
{ |
register int rval; |
int rval; |
|
|
nxtch = expbuf; |
nxtch = expbuf; |
if (setjmp(expjump) != 0) |
if (setjmp(expjump) != 0) |
|
|
static int |
static int |
query() |
query() |
{ |
{ |
register int bool, true_val, false_val; |
int bool, true_val, false_val; |
|
|
bool = lor(); |
bool = lor(); |
if (skipws() != '?') { |
if (skipws() != '?') { |
|
|
static int |
static int |
lor() |
lor() |
{ |
{ |
register int c, vl, vr; |
int c, vl, vr; |
|
|
vl = land(); |
vl = land(); |
while ((c = skipws()) == '|') { |
while ((c = skipws()) == '|') { |
|
|
static int |
static int |
land() |
land() |
{ |
{ |
register int c, vl, vr; |
int c, vl, vr; |
|
|
vl = not(); |
vl = not(); |
while ((c = skipws()) == '&') { |
while ((c = skipws()) == '&') { |
|
|
static int |
static int |
not() |
not() |
{ |
{ |
register int val, c; |
int val, c; |
|
|
if ((c = skipws()) == '!' && getch() != '=') { |
if ((c = skipws()) == '!' && getch() != '=') { |
ungetch(); |
ungetch(); |
|
|
static int |
static int |
eqrel() |
eqrel() |
{ |
{ |
register int vl, vr, eqrel; |
int vl, vr, eqrel; |
|
|
vl = shift(); |
vl = shift(); |
while ((eqrel = geteqrel()) != -1) { |
while ((eqrel = geteqrel()) != -1) { |
|
|
static int |
static int |
shift() |
shift() |
{ |
{ |
register int vl, vr, c; |
int vl, vr, c; |
|
|
vl = primary(); |
vl = primary(); |
while (((c = skipws()) == '<' || c == '>') && getch() == c) { |
while (((c = skipws()) == '<' || c == '>') && getch() == c) { |
|
|
static int |
static int |
primary() |
primary() |
{ |
{ |
register int c, vl, vr; |
int c, vl, vr; |
|
|
vl = term(); |
vl = term(); |
while ((c = skipws()) == '+' || c == '-') { |
while ((c = skipws()) == '+' || c == '-') { |
|
|
static int |
static int |
term() |
term() |
{ |
{ |
register int c, vl, vr; |
int c, vl, vr; |
|
|
vl = exp(); |
vl = exp(); |
while ((c = skipws()) == '*' || c == '/' || c == '%') { |
while ((c = skipws()) == '*' || c == '/' || c == '%') { |
|
|
static int |
static int |
exp() |
exp() |
{ |
{ |
register int c, vl, vr, n; |
int c, vl, vr, n; |
|
|
vl = unary(); |
vl = unary(); |
switch (c = skipws()) { |
switch (c = skipws()) { |
|
|
static int |
static int |
unary() |
unary() |
{ |
{ |
register int val, c; |
int val, c; |
|
|
if ((c = skipws()) == '+' || c == '-' || c == '~') { |
if ((c = skipws()) == '+' || c == '-' || c == '~') { |
val = unary(); |
val = unary(); |
|
|
static int |
static int |
factor() |
factor() |
{ |
{ |
register int val; |
int val; |
|
|
if (skipws() == '(') { |
if (skipws() == '(') { |
val = query(); |
val = query(); |
|
|
static int |
static int |
constant() |
constant() |
{ |
{ |
register int i; |
int i; |
register int value; |
int value; |
register int c; |
int c; |
int v[sizeof(int)]; |
int v[sizeof(int)]; |
|
|
if (skipws() != '\'') { |
if (skipws() != '\'') { |
|
|
static int |
static int |
num() |
num() |
{ |
{ |
register int rval, c, base; |
int rval, c, base; |
int ndig; |
int ndig; |
|
|
rval = 0; |
rval = 0; |
|
|
experr("bad constant"); |
experr("bad constant"); |
|
|
return rval; |
return rval; |
|
|
} |
} |
|
|
/* |
/* |
|
|
static int |
static int |
geteqrel() |
geteqrel() |
{ |
{ |
register int c1, c2; |
int c1, c2; |
|
|
c1 = skipws(); |
c1 = skipws(); |
c2 = getch(); |
c2 = getch(); |
|
|
static int |
static int |
skipws() |
skipws() |
{ |
{ |
register int c; |
int c; |
|
|
while ((c = getch()) <= ' ' && c > EOS) |
while ((c = getch()) <= ' ' && c > EOS) |
; |
; |
|
|
*/ |
*/ |
static void |
static void |
experr(msg) |
experr(msg) |
char *msg; |
char *msg; |
{ |
{ |
printf("m4: %s in expr.\n", msg); |
printf("m4: %s in expr.\n", msg); |
longjmp(expjump, -1); |
longjmp(expjump, -1); |