-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagnes.l
More file actions
68 lines (63 loc) · 2.75 KB
/
Copy pathagnes.l
File metadata and controls
68 lines (63 loc) · 2.75 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*** Definition SECTION ***/
%{
#include <string>
// structure pour stocker les adresses pour les sauts condistionnels et autres...
typedef struct addr {
int ic_goto;
int ic_false;
} t_address;
typedef struct type_ {
double aDouble;
char aString[256];
bool aBool;
} t_type;
#include "agnes.y.hpp"
using namespace std;
%}
%option noyywrap
%option yylineno
/*** Rules SECTION ***/
%%
[ \t\n]+ ; // ignore all whitespace
\/[*]([^*]|([*][^/]))*[*]+\/ { } // printf("%s\n", yytext); A rajouter si on veux afficher les commentaires
\"(.*?)\" { strcpy(yylval.aString, yytext); return TEXT; }
pi|PI|π { return PI; }
"cos"|"cosinus" { return COS; }
"sin"|"sinus" { return SIN; }
"tan"|"tangente" { return TAN; }
";"|"point virgule" { return SEPARATOR; }
"+"|"plus" { return PLUS; }
"-"|"moins" { return MINUS; }
"*"|"fois"|"multiplié par" { return MULTIPLY; }
"/"|"divisé par" { return DIVIDE; }
"("|"parenthèse gauche" { return LP; }
")"|"parenthèse droite" { return RP; }
"{"|"accolade gauche" { return LA; }
"}"|"accolade droite" { return RA; }
">>"|"afficher" { return PRINT; }
"<<"|"entrer" { return INPUT; }
"=="|"egal a"|"égal à" { return IFEQUAL; }
"!="|"different de"|"différent de" { return IFDIFFERENT; }
"="|"egal"|"égal" { return EQUAL; }
"répéter"|"réitérer" { return REPEAT; }
"HTML"|"html" { return HTML; }
"JSON"|"json" { return JSON; }
"btc"|"BTC" { return BTC; }
"lancer"|"LANCER"|"Lancer"|"launch"|"Launch"|"LAUNCH" { return LAUNCH; }
"tant que"|"Tant que"|"while" { return WHILE; }
"si"|"SI"|"Si" { return IF; }
"Pour"|"pour" { return FOR; }
"allant de" { return FOR2; }
"Sinon"|"sinon"|"SINON" { return ELSE; }
"inférieur à"|"<"|"inferieur a" { return INF; }
"supérieur à"|">"|"superieur a" { return SUP; }
"inférieur ou égal à"|"<="|"inferieur ou egal a" { return INFOREQUAL; }
"supérieur ou égal à"|">="|"superieur ou egal a" { return SUPOREQUAL; }
"factoriel"|"!" { return FACT; }
[a-zA-Z][a-zA-Z0-9]* { strcpy(yylval.aString, yytext); return VARIABLE; }
[0-9]+(\.[0-9]+)? { yylval.aDouble = atof(yytext); return NUMBER; }
. { }
%%
int yyerror(char* str) {
fprintf(stderr,"[Erreur][Ligne %d] %s\n",yylineno-1,str);
}