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