26 mai 2026
Voici un diagramme UML PlantUML représentant l’architecture
principale du projet. J’ai volontairement simplifié certains détails STL
(vector, unique_ptr, itérateurs) pour mettre
en évidence les concepts métier et les relations importantes.
@startuml
skinparam classAttributeIconSize 0
namespace logo {
class Interpreter {
- myProgram : Program
- myCallStack : vector<ExecutionContext>
+ startProgram()
+ nextStep()
+ isProgramRunning()
+ pushNewContext()
+ currentInstruction()
+ currentPos()
+ endOfBlock()
}
class Program {
- myInstructions : InstructionList
- myFunctions : FunctionList
- isMainProgram : bool
+ display()
+ findSubProgram(name)
}
class ExecutionContext {
- myCurrentPos
- myEndOfBlock
- myVariables : map<string,int>
- myInterpreter : Interpreter
+ variable(name)
+ currentPos()
+ endOfBlock()
+ setCurrentPos()
}
abstract class Instruction {
+ execute()
+ getNext()
+ display()
# doExecute()
# doGetNext()
# doDisplay()
}
class UnaryInstruction {
# myParameter : int
}
class Move {
- isForward : bool
}
class Turn {
- isClockwise : bool
}
class SetPenPos {
- isUp : bool
}
class FunctionCall {
- myName : string
- myMainProgram : Program
}
class ParseError
}
namespace turtle {
class TurtleRuntime {
+ turtleX : double
+ turtleY : double
+ turtleDir : double
+ turtlePenDown : bool
+ initTurtle()
+ redraw()
+ drawLine()
+ waitEnd()
+ interrupt()
}
}
' =====================
' Héritage
' =====================
Instruction <|-- UnaryInstruction
UnaryInstruction <|-- Move
UnaryInstruction <|-- Turn
Instruction <|-- SetPenPos
Instruction <|-- FunctionCall
ParseError --|> RuntimeException
' =====================
' Associations
' =====================
Interpreter *-- Program
Interpreter *-- ExecutionContext
ExecutionContext --> Interpreter
Program *-- Instruction
Program *-- Program : fonctions
FunctionCall --> Program : recherche fonction
Instruction ..> Interpreter
Move ..> TurtleRuntime
Turn ..> TurtleRuntime
SetPenPos ..> TurtleRuntime
@enduml
Si vous devez maintenir ou faire évoluer le projet (par exemple
ajouter REPETE, des variables ou la génération SVG), je
vous recommande également de représenter les flux d’exécution :
Lexer
|
v
Program
|
v
Instruction
|
v
Interpreter
|
v
ExecutionContext (pile d'appels)
|
v
Turtle
Les classes les plus importantes à comprendre sont :
| Classe | Rôle |
|---|---|
Lexer |
Transforme le texte en tokens |
Program |
Parse les tokens et construit les objets Instruction |
Instruction |
Classe de base du langage |
Interpreter |
Exécute le programme |
ExecutionContext |
Gère la pile d’appels des fonctions |
FunctionCall |
Appel de procédure Logo |
Move, Turn, SetPenPos |
Instructions concrètes |
Turtle |
Backend graphique SFML |
Pour une documentation de maintenance, j’ajouterais également un
diagramme de séquence UML de l’exécution d’un appel de fonction
Logo, car c’est la partie la plus subtile du projet (gestion de
myCallStack, FunctionCall::doExecute() et
Interpreter::nextStep()).