Skip to content

Commit 28baf70

Browse files
committed
Vars Management-> WIP
1 parent c0f3da6 commit 28baf70

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

src/VariableDefinition.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "VariableDefinition.h"
2+
3+
namespace FPL {
4+
Statement::Statement(StatementKind kind, std::string name, Type type) {
5+
StatementType = type;
6+
StatementName = name;
7+
StatementKind{kind};
8+
}
9+
10+
void VariableDefinition::GiveValue(const std::string &value) {
11+
std::cout << VariableName << " de type " << VariableType.mName << " aura la valeur " << value;
12+
13+
if (VariableType.mType == ENTIER_LITERAL) {
14+
15+
} else if (VariableType.mType == DECIMAL_LITERAL) {
16+
17+
} else if (VariableType.mType == CHAINE_LITERAL) {
18+
19+
} else {
20+
21+
}
22+
}
23+
}

src/VariableDefinition.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#pragma once
2+
3+
#include <iostream>
4+
#include <string>
5+
#include <map>
6+
7+
#include "TokenBuilding.h"
8+
#include "TypeManager.h"
9+
10+
namespace FPL {
11+
12+
enum class StatementKind: int {
13+
VARIABLE_DECLARATION,
14+
FUNCTION_CALL,
15+
LITTERAL
16+
};
17+
18+
static const char* sStatementKindStrings[] = {
19+
"VARIABLE_DECLARATION",
20+
"FUNCTION_CALL",
21+
"LITTERAL"
22+
};
23+
24+
class Statement {
25+
public:
26+
Statement(StatementKind kind, std::string name, Type type);
27+
28+
std::string StatementName;
29+
Type StatementType{Type("void", VOID)};
30+
StatementKind kind{};
31+
};
32+
33+
class VariableDefinition {
34+
public:
35+
//VariableDefinition(std::string name, std::string typeName, enum BUILTIN_TYPE type) : VariableName(name), VariableType(Type(typeName, type)){};
36+
37+
std::string VariableName;
38+
Type VariableType;
39+
40+
int valueVarI; // Valeur si c'est un int
41+
double valueVarD; // Valeur si c'est un décimal
42+
std::string valueVarS; // Valeur si c'est une chaine de caractere (en FPL, texte)
43+
44+
void GiveValue(const std::string &value);
45+
};
46+
}

0 commit comments

Comments
 (0)