itbl-lex.l revision 107493
1/* itbl-lex.l
2   Copyright 1997, 1998, 2001 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, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.  */
20
21%{
22#include <stdio.h>
23#include <string.h>
24#include <stdlib.h>
25
26#include <itbl-parse.h>
27
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
35
36int insntbl_line = 1;
37%}
38
39ALNUM	[A-Za-z0-9_]
40DIGIT	[0-9]
41ALPHA	[A-Za-z_]
42HEX	[0-9A-Fa-f]
43
44%%
45
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  }
106%%
107
108#ifndef yywrap
109int
110yywrap ()
111  {
112    return 1;
113  }
114#endif
115