xref: /csrg-svn/bin/sh/arith_lex.l (revision 69274)
154333Smarc %{
260701Sbostic /*-
360701Sbostic  * Copyright (c) 1993
460701Sbostic  *	The Regents of the University of California.  All rights reserved.
560701Sbostic  *
660701Sbostic  * This code is derived from software contributed to Berkeley by
760701Sbostic  * Kenneth Almquist.
860701Sbostic  *
960701Sbostic  * %sccs.include.redist.c%
1060701Sbostic  */
1160701Sbostic 
1260701Sbostic #ifndef lint
13*69274Schristos static char sccsid[] = "@(#)arith_lex.l	8.3 (Berkeley) 05/04/95";
1460701Sbostic #endif /* not lint */
1560701Sbostic 
16*69274Schristos #include <unistd.h>
1754333Smarc #include "y.tab.h"
18*69274Schristos #include "error.h"
1960701Sbostic 
2054333Smarc extern yylval;
2154333Smarc extern char *arith_buf, *arith_startbuf;
2254333Smarc #undef YY_INPUT
2354333Smarc #define YY_INPUT(buf,result,max) \
2454333Smarc 	result = (*buf = *arith_buf++) ? 1 : YY_NULL;
2554333Smarc %}
2654333Smarc 
2754333Smarc %%
2854333Smarc [ \t\n]	{ ; }
2968929Sbostic [0-9]+	{ yylval = atol(yytext); return(ARITH_NUM); }
3068929Sbostic "("	{ return(ARITH_LPAREN); }
3168929Sbostic ")"	{ return(ARITH_RPAREN); }
3268929Sbostic "||"	{ return(ARITH_OR); }
3368929Sbostic "&&"	{ return(ARITH_AND); }
3468929Sbostic "|"	{ return(ARITH_BOR); }
3568929Sbostic "^"	{ return(ARITH_BXOR); }
3668929Sbostic "&"	{ return(ARITH_BAND); }
3768929Sbostic "=="	{ return(ARITH_EQ); }
3868929Sbostic "!="	{ return(ARITH_NE); }
3968929Sbostic ">"	{ return(ARITH_GT); }
4068929Sbostic ">="	{ return(ARITH_GE); }
4168929Sbostic "<"	{ return(ARITH_LT); }
4268929Sbostic "<="	{ return(ARITH_LE); }
4368929Sbostic "<<"	{ return(ARITH_LSHIFT); }
4468929Sbostic ">>"	{ return(ARITH_RSHIFT); }
4568929Sbostic "*"	{ return(ARITH_MUL); }
4668929Sbostic "/"	{ return(ARITH_DIV); }
4768929Sbostic "%"	{ return(ARITH_REM); }
4868929Sbostic "+"	{ return(ARITH_ADD); }
4968929Sbostic "-"	{ return(ARITH_SUB); }
5068929Sbostic "~"	{ return(ARITH_BNOT); }
5168929Sbostic "!"	{ return(ARITH_NOT); }
5254333Smarc .	{ error("arith: syntax error: \"%s\"\n", arith_startbuf); }
5354333Smarc %%
5454333Smarc 
55*69274Schristos void
5654333Smarc arith_lex_reset() {
5754333Smarc 	YY_NEW_FILE;
5854333Smarc }
59