Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2003-06-24 04:13:14 +0000
committerAlain Magloire2003-06-24 04:13:14 +0000
commit64bf394e6844cf0e18bf3b8d8f119b2c26430c70 (patch)
tree083b0958c736b68a11d34167e0c68f72eb4509c8
parentda6cf42803f4981eee44d17146fa16284a236dde (diff)
downloadorg.eclipse.cdt-64bf394e6844cf0e18bf3b8d8f119b2c26430c70.tar.gz
org.eclipse.cdt-64bf394e6844cf0e18bf3b8d8f119b2c26430c70.tar.xz
org.eclipse.cdt-64bf394e6844cf0e18bf3b8d8f119b2c26430c70.zip
Parsing scheme for Preprocessor
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java58
1 files changed, 57 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java
index f4cb190e2c0..03cfe1a6638 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java
@@ -13,7 +13,27 @@ import org.eclipse.core.resources.IFile;
public class GCCErrorParser implements IErrorParser {
public boolean processLine(String line, ErrorParserManager eoParser) {
- // gcc: "filename:linenumber:column: error_desc"
+ // Known patterns.
+ // (a)
+ // filename:lineno: description
+ //
+ // (b)
+ // filename:lineno:column: description
+ //
+ // (b)
+ // In file included from b.h:2,
+ // from a.h:3,
+ // from hello.c:3:
+ // c.h:2:15: missing ')' in macro parameter list
+ //
+ // (c)
+ // h.c: In function `main':
+ // h.c:41: `foo' undeclared (first use in this function)
+ // h.c:41: (Each undeclared identifier is reported only once
+ // h.c:41: for each function it appears in.)
+ // h.c:41: parse error before `char'
+ // h.c:75: `p' undeclared (first use in this function)
+
int firstColon = line.indexOf(':');
/* Guard against drive in Windows platform. */
@@ -113,8 +133,38 @@ public class GCCErrorParser implements IErrorParser {
varName = desc.substring(desc.indexOf("`") + 1, p);
//System.out.println("prev varName "+ varName);
}
+ } else if ((s = desc.indexOf("parse error before ")) != -1) {
+ int p = desc.indexOf("\'", s);
+ if (p != -1) {
+ varName = desc.substring(desc.indexOf("`") + 1, p);
+ //System.out.println("prev varName "+ varName);
+ }
}
+ if (eoParser.getScratchBuffer().startsWith("In file included from ")) {
+ if (line.startsWith("from ")) {
+ eoParser.appendToScratchBuffer(line);
+ return false;
+ }
+ String buffer = eoParser.getScratchBuffer();
+ eoParser.clearScratchBuffer();
+ int from = -1;
+ while ((from = buffer.lastIndexOf("from ")) != -1) {
+ String buf = buffer.substring(from + 5);
+ buffer = buffer.substring(0, from);
+ if (buf.endsWith(",")) {
+ int coma = buf.lastIndexOf(',');
+ StringBuffer b = new StringBuffer(buf);
+ b.setCharAt(coma, ':');
+ b.append(' ').append(buffer).append(" from ").append(line);
+ buf = b.toString();
+ } else {
+ buf = buf + ' ' + buffer + " from " + line;
+ }
+ processLine(buf, eoParser);
+ }
+ }
+
IFile file = eoParser.findFilePath(fileName);
if (file == null) {
@@ -147,6 +197,12 @@ public class GCCErrorParser implements IErrorParser {
desc = desc +"[" + fileName + "]";
}
eoParser.generateMarker(file, num, desc, severity, varName);
+ } else {
+ if (line.startsWith("In file included from ")) {
+ eoParser.appendToScratchBuffer(line);
+ } else if (line.startsWith("from ")) {
+ eoParser.appendToScratchBuffer(line);
+ }
}
} catch (StringIndexOutOfBoundsException e) {
} catch (NumberFormatException e) {

Back to the top