Suppression des .classs et mise à jour du parser (Il faut des tabs désormais pour les commandes) + Ajout du test n°8

This commit is contained in:
Moncef STITI 2025-02-08 19:23:39 +01:00
parent eb08e7ea85
commit 1790ccbd94
39 changed files with 26 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -23,7 +23,7 @@ public class BakefileParser {
* Regex pour détecter les lignes de commande associées à une target.
* Format : " gcc -o program program.c" (ligne indentée)
*/
private static final Pattern COMMAND_PATTERN = Pattern.compile("^\\s+(.+)$");
private static final Pattern COMMAND_PATTERN = Pattern.compile("^\\t(.+)$");
/**
* Regex pour détecter les définitions de variables.
@ -61,12 +61,24 @@ public class BakefileParser {
String currentTarget = null;
List<String> dependencies = new ArrayList<>();
List<String> commands = new ArrayList<>();
int lineNumber = 0;
for (String line : lines) {
lineNumber++;
Matcher varMatcher = VARIABLE_PATTERN.matcher(line);
Matcher targetMatcher = TARGET_PATTERN.matcher(line);
Matcher commandMatcher = COMMAND_PATTERN.matcher(line);
if (line.trim().isEmpty()) {
continue;
}
if (line.matches("^ +.*$")) { // Détecte les lignes commençant par des espaces
System.err.println(filename + ":" + lineNumber + ": *** missing separator. Stop.");
System.exit(1);
}
if (varMatcher.matches()) {
// Stocke la variable
variables.put(varMatcher.group(1), varMatcher.group(2));

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,6 @@
all:
echo "Cette ligne est correcte"
test_espaces:
echo "Cette ligne utilise une tabulation"
echo "Cette ligne utilise des espaces et doit provoquer une erreur"

@ -0,0 +1,6 @@
all:
echo "Cette ligne est correcte"
test_espaces:
echo "Cette ligne utilise une tabulation"
echo "Cette ligne utilise des espaces et doit provoquer une erreur"

Binary file not shown.

Binary file not shown.

Binary file not shown.