diff options
author | Shevek <[email protected]> | 2008-06-14 22:42:09 +0000 |
---|---|---|
committer | Shevek <[email protected]> | 2008-06-14 22:42:09 +0000 |
commit | aba944f23747fdf35e890020cdbbca722bbaaacf (patch) | |
tree | ba247d276402039f5c75d00312a40bf5581715a2 /src/java/org/anarres/cpp/Source.java | |
parent | 0e479d174065605b32892be1a7fc5f789ea2e255 (diff) |
remove quadratic getName; close lexers; add debug flags
Diffstat (limited to 'src/java/org/anarres/cpp/Source.java')
-rw-r--r-- | src/java/org/anarres/cpp/Source.java | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/java/org/anarres/cpp/Source.java b/src/java/org/anarres/cpp/Source.java index f6cd3b8..d69a5c2 100644 --- a/src/java/org/anarres/cpp/Source.java +++ b/src/java/org/anarres/cpp/Source.java @@ -18,6 +18,7 @@ package org.anarres.cpp; import java.io.BufferedReader; +import java.io.Closeable; import java.io.File; import java.io.FileReader; import java.io.IOException; @@ -42,7 +43,7 @@ import static org.anarres.cpp.Token.*; * * BUG: Error messages are not handled properly. */ -public abstract class Source implements Iterable<Token> { +public abstract class Source implements Iterable<Token>, Closeable { private Source parent; private boolean autopop; private PreprocessorListener listener; @@ -137,23 +138,15 @@ public abstract class Source implements Iterable<Token> { */ /* pp */ String getPath() { Source parent = getParent(); - while (parent != null) { - String path = parent.getPath(); - if (path != null) - return path; - parent = parent.getParent(); - } + if (parent != null) + return parent.getPath(); return null; } /* pp */ String getName() { Source parent = getParent(); - while (parent != null) { - String name = parent.getName(); - if (name != null) - return name; - parent = parent.getParent(); - } + if (parent != null) + return parent.getName(); return null; } @@ -287,4 +280,8 @@ public abstract class Source implements Iterable<Token> { throw new LexerException("Warning at " + line + ":" + column + ": " + msg); } + public void close() + throws IOException { + } + } |