TODO state machine
This commit is contained in:
parent
e63380461d
commit
d34936b229
BIN
TP1/.DS_Store
vendored
Normal file
BIN
TP1/.DS_Store
vendored
Normal file
Binary file not shown.
5
TP1/parseur/.vscode/settings.json
vendored
Normal file
5
TP1/parseur/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"stdio.h": "c"
|
||||
}
|
||||
}
|
61
TP1/parseur/main.c
Normal file
61
TP1/parseur/main.c
Normal file
@ -0,0 +1,61 @@
|
||||
#include <stdio.h>
|
||||
#include "main.h"
|
||||
|
||||
enum Etats curEtat;
|
||||
FILE *fp;
|
||||
|
||||
void AnalyseFicher(const char *nomFichier) {
|
||||
fp = fopen(*nomFichier, "rt");
|
||||
char c;
|
||||
while ((c=fgetc(fp)) != EOF)
|
||||
{
|
||||
enum EEtat ret = AnalyseProchaineBalise(c);
|
||||
if (ret == EEtatErreur) {
|
||||
printf("Error");
|
||||
break;
|
||||
}
|
||||
if (ret = EEtatTermine){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum EEtat AnalyseProchaineBalise(char c) {
|
||||
switch (curEtat)
|
||||
{
|
||||
case SEtatDebut:
|
||||
if (c == '<') {
|
||||
curEtat = SEtat1;
|
||||
}
|
||||
break;
|
||||
case SEtat1:
|
||||
if (c == '/') {
|
||||
curEtat = SEtat2;
|
||||
} else {
|
||||
curEtat = SEtat3;
|
||||
}
|
||||
break;
|
||||
case SEtat2:
|
||||
if (c == '>') {
|
||||
curEtat = SEtatFin;
|
||||
}
|
||||
break;
|
||||
case SEtat3:
|
||||
if (c == '>') {
|
||||
curEtat = SEtatFin;
|
||||
}
|
||||
break;
|
||||
case SEtatFin:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
curEtat = SEtatDebut;
|
||||
|
||||
return 0;
|
||||
}
|
18
TP1/parseur/main.h
Normal file
18
TP1/parseur/main.h
Normal file
@ -0,0 +1,18 @@
|
||||
enum Etats
|
||||
{
|
||||
SEtatDebut,
|
||||
SEtat1,
|
||||
SEtat2,
|
||||
SEtat3,
|
||||
SEtatFin
|
||||
};
|
||||
|
||||
enum EEtat
|
||||
{
|
||||
EEtatErreur,
|
||||
EEtatTermine,
|
||||
EEtatContinue
|
||||
};
|
||||
|
||||
void PileInit();
|
||||
void PilePush();
|
BIN
TP1/read_file/a.out
Executable file
BIN
TP1/read_file/a.out
Executable file
Binary file not shown.
BIN
TP1/read_file/main
Executable file
BIN
TP1/read_file/main
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user