diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/anarres/cpp/JavaFileSystem.java | 11 | ||||
-rw-r--r-- | src/java/org/anarres/cpp/LexerSource.java | 13 | ||||
-rw-r--r-- | src/java/org/anarres/cpp/Source.java | 5 |
3 files changed, 25 insertions, 4 deletions
diff --git a/src/java/org/anarres/cpp/JavaFileSystem.java b/src/java/org/anarres/cpp/JavaFileSystem.java index fab7721..83a5caa 100644 --- a/src/java/org/anarres/cpp/JavaFileSystem.java +++ b/src/java/org/anarres/cpp/JavaFileSystem.java @@ -55,7 +55,16 @@ public class JavaFileSystem implements VirtualFileSystem { @Override public JavaFile getParentFile() { - return new JavaFile(getParent()); + String parent = getParent(); + if (parent != null) + return new JavaFile(parent); + File absolute = getAbsoluteFile(); + parent = absolute.getParent(); + /* + if (parent == null) + return null; + */ + return new JavaFile(parent); } public JavaFile getChildFile(String name) { diff --git a/src/java/org/anarres/cpp/LexerSource.java b/src/java/org/anarres/cpp/LexerSource.java index 22df78f..d252569 100644 --- a/src/java/org/anarres/cpp/LexerSource.java +++ b/src/java/org/anarres/cpp/LexerSource.java @@ -288,7 +288,7 @@ public class LexerSource extends Source { LexerException { int d = read(); switch (d) { - case 'a': text.append('a'); return 0x0a; + case 'a': text.append('a'); return 0x07; case 'b': text.append('b'); return '\b'; case 'f': text.append('f'); return '\f'; case 'n': text.append('n'); return '\n'; @@ -791,7 +791,16 @@ public class LexerSource extends Source { } } - bol = false; + if (bol) { + switch (tok.getType()) { + case WHITESPACE: + case CCOMMENT: + break; + default: + bol = false; + break; + } + } tok.setLocation(_l, _c); if (DEBUG) diff --git a/src/java/org/anarres/cpp/Source.java b/src/java/org/anarres/cpp/Source.java index 49277c7..5f50a86 100644 --- a/src/java/org/anarres/cpp/Source.java +++ b/src/java/org/anarres/cpp/Source.java @@ -247,7 +247,10 @@ public abstract class Source implements Iterable<Token>, Closeable { /* XXX Are we sure about this? */ warning(tok.getLine(), tok.getColumn(), "No newline before end of file"); - return tok; + return new Token(NL, + tok.getLine(), tok.getColumn(), + "\n"); + // return tok; case NL: /* This may contain one or more newlines. */ return tok; |