misc cleanup
[unix-history] / usr / src / bin / sh / arith_lex.l
CommitLineData
0dd4a4ec 1%{
3d987f16
KB
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
34a1a05a 13static char sccsid[] = "@(#)arith_lex.l 8.3 (Berkeley) %G%";
3d987f16
KB
14#endif /* not lint */
15
34a1a05a 16#include <unistd.h>
0dd4a4ec 17#include "y.tab.h"
34a1a05a 18#include "error.h"
3d987f16 19
0dd4a4ec
MT
20extern yylval;
21extern char *arith_buf, *arith_startbuf;
0dd4a4ec
MT
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] { ; }
c1cfba10
KB
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); }
0dd4a4ec
MT
52. { error("arith: syntax error: \"%s\"\n", arith_startbuf); }
53%%
54
34a1a05a 55void
0dd4a4ec
MT
56arith_lex_reset() {
57 YY_NEW_FILE;
58}