diff options
author | Shevek <[email protected]> | 2009-03-31 13:15:12 +0000 |
---|---|---|
committer | Shevek <[email protected]> | 2009-03-31 13:15:12 +0000 |
commit | 5b560840be18a2920f77752925f0882fabe6422c (patch) | |
tree | 68f49f13857ec7c492411ea1d1c416044900bc28 /src/java/org/anarres | |
parent | 15ab0955dd6da2ff0bdad791b190a93039e8edbd (diff) |
Fix comments in macros. Fix EOF killing jcpp. Allow macros after whitespace.
Diffstat (limited to 'src/java/org/anarres')
-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; |