1 %{ 2 /*- 3 * Copyright (c) 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Kenneth Almquist. 8 * 9 * %sccs.include.redist.c% 10 */ 11 12 #ifndef lint 13 static char sccsid[] = "@(#)arith_lex.l 8.3 (Berkeley) 05/04/95"; 14 #endif /* not lint */ 15 16 #include <unistd.h> 17 #include "y.tab.h" 18 #include "error.h" 19 20 extern yylval; 21 extern char *arith_buf, *arith_startbuf; 22 #undef YY_INPUT 23 #define YY_INPUT(buf,result,max) \ 24 result = (*buf = *arith_buf++) ? 1 : YY_NULL; 25 %} 26 27 %% 28 [ \t\n] { ; } 29 [0-9]+ { yylval = atol(yytext); return(ARITH_NUM); } 30 "(" { return(ARITH_LPAREN); } 31 ")" { return(ARITH_RPAREN); } 32 "||" { return(ARITH_OR); } 33 "&&" { return(ARITH_AND); } 34 "|" { return(ARITH_BOR); } 35 "^" { return(ARITH_BXOR); } 36 "&" { return(ARITH_BAND); } 37 "==" { return(ARITH_EQ); } 38 "!=" { return(ARITH_NE); } 39 ">" { return(ARITH_GT); } 40 ">=" { return(ARITH_GE); } 41 "<" { return(ARITH_LT); } 42 "<=" { return(ARITH_LE); } 43 "<<" { return(ARITH_LSHIFT); } 44 ">>" { return(ARITH_RSHIFT); } 45 "*" { return(ARITH_MUL); } 46 "/" { return(ARITH_DIV); } 47 "%" { return(ARITH_REM); } 48 "+" { return(ARITH_ADD); } 49 "-" { return(ARITH_SUB); } 50 "~" { return(ARITH_BNOT); } 51 "!" { return(ARITH_NOT); } 52 . { error("arith: syntax error: \"%s\"\n", arith_startbuf); } 53 %% 54 55 void 56 arith_lex_reset() { 57 YY_NEW_FILE; 58 } 59