Initial revision
[binutils.git] / gas / itbl-lex.l
bloba905ddd007a19a56000dadf2a205e0ae15457f5d
1 /* itbl-lex.l
2    Copyright (C) 1997  Free Software Foundation, Inc.
4    This file is part of GAS, the GNU Assembler.
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.
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.
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, 59 Temple Place - Suite 330, Boston, MA
19    02111-1307, USA.  */
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdlib.h>
25 #include <ctype.h>
26 #include "itbl-parse.h"
28 #ifdef DEBUG
29 #define DBG(x) printf x
30 #define MDBG(x) printf x
31 #else
32 #define DBG(x)
33 #define MDBG(x)
34 #endif
36 int insntbl_line = 1;
39 ALNUM   [A-Za-z0-9_]
40 DIGIT   [0-9]
41 ALPHA   [A-Za-z_]
42 HEX     [0-9A-Fa-f]
46 "creg"|"CREG" {
47     return CREG;
48   }
49 "dreg"|"DREG" {
50     return DREG;
51   }
52 "greg"|"GREG" {
53     return GREG;
54   }
55 "immed"|"IMMED" {
56     return IMMED;
57   }
58 "addr"|"ADDR" {
59     return ADDR;
60   }
61 "insn"|"INSN" {
62     return INSN;
63   }
64 "p"{DIGIT} {
65     yytext[yyleng] = 0;
66     yylval.processor = strtoul (yytext+1, 0, 0);
67     return PNUM;
68   }
69 {DIGIT}+ {
70     yytext[yyleng] = 0;
71     yylval.num = strtoul (yytext, 0, 0);
72     return NUM;
73   }
74 "0x"{HEX}+ {
75     yytext[yyleng] = 0;
76     yylval.num = strtoul (yytext, 0, 0);
77     return NUM;
78   }
79 {ALPHA}{ALNUM}* {
80     yytext[yyleng] = 0;
81     yylval.str = strdup (yytext);
82     return ID;
83   }
84 ";"|"#" {
85     int c;
86     while ((c = input ()) !=  EOF) 
87       {
88         if (c ==  '\n') 
89         {
90                 unput (c);
91                 break;
92         }
93       }
94   }
95 "\n"    { 
96     insntbl_line++; 
97     MDBG (("in lex, NL = %d (x%x)\n", NL, NL));
98     return NL; 
99   }
100 " "|"\t" { 
101   }
102 . {
103     MDBG (("char = %x, %d\n", yytext[0], yytext[0]));
104     return yytext[0];
105   }
108 #ifndef yywrap
109 int 
110 yywrap () 
111   { 
112     return 1; 
113   }
114 #endif