-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlexer.lex
More file actions
48 lines (43 loc) · 1.11 KB
/
lexer.lex
File metadata and controls
48 lines (43 loc) · 1.11 KB
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
/*
BOGADO GARCIA Maximino
L3 Informatique
lexer.lex
*/
%{
#include <string.h>
#include "parser.h"
%}
%option nounput
%option noinput
NOMBRE 0|[1-9][0-9]*
ID [a-zA-Z][a-zA-Z0-9]*
COMMENTAIRE #.*\n
%%
{COMMENTAIRE} {/* ne rien faire */}
"<-" {return AFFECT;}
[%)(*/+-] {return yytext[0];}
[<>=] {return yytext[0];}
"<=" {return EGAL_P;}
">=" {return EGAL_G;}
"!=" {return NON_EGAL;}
"OU" {return OU;}
"ET" {return ET;}
"SI" {return SI;}
"ALORS" {return ALORS;}
"SINON" {return SINON;}
"FSI" {return FSI;}
"NON" {return NON;}
"DEBUT" {return DEBUT;}
"VAR" {return VAR;}
"FAIRE" {return FAIRE;}
"FTQ" {return FTQ;}
"FIN" {return FIN;}
"TQ" {return TQ;}
"LIRE" {return LIRE;}
"AFFICHER" {return AFFICHER;}
"\n" {return NL;}
{ID} {strcpy(yylval.id,yytext);return ID;}
{NOMBRE} {yylval.nb = atoi(yytext); return NB;}
[ \t] {}
. {fprintf(stderr, "[err lexer] caractere inconnu %c\n",yytext[0]); return 1;}
%%