1181834Sroberto/* itbl-lex.l
2181834Sroberto   Copyright 1997, 1998, 2001, 2002, 2005, 2006
3181834Sroberto   Free Software Foundation, Inc.
4181834Sroberto
5181834Sroberto   This file is part of GAS, the GNU Assembler.
6181834Sroberto
7181834Sroberto   GAS is free software; you can redistribute it and/or modify
8181834Sroberto   it under the terms of the GNU General Public License as published by
9181834Sroberto   the Free Software Foundation; either version 2, or (at your option)
10181834Sroberto   any later version.
11181834Sroberto
12181834Sroberto   GAS is distributed in the hope that it will be useful,
13181834Sroberto   but WITHOUT ANY WARRANTY; without even the implied warranty of
14181834Sroberto   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15181834Sroberto   GNU General Public License for more details.
16181834Sroberto
17181834Sroberto   You should have received a copy of the GNU General Public License
18181834Sroberto   along with GAS; see the file COPYING.  If not, write to the Free
19181834Sroberto   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20181834Sroberto   02110-1301, USA.  */
21181834Sroberto
22181834Sroberto%{
23181834Sroberto#include "as.h"
24181834Sroberto#include "itbl-lex.h"
25181834Sroberto#include <itbl-parse.h>
26181834Sroberto
27181834Sroberto#ifdef DEBUG
28181834Sroberto#define DBG(x) printf x
29181834Sroberto#define MDBG(x) printf x
30181834Sroberto#else
31181834Sroberto#define DBG(x)
32181834Sroberto#define MDBG(x)
33181834Sroberto#endif
34181834Sroberto
35181834Srobertoint insntbl_line = 1;
36181834Sroberto%}
37181834Sroberto
38181834SrobertoALNUM	[A-Za-z0-9_]
39181834SrobertoDIGIT	[0-9]
40181834SrobertoALPHA	[A-Za-z_]
41181834SrobertoHEX	[0-9A-Fa-f]
42181834Sroberto
43181834Sroberto%%
44181834Sroberto
45181834Sroberto"creg"|"CREG" {
46181834Sroberto    return CREG;
47181834Sroberto  }
48181834Sroberto"dreg"|"DREG" {
49181834Sroberto    return DREG;
50181834Sroberto  }
51181834Sroberto"greg"|"GREG" {
52181834Sroberto    return GREG;
53181834Sroberto  }
54181834Sroberto"immed"|"IMMED" {
55181834Sroberto    return IMMED;
56181834Sroberto  }
57181834Sroberto"addr"|"ADDR" {
58181834Sroberto    return ADDR;
59181834Sroberto  }
60181834Sroberto"insn"|"INSN" {
61181834Sroberto    return INSN;
62181834Sroberto  }
63181834Sroberto"p"{DIGIT} {
64181834Sroberto    yytext[yyleng] = 0;
65181834Sroberto    yylval.processor = strtoul (yytext+1, 0, 0);
66181834Sroberto    return PNUM;
67181834Sroberto  }
68181834Sroberto{DIGIT}+ {
69181834Sroberto    yytext[yyleng] = 0;
70181834Sroberto    yylval.num = strtoul (yytext, 0, 0);
71181834Sroberto    return NUM;
72181834Sroberto  }
73181834Sroberto"0x"{HEX}+ {
74181834Sroberto    yytext[yyleng] = 0;
75181834Sroberto    yylval.num = strtoul (yytext, 0, 0);
76181834Sroberto    return NUM;
77181834Sroberto  }
78181834Sroberto{ALPHA}{ALNUM}*	{
79181834Sroberto    yytext[yyleng] = 0;
80181834Sroberto    yylval.str = strdup (yytext);
81181834Sroberto    return ID;
82181834Sroberto  }
83181834Sroberto";"|"#"	{
84181834Sroberto    int c;
85181834Sroberto    while ((c = input ()) !=  EOF)
86181834Sroberto      {
87181834Sroberto        if (c ==  '\n')
88181834Sroberto    	{
89181834Sroberto    		unput (c);
90181834Sroberto    		break;
91181834Sroberto    	}
92181834Sroberto      }
93181834Sroberto  }
94181834Sroberto"\n"	{
95181834Sroberto    insntbl_line++;
96181834Sroberto    MDBG (("in lex, NL = %d (x%x)\n", NL, NL));
97181834Sroberto    return NL;
98181834Sroberto  }
99181834Sroberto" "|"\t" {
100181834Sroberto  }
101181834Sroberto. {
102181834Sroberto    MDBG (("char = %x, %d\n", yytext[0], yytext[0]));
103181834Sroberto    return yytext[0];
104181834Sroberto  }
105181834Sroberto%%
106181834Sroberto
107181834Sroberto#ifndef yywrap
108181834Srobertoint
109181834Srobertoyywrap ()
110181834Sroberto  {
111181834Sroberto    return 1;
112181834Sroberto  }
113181834Sroberto#endif
114181834Sroberto