1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1985-2011 AT&T Intellectual Property * 1N/A* and is licensed under the * 1N/A* Common Public License, Version 1.0 * 1N/A* by AT&T Intellectual Property * 1N/A* A copy of the License is available at * 1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 1N/A* Information and Software Systems Research * 1N/A* Glenn Fowler <gsf@research.att.com> * 1N/A* David Korn <dgk@research.att.com> * 1N/A* Phong Vo <kpv@research.att.com> * 1N/A***********************************************************************/ 1N/A * AT&T Bell Laboratories 1N/A * long integer arithmetic expression evaluator 1N/A * long constants may be represented as: 1N/A * 0[xX]hhh hexadecimal 1N/A * n#ccc base n, 2 <= b <= 36 1N/A * NOTE: all operands are evaluated as both the parse 1N/A * and evaluation are done on the fly 1N/Atypedef struct /* expression handle */ 1N/A * set error message string 1N/A * evaluate a subexpression with precedence 1N/A if (c ==
'=') n = n == x;
1N/A if (c ==
'<') n <<= x;
1N/A if (c ==
'<') n = n <= x;
1N/A if (c ==
'<') n = n < x;
1N/A if (c ==
'+') n += x;
1N/A if (c ==
'*') n *= x;
1N/A else if (c ==
'/') n /= x;
1N/A * evaluate an integer arithmetic expression in s 1N/A * (long)(*convert)(const char* string, char** end, void* handle) 1N/A * is a user supplied conversion routine that is called when unknown 1N/A * chars are encountered; string points to the part to be 1N/A * converted and end is adjusted to point to the next non-converted 1N/A * character; if string is 0 then end points to an error message string 1N/A * NOTE: (*convert)() may call strexpr(ex, )