Branch data Line data Source code
1 : : %top{
2 : : #ifdef HAVE_CONFIG_H
3 : : # include <config.h>
4 : : #endif
5 : : }
6 : :
7 : : %{
8 : : /* Copyright (C) 2004, 2005, 2007, 2008 Red Hat, Inc.
9 : : Written by Ulrich Drepper <drepper@redhat.com>, 2004.
10 : :
11 : : This file is free software; you can redistribute it and/or modify
12 : : it under the terms of either
13 : :
14 : : * the GNU Lesser General Public License as published by the Free
15 : : Software Foundation; either version 3 of the License, or (at
16 : : your option) any later version
17 : :
18 : : or
19 : :
20 : : * the GNU General Public License as published by the Free
21 : : Software Foundation; either version 2 of the License, or (at
22 : : your option) any later version
23 : :
24 : : or both in parallel, as here.
25 : :
26 : : elfutils is distributed in the hope that it will be useful, but
27 : : WITHOUT ANY WARRANTY; without even the implied warranty of
28 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 : : General Public License for more details.
30 : :
31 : : You should have received copies of the GNU General Public License and
32 : : the GNU Lesser General Public License along with this program. If
33 : : not, see <http://www.gnu.org/licenses/>. */
34 : :
35 : : #include <ctype.h>
36 : :
37 : : #include <libeu.h>
38 : : #include "system.h"
39 : : #include "i386_parse.h"
40 : :
41 : :
42 : : static void eat_to_eol (void);
43 : : static void invalid_char (int ch);
44 : : %}
45 : :
46 : : ID [a-zA-Z_][a-zA-Z0-9_/]*
47 : : ID2 [a-zA-Z0-9_:/]*
48 : : NUMBER [0-9]+
49 : : WHITE [[:space:]]+
50 : :
51 : : %option yylineno
52 : : %option never-interactive
53 : : %option noyywrap
54 : :
55 : :
56 : : %x MAIN
57 : :
58 : : %%
59 : :
60 : : "%mask" { return kMASK; }
61 : 4 :
62 : 4 : "%prefix" { return kPREFIX; }
63 [ + - ]: 4 : "%suffix" { return kSUFFIX; }
64 : 14 :
65 [ + - ]: 4 : "%synonym" { return kSYNONYM; }
66 [ + - ]: 10 :
67 : 94 : {NUMBER} { i386_lval.num = strtoul (yytext, NULL, 10);
68 [ + - ]: 188 : return kNUMBER; }
69 : 2 :
70 : 2 : "%%" { BEGIN (MAIN); return kPERCPERC; }
71 [ + - ]: 2 :
72 : 13145 :
73 [ + - ]: 13145 : <MAIN>"0" { return '0'; }
74 : 13839 : <MAIN>"1" { return '1'; }
75 : 21426 :
76 [ + - ]: 13839 : <INITIAL,MAIN>"{"{ID2}"}" { i386_lval.str = xstrndup (yytext + 1,
77 [ + - ]: 7587 : yyleng - 2);
78 : 7587 : return kBITFIELD; }
79 : 18 :
80 : 36 : <MAIN>"INVALID" { i386_lval.str = (void *) -1l;
81 [ + - ]: 18 : return kID; }
82 : 1587 :
83 : 1587 : <MAIN>{ID} { i386_lval.str = xstrndup (yytext, yyleng);
84 [ + - ]: 3174 : return kID; }
85 : 4317 :
86 : 4317 : <MAIN>"," { return ','; }
87 [ + - ]: 4317 :
88 : 1501 : <MAIN>":" { return ':'; }
89 [ + - ]: 1501 :
90 : 0 : <INITIAL,MAIN>^"\n" { /* IGNORE */ }
91 : :
92 [ # # ]: 0 : <INITIAL,MAIN>"\n" { return '\n'; }
93 : 120 :
94 [ + - ]: 1613 : <INITIAL,MAIN>^"#" { eat_to_eol (); }
95 [ + - ]: 120 :
96 : 218 : {WHITE} { /* IGNORE */ }
97 : :
98 [ - + ]: 218 : <MAIN>{WHITE} { return kSPACE; }
99 : 112 :
100 [ + - ]: 1434 : <MAIN>. { i386_lval.ch = *yytext; return kCHAR; }
101 [ + - ]: 112 :
102 : 0 : . { invalid_char (*yytext); }
103 [ # # ]: 0 :
104 : 0 :
105 [ # # ]: 0 : %%
106 : 0 :
107 : : static void
108 : 120 : eat_to_eol (void)
109 : : {
110 : 1502 : while (1)
111 : : {
112 : 1502 : int c = input ();
113 : :
114 [ + + ]: 1502 : if (c == EOF || c == '\n')
115 : : break;
116 : : }
117 : 120 : }
118 : :
119 : : static void
120 : 0 : invalid_char (int ch)
121 : : {
122 [ # # ]: 0 : error (0, 0, (isascii (ch)
123 : 0 : ? _("invalid character '%c' at line %d; ignored")
124 : 0 : : _("invalid character '\\%o' at line %d; ignored")),
125 : : ch, yylineno);
126 : 0 : }
127 : :
128 : : // Local Variables:
129 : : // mode: C
130 : : // End:
|