mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Fix to the parser
This commit is contained in:
parent
b871d57ad8
commit
78f034de45
1 changed files with 36 additions and 13 deletions
|
@ -73,6 +73,7 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
startLine = endLine + 1;
|
startLine = endLine + 1;
|
||||||
endLine = reader.getLineNumber();
|
endLine = reader.getLineNumber();
|
||||||
|
|
||||||
// Strip away any comments.
|
// Strip away any comments.
|
||||||
int pound = MakefileUtil.indexOfComment(line);
|
int pound = MakefileUtil.indexOfComment(line);
|
||||||
if (pound != -1) {
|
if (pound != -1) {
|
||||||
|
@ -81,22 +82,35 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
stmt.setLines(startLine, endLine);
|
stmt.setLines(startLine, endLine);
|
||||||
addStatement(stmt);
|
addStatement(stmt);
|
||||||
line = line.substring(0, pound);
|
line = line.substring(0, pound);
|
||||||
|
// If all we have left are spaces continue
|
||||||
|
if (MakefileUtil.isEmptyLine(line)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Empty lines ?
|
||||||
if (MakefileUtil.isEmptyLine(line)) {
|
if (MakefileUtil.isEmptyLine(line)) {
|
||||||
// Empty Line.
|
// Empty Line.
|
||||||
Statement stmt = new EmptyLine();
|
Statement stmt = new EmptyLine();
|
||||||
stmt.setLines(startLine, endLine);
|
stmt.setLines(startLine, endLine);
|
||||||
addStatement(stmt);
|
addStatement(stmt);
|
||||||
} else if (MakefileUtil.isCommand(line)) {
|
continue;
|
||||||
// Command.
|
}
|
||||||
|
|
||||||
|
// Is this a command ?
|
||||||
|
if (MakefileUtil.isCommand(line)) {
|
||||||
Command cmd = new Command(line);
|
Command cmd = new Command(line);
|
||||||
|
// The commands are added to a Rule
|
||||||
if (rule != null) {
|
if (rule != null) {
|
||||||
rule.addCommand(cmd);
|
rule.addCommand(cmd);
|
||||||
rule.setEndLine(endLine);
|
rule.setEndLine(endLine);
|
||||||
} else {
|
continue;
|
||||||
throw new IOException("Error Parsing");
|
|
||||||
}
|
}
|
||||||
} else if (MakefileUtil.isInferenceRule(line)) {
|
// If it is not a command give the other a chance a fallthrough
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for inference rule.
|
||||||
|
if (MakefileUtil.isInferenceRule(line)) {
|
||||||
// Inference Rule
|
// Inference Rule
|
||||||
String tgt;
|
String tgt;
|
||||||
int index = MakefileUtil.indexOf(line, ':');
|
int index = MakefileUtil.indexOf(line, ':');
|
||||||
|
@ -108,12 +122,10 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
rule = new InferenceRule(new Target(tgt));
|
rule = new InferenceRule(new Target(tgt));
|
||||||
rule.setLines(startLine, endLine);
|
rule.setLines(startLine, endLine);
|
||||||
addStatement(rule);
|
addStatement(rule);
|
||||||
} else if (MakefileUtil.isMacroDefinition(line)) {
|
continue;
|
||||||
// MacroDefinition
|
}
|
||||||
Statement stmt = new MacroDefinition(line);
|
|
||||||
stmt.setLines(startLine, endLine);
|
if (MakefileUtil.isTargetRule(line)) {
|
||||||
addStatement(stmt);
|
|
||||||
} else if (MakefileUtil.isTargetRule(line)) {
|
|
||||||
String[] targets;
|
String[] targets;
|
||||||
String[] reqs = new String[0];
|
String[] reqs = new String[0];
|
||||||
String cmd = null;
|
String cmd = null;
|
||||||
|
@ -146,11 +158,22 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
rule.addCommand(new Command(cmd));
|
rule.addCommand(new Command(cmd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
continue;
|
||||||
Statement stmt = new BadStatement(line);
|
}
|
||||||
|
|
||||||
|
// Macro Definiton ?
|
||||||
|
if (MakefileUtil.isMacroDefinition(line)) {
|
||||||
|
// MacroDefinition
|
||||||
|
Statement stmt = new MacroDefinition(line);
|
||||||
stmt.setLines(startLine, endLine);
|
stmt.setLines(startLine, endLine);
|
||||||
addStatement(stmt);
|
addStatement(stmt);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Should not be here.
|
||||||
|
Statement stmt = new BadStatement(line);
|
||||||
|
stmt.setLines(startLine, endLine);
|
||||||
|
addStatement(stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue