xref: /openbsd-src/gnu/usr.bin/binutils-2.17/binutils/syslex.l (revision 3d8817e467ea46cf4772788d6804dd293abfb01a)
1*3d8817e4Smiod %{
2*3d8817e4Smiod /* Copyright 2001, 2003, 2005 Free Software Foundation, Inc.
3*3d8817e4Smiod 
4*3d8817e4Smiod This file is part of GNU Binutils.
5*3d8817e4Smiod 
6*3d8817e4Smiod This program is free software; you can redistribute it and/or modify
7*3d8817e4Smiod it under the terms of the GNU General Public License as published by
8*3d8817e4Smiod the Free Software Foundation; either version 2, or (at your option)
9*3d8817e4Smiod any later version.
10*3d8817e4Smiod 
11*3d8817e4Smiod This program is distributed in the hope that it will be useful,
12*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
13*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*3d8817e4Smiod GNU General Public License for more details.
15*3d8817e4Smiod 
16*3d8817e4Smiod You should have received a copy of the GNU General Public License
17*3d8817e4Smiod along with GLD; see the file COPYING.  If not, write to the Free
18*3d8817e4Smiod Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19*3d8817e4Smiod 02110-1301, USA.  */
20*3d8817e4Smiod 
21*3d8817e4Smiod #include "config.h"
22*3d8817e4Smiod #ifdef HAVE_STRING_H
23*3d8817e4Smiod #include <string.h>
24*3d8817e4Smiod #else
25*3d8817e4Smiod #ifdef HAVE_STRINGS_H
26*3d8817e4Smiod #include <strings.h>
27*3d8817e4Smiod #endif
28*3d8817e4Smiod #endif
29*3d8817e4Smiod #include "sysinfo.h"
30*3d8817e4Smiod 
31*3d8817e4Smiod #define YY_NO_UNPUT
32*3d8817e4Smiod 
33*3d8817e4Smiod #ifndef yywrap
yywrap(void)34*3d8817e4Smiod static int yywrap (void) { return 1; }
35*3d8817e4Smiod #endif
36*3d8817e4Smiod 
37*3d8817e4Smiod extern int yylex (void);
38*3d8817e4Smiod %}
39*3d8817e4Smiod %%
40*3d8817e4Smiod "(" { return '(';}
41*3d8817e4Smiod ")" { return ')';}
42*3d8817e4Smiod "[" { return '[';}
43*3d8817e4Smiod "]" { return ']';}
44*3d8817e4Smiod " " { ; }
45*3d8817e4Smiod ";".* { ; }
46*3d8817e4Smiod "\t" { ; }
47*3d8817e4Smiod "\n" { ; }
48*3d8817e4Smiod "\""[^\"]*"\"" {
49*3d8817e4Smiod 	yylval.s = malloc (yyleng - 1);
50*3d8817e4Smiod 	memcpy (yylval.s, yytext + 1, yyleng - 2);
51*3d8817e4Smiod 	yylval.s[yyleng - 2] = '\0';
52*3d8817e4Smiod         return NAME;
53*3d8817e4Smiod 	}
54*3d8817e4Smiod 
55*3d8817e4Smiod 0x[0-9a-f]+ {
56*3d8817e4Smiod         yylval.i = strtol(yytext,0,16);
57*3d8817e4Smiod 	return  NUMBER;
58*3d8817e4Smiod 	}
59*3d8817e4Smiod 
60*3d8817e4Smiod [0-9]+ {
61*3d8817e4Smiod         yylval.i = atoi(yytext);
62*3d8817e4Smiod 	return  NUMBER;
63*3d8817e4Smiod 	}
64*3d8817e4Smiod 
65*3d8817e4Smiod 
66*3d8817e4Smiod "bits" { yylval.i =1 ;return UNIT;}
67*3d8817e4Smiod "bit" { yylval.i = 1; return UNIT;}
68*3d8817e4Smiod "bytes" { yylval.i= 8; return UNIT;}
69*3d8817e4Smiod "byte" { yylval.i = 8; return UNIT;}
70*3d8817e4Smiod 
71*3d8817e4Smiod "int" { yylval.s = "INT"; return TYPE;}
72*3d8817e4Smiod "barray" { yylval.s = "BARRAY"; return TYPE;}
73*3d8817e4Smiod "chars" { yylval.s = "CHARS"; return TYPE;}
74*3d8817e4Smiod "variable" { yylval.i = 0; return NUMBER;}
75*3d8817e4Smiod "counted" { yylval.i = -4; return NUMBER;}
76*3d8817e4Smiod "addrsize" { yylval.i = -2; return NUMBER; }
77*3d8817e4Smiod "segsize" { yylval.i = -1; return NUMBER; }
78*3d8817e4Smiod "cond" { return COND;}
79*3d8817e4Smiod "repeat" { return REPEAT;}
80