* The Regents of the University of California. All rights reserved.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
static char sccsid[] = "@(#)arith_lex.l 8.1 (Berkeley) %G%";
extern char *arith_buf, *arith_startbuf;
#define YY_INPUT(buf,result,max) \
result = (*buf = *arith_buf++) ? 1 : YY_NULL;
[0-9]+ { arith_wasoper = 0; yylval = atol(yytext); return(ARITH_NUM); }
"(" { arith_wasoper = 1; return(ARITH_LPAREN); }
")" { arith_wasoper = 0; return(ARITH_RPAREN); }
"||" { arith_wasoper = 1; return(ARITH_OR); }
"&&" { arith_wasoper = 1; return(ARITH_AND); }
"==" { arith_wasoper = 1; return(ARITH_EQ); }
">" { arith_wasoper = 1; return(ARITH_GT); }
">=" { arith_wasoper = 1; return(ARITH_GEQ); }
"<" { arith_wasoper = 1; return(ARITH_LT); }
"<=" { arith_wasoper = 1; return(ARITH_LEQ); }
"!=" { arith_wasoper = 1; return(ARITH_NEQ); }
"*" { arith_wasoper = 1; return(ARITH_MULT); }
"/" { arith_wasoper = 1; return(ARITH_DIV); }
"%" { arith_wasoper = 1; return(ARITH_REM); }
"+" { if (!arith_wasoper) { /* ignore unary plus */
"-" { if (arith_wasoper) {
return(ARITH_UNARYMINUS);
"!" { arith_wasoper = 1; return(ARITH_NOT); }
. { error("arith: syntax error: \"%s\"\n", arith_startbuf); }