-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcal.l
66 lines (38 loc) · 1.04 KB
/
cal.l
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
62
63
64
65
66
%{
#include "simple.h"
unsigned int lineno=1;
bool error_lexical=false;
%}
%option noyywrap
nombre 0|[1-9][[:digit:]]*
variable_identificateur A|B|C|D|E
%%
{nombre} {
sscanf(yytext, "%ld", &yylval.nombre);
return TOK_NOMBRE;
}
"BEGIN" {return TOK_BEGIN;}
"FIN." {return TOK_FIN;}
"afficher" {return TOK_AFFICHER;}
":=" {return TOK_AFFECT;}
"+" {return TOK_UNION;}
"-" {return TOK_DIFF;}
"*" {return TOK_INTER;}
"(" {return TOK_PARG;}
")" {return TOK_PARD;}
"{" {return TOK_PG;}
"}" {return TOK_PD;}
";" {return TOK_FINSTR;}
"," {return TOK_VER;}
"\n" {lineno++;}
{variable_identificateur} {
yylval.texte = yytext;
return TOK_VARB;
}
" "|"\t" {}
. {
fprintf(stderr,"\tERREUR : Lexeme inconnu a la ligne %d. Il s'agit de %s et comporte %d lettre(s)\n",lineno,yytext,yyleng);
error_lexical=true;
return yytext[0];
}
%%