aboutsummaryrefslogtreecommitdiff
path: root/gas/config/loongarch-lex.l
blob: d96f77ea40b9cc5daae409966c1db228f78f0989 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
%option noyywrap
/*
   Copyright (C) 2021-2022 Free Software Foundation, Inc.

   This file is part of GAS, the GNU Assembler.

   GAS is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GAS is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING3.  If not,
   see <http://www.gnu.org/licenses/>.  */
%{
#include "as.h"
#include "loongarch-parse.h"

/* Flex generates static functions "input" & "unput" which are not used.  */
#define YY_NO_INPUT
#define YY_NO_UNPUT
%}

D	[0-9]
/* We consider anything greater than \x7f to be a "letter" for UTF-8
   support.  See the lex_type array in ../read.c.  */
L	[a-zA-Z_\.\$\x80-\xff]
H	[0-9A-Fa-f]

hex	0[xX]{H}+
oct	0[0-7]+
bin	0[bB][01]+
dec	([1-9]{D}*)|0
id	({D}+[fb])|({L}({D}|{L})*)|(:{dec}[bf])
ws	[ \t\v\f]+

%%

{dec}	{ yylval.imm = strtoull (yytext, 0, 0); return INTEGER; }
{hex}	{ yylval.imm = strtoull (yytext + 2, 0, 16); return INTEGER; }
{bin}	{ yylval.imm = strtoull (yytext + 2, 0, 2); return INTEGER; }
{oct}	{ yylval.imm = strtoull (yytext + 1, 0, 8); return INTEGER; }
{id}	{ yylval.c_str = strdup (yytext);return IDENTIFIER; }
{ws}	{ }

">>"	{ return RIGHT_OP; }
"<<"	{ return LEFT_OP; }
"&&"	{ return AND_OP; }
"||"	{ return OR_OP; }
"<="	{ return LE_OP; }
">="	{ return GE_OP; }
"=="	{ return EQ_OP; }
"!="	{ return NE_OP; }
.	{ return yytext[0];}

%%