This commit was generated by cvs2svn to track changes on a CVS vendor
[platform/upstream/binutils.git] / gas / itbl-lex.l
1
2 /* itbl-lex.l
3
4    Copyright (C) 1997  Free Software Foundation, Inc.
5
6    This file is part of GAS, the GNU Assembler.
7
8    GAS 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 2, or (at your option)
11    any later version.
12
13    GAS 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.
17
18    You should have received a copy of the GNU General Public License
19    along with GAS; see the file COPYING.  If not, write to the Free
20    Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21    02111-1307, USA.  */
22
23 %{
24 #include <stdio.h>
25 #include <string.h>
26 #include <stdlib.h>
27 #include <ctype.h>
28 #include "itbl-parse.h"
29
30 #ifdef DEBUG
31 #define DBG(x) printf x
32 #define MDBG(x) printf x
33 #else
34 #define DBG(x)
35 #define MDBG(x)
36 #endif
37
38 int insntbl_line = 1;
39 %}
40
41 ALNUM   [A-Za-z0-9_]
42 DIGIT   [0-9]
43 ALPHA   [A-Za-z_]
44 HEX     [0-9A-Fa-f]
45
46 %%
47
48 "creg"|"CREG" {
49     return CREG;
50   }
51 "dreg"|"DREG" {
52     return DREG;
53   }
54 "greg"|"GREG" {
55     return GREG;
56   }
57 "immed"|"IMMED" {
58     return IMMED;
59   }
60 "addr"|"ADDR" {
61     return ADDR;
62   }
63 "insn"|"INSN" {
64     return INSN;
65   }
66 "p"{DIGIT} {
67     yytext[yyleng] = 0;
68     yylval.processor = strtoul (yytext+1, 0, 0);
69     return PNUM;
70   }
71 {DIGIT}+ {
72     yytext[yyleng] = 0;
73     yylval.num = strtoul (yytext, 0, 0);
74     return NUM;
75   }
76 "0x"{HEX}+ {
77     yytext[yyleng] = 0;
78     yylval.num = strtoul (yytext, 0, 0);
79     return NUM;
80   }
81 {ALPHA}{ALNUM}* {
82     yytext[yyleng] = 0;
83     yylval.str = strdup (yytext);
84     return ID;
85   }
86 ";"|"#" {
87     int c;
88     while ((c = input ()) !=  EOF) 
89       {
90         if (c ==  '\n') 
91         {
92                 unput (c);
93                 break;
94         }
95       }
96   }
97 "\n"    { 
98     insntbl_line++; 
99     MDBG (("in lex, NL = %d (x%x)\n", NL, NL));
100     return NL; 
101   }
102 " "|"\t" { 
103   }
104 . {
105     MDBG (("char = %x, %d\n", yytext[0], yytext[0]));
106     return yytext[0];
107   }
108 %%
109
110 int 
111 yywrap () 
112   { 
113     return 1; 
114   }