itbl-lex.l revision 38889
133965Sjdp/* itbl-lex.l
233965Sjdp   Copyright (C) 1997  Free Software Foundation, Inc.
333965Sjdp
433965Sjdp   This file is part of GAS, the GNU Assembler.
533965Sjdp
633965Sjdp   GAS is free software; you can redistribute it and/or modify
733965Sjdp   it under the terms of the GNU General Public License as published by
833965Sjdp   the Free Software Foundation; either version 2, or (at your option)
933965Sjdp   any later version.
1033965Sjdp
1133965Sjdp   GAS is distributed in the hope that it will be useful,
1233965Sjdp   but WITHOUT ANY WARRANTY; without even the implied warranty of
1333965Sjdp   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1433965Sjdp   GNU General Public License for more details.
1533965Sjdp
1633965Sjdp   You should have received a copy of the GNU General Public License
1733965Sjdp   along with GAS; see the file COPYING.  If not, write to the Free
1833965Sjdp   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
1933965Sjdp   02111-1307, USA.  */
2033965Sjdp
2133965Sjdp%{
2233965Sjdp#include <stdio.h>
2333965Sjdp#include <string.h>
2433965Sjdp#include <stdlib.h>
2533965Sjdp#include <ctype.h>
2633965Sjdp#include "itbl-parse.h"
2733965Sjdp
2833965Sjdp#ifdef DEBUG
2933965Sjdp#define DBG(x) printf x
3033965Sjdp#define MDBG(x) printf x
3133965Sjdp#else
3233965Sjdp#define DBG(x)
3333965Sjdp#define MDBG(x)
3433965Sjdp#endif
3533965Sjdp
3633965Sjdpint insntbl_line = 1;
3733965Sjdp%}
3833965Sjdp
3933965SjdpALNUM	[A-Za-z0-9_]
4033965SjdpDIGIT	[0-9]
4133965SjdpALPHA	[A-Za-z_]
4233965SjdpHEX	[0-9A-Fa-f]
4333965Sjdp
4433965Sjdp%%
4533965Sjdp
4633965Sjdp"creg"|"CREG" {
4733965Sjdp    return CREG;
4833965Sjdp  }
4933965Sjdp"dreg"|"DREG" {
5033965Sjdp    return DREG;
5133965Sjdp  }
5233965Sjdp"greg"|"GREG" {
5333965Sjdp    return GREG;
5433965Sjdp  }
5533965Sjdp"immed"|"IMMED" {
5633965Sjdp    return IMMED;
5733965Sjdp  }
5833965Sjdp"addr"|"ADDR" {
5933965Sjdp    return ADDR;
6033965Sjdp  }
6133965Sjdp"insn"|"INSN" {
6233965Sjdp    return INSN;
6333965Sjdp  }
6433965Sjdp"p"{DIGIT} {
6533965Sjdp    yytext[yyleng] = 0;
6633965Sjdp    yylval.processor = strtoul (yytext+1, 0, 0);
6733965Sjdp    return PNUM;
6833965Sjdp  }
6933965Sjdp{DIGIT}+ {
7033965Sjdp    yytext[yyleng] = 0;
7133965Sjdp    yylval.num = strtoul (yytext, 0, 0);
7233965Sjdp    return NUM;
7333965Sjdp  }
7433965Sjdp"0x"{HEX}+ {
7533965Sjdp    yytext[yyleng] = 0;
7633965Sjdp    yylval.num = strtoul (yytext, 0, 0);
7733965Sjdp    return NUM;
7833965Sjdp  }
7933965Sjdp{ALPHA}{ALNUM}*	{
8033965Sjdp    yytext[yyleng] = 0;
8133965Sjdp    yylval.str = strdup (yytext);
8233965Sjdp    return ID;
8333965Sjdp  }
8433965Sjdp";"|"#"	{
8533965Sjdp    int c;
8633965Sjdp    while ((c = input ()) !=  EOF)
8733965Sjdp      {
8833965Sjdp        if (c ==  '\n')
8933965Sjdp    	{
9033965Sjdp    		unput (c);
9133965Sjdp    		break;
9233965Sjdp    	}
9333965Sjdp      }
9433965Sjdp  }
9533965Sjdp"\n"	{
9633965Sjdp    insntbl_line++;
9733965Sjdp    MDBG (("in lex, NL = %d (x%x)\n", NL, NL));
9833965Sjdp    return NL;
9933965Sjdp  }
10033965Sjdp" "|"\t" {
10133965Sjdp  }
10233965Sjdp. {
10333965Sjdp    MDBG (("char = %x, %d\n", yytext[0], yytext[0]));
10433965Sjdp    return yytext[0];
10533965Sjdp  }
10633965Sjdp%%
10733965Sjdp
10838889Sjdp#ifndef yywrap
10933965Sjdpint
11033965Sjdpyywrap ()
11133965Sjdp  {
11233965Sjdp    return 1;
11333965Sjdp  }
11438889Sjdp#endif
115