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