xref: /openbsd/gnu/usr.bin/binutils/binutils/syslex.l (revision 007c2a45)
12159047fSniklas %{
2*007c2a45Smiod /* Copyright 2001, 2003 Free Software Foundation, Inc.
35f210c2aSfgsch 
45f210c2aSfgsch This file is part of GLD, the Gnu Linker.
55f210c2aSfgsch 
65f210c2aSfgsch GLD is free software; you can redistribute it and/or modify
75f210c2aSfgsch it under the terms of the GNU General Public License as published by
85f210c2aSfgsch the Free Software Foundation; either version 2, or (at your option)
95f210c2aSfgsch any later version.
105f210c2aSfgsch 
115f210c2aSfgsch GLD is distributed in the hope that it will be useful,
125f210c2aSfgsch but WITHOUT ANY WARRANTY; without even the implied warranty of
135f210c2aSfgsch MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
145f210c2aSfgsch GNU General Public License for more details.
155f210c2aSfgsch 
165f210c2aSfgsch You should have received a copy of the GNU General Public License
175f210c2aSfgsch along with GLD; see the file COPYING.  If not, write to the Free
185f210c2aSfgsch Software Foundation, 59 Temple Place - Suite 330, Boston, MA
195f210c2aSfgsch 02111-1307, USA.  */
205f210c2aSfgsch 
212159047fSniklas #include "sysinfo.h"
222159047fSniklas char *word;
232159047fSniklas int number;
242159047fSniklas int unit;
252159047fSniklas 
262159047fSniklas #ifndef yywrap
yywrap(void)27*007c2a45Smiod static int yywrap (void) { return 1; }
282159047fSniklas #endif
292159047fSniklas %}
302159047fSniklas %%
312159047fSniklas "(" { return '(';}
322159047fSniklas ")" { return ')';}
332159047fSniklas "[" { return '[';}
342159047fSniklas "]" { return ']';}
352159047fSniklas " " { ; }
362159047fSniklas ";".* { ; }
372159047fSniklas "\t" { ; }
382159047fSniklas "\n" { ; }
392159047fSniklas "\""[^\"]*"\"" {
402159047fSniklas yylval.s = malloc(strlen (yytext));
412159047fSniklas strcpy(yylval.s, yytext+1);
422159047fSniklas yylval.s[strlen(yylval.s)-1] = 0;
432159047fSniklas         return NAME;
442159047fSniklas 	}
452159047fSniklas 
462159047fSniklas 0x[0-9a-f]+ {
472159047fSniklas         yylval.i = strtol(yytext,0,16);
482159047fSniklas 	return  NUMBER;
492159047fSniklas 	}
502159047fSniklas 
512159047fSniklas [0-9]+ {
522159047fSniklas         yylval.i = atoi(yytext);
532159047fSniklas 	return  NUMBER;
542159047fSniklas 	}
552159047fSniklas 
562159047fSniklas 
572159047fSniklas "bits" { yylval.i =1 ;return UNIT;}
582159047fSniklas "bit" { yylval.i = 1; return UNIT;}
592159047fSniklas "bytes" { yylval.i= 8; return UNIT;}
602159047fSniklas "byte" { yylval.i = 8; return UNIT;}
612159047fSniklas 
622159047fSniklas "int" { yylval.s = "INT"; return TYPE;}
632159047fSniklas "barray" { yylval.s = "BARRAY"; return TYPE;}
642159047fSniklas "chars" { yylval.s = "CHARS"; return TYPE;}
652159047fSniklas "variable" { yylval.i = 0; return NUMBER;}
662159047fSniklas "counted" { yylval.i = -4; return NUMBER;}
672159047fSniklas "addrsize" { yylval.i = -2; return NUMBER; }
682159047fSniklas "segsize" { yylval.i = -1; return NUMBER; }
692159047fSniklas "cond" { return COND;}
702159047fSniklas "repeat" { return REPEAT;}
71