xref: /original-bsd/bin/sh/arith_lex.l (revision 00695d63)
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.2 (Berkeley) 04/27/95";
14 #endif /* not lint */
15 
16 #include "y.tab.h"
17 
18 extern yylval;
19 extern char *arith_buf, *arith_startbuf;
20 #undef YY_INPUT
21 #define YY_INPUT(buf,result,max) \
22 	result = (*buf = *arith_buf++) ? 1 : YY_NULL;
23 %}
24 
25 %%
26 [ \t\n]	{ ; }
27 [0-9]+	{ yylval = atol(yytext); return(ARITH_NUM); }
28 "("	{ return(ARITH_LPAREN); }
29 ")"	{ return(ARITH_RPAREN); }
30 "||"	{ return(ARITH_OR); }
31 "&&"	{ return(ARITH_AND); }
32 "|"	{ return(ARITH_BOR); }
33 "^"	{ return(ARITH_BXOR); }
34 "&"	{ return(ARITH_BAND); }
35 "=="	{ return(ARITH_EQ); }
36 "!="	{ return(ARITH_NE); }
37 ">"	{ return(ARITH_GT); }
38 ">="	{ return(ARITH_GE); }
39 "<"	{ return(ARITH_LT); }
40 "<="	{ return(ARITH_LE); }
41 "<<"	{ return(ARITH_LSHIFT); }
42 ">>"	{ return(ARITH_RSHIFT); }
43 "*"	{ return(ARITH_MUL); }
44 "/"	{ return(ARITH_DIV); }
45 "%"	{ return(ARITH_REM); }
46 "+"	{ return(ARITH_ADD); }
47 "-"	{ return(ARITH_SUB); }
48 "~"	{ return(ARITH_BNOT); }
49 "!"	{ return(ARITH_NOT); }
50 .	{ error("arith: syntax error: \"%s\"\n", arith_startbuf); }
51 %%
52 
53 arith_lex_reset() {
54 	YY_NEW_FILE;
55 }
56