-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLexer.cpp
More file actions
55 lines (49 loc) · 1.27 KB
/
Copy pathLexer.cpp
File metadata and controls
55 lines (49 loc) · 1.27 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
#include "Lexer.h"
Symbole * Lexer::Consulter() {
if (!tampon) {
if (tete==flux.length())
tampon = new Symbole(FIN);
else
{
switch (flux[tete]) {
case '(':
tampon = new Symbole(OPENPAR);
tete++;
break;
case ')':
tampon = new Symbole(CLOSEPAR);
tete++;
break;
case '*':
tampon = new Symbole(MULT);
tete++;
break;
case '+':
tampon = new Symbole(PLUS);
tete++;
break;
default:
if (flux[tete]<='9' && flux[tete]>='0') {
int resultat = flux[tete]-'0';
int i=1;
while (flux[tete+i]<='9' && flux[tete+i]>='0') {
resultat = resultat*10+(flux[tete+i]-'0');
i++;
}
tete = tete+i;
tampon = new Entier(resultat);
}
else {
tampon = new Symbole(ERREUR);
}
}
}
}
return tampon;
}
void Lexer::Avancer() {
tampon = nullptr;
}
void Lexer::setSymbole(Symbole* s) {
tampon = s;
}