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:
parent
eb08e7ea85
commit
1790ccbd94
bakefile.jar
build/fr/monlouyan/bakefile
BakeCLI.classBakeEngine.classBakefileParser.classCommandExecutor.classDependencyResolver.classMain.classRule.classTimestampManager.class
src/fr/monlouyan/bakefile
tests
C
bakefile.jar
test-01-from-nothing
test-02-already-exist
test-03-circular
test-04-edited
test-05-variables
test-06-variables-on-cascade
test-08-space-vs-tabulation
Java
bakefile.jar
BIN
bakefile.jar
BIN
bakefile.jar
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.
@ -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.
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.
6
tests/C/test-08-space-vs-tabulation/bake/Bakefile
Normal file
6
tests/C/test-08-space-vs-tabulation/bake/Bakefile
Normal file
@ -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"
|
6
tests/C/test-08-space-vs-tabulation/make/Makefile
Normal file
6
tests/C/test-08-space-vs-tabulation/make/Makefile
Normal file
@ -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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user