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