diff options
author | Shevek <[email protected]> | 2009-02-06 01:10:48 +0000 |
---|---|---|
committer | Shevek <[email protected]> | 2009-02-06 01:10:48 +0000 |
commit | 24cb38b8398ddc3bc70a544c98a0acb3366ff8bc (patch) | |
tree | 84adb390dd167c189f94a7cf1952ca36903aeda6 | |
parent | aba944f23747fdf35e890020cdbbca722bbaaacf (diff) |
start on objc
-rw-r--r-- | etc/MANIFEST | 2 | ||||
-rw-r--r-- | etc/targets/global-jar.xml | 2 | ||||
-rw-r--r-- | etc/targets/global-tar.xml | 2 | ||||
-rw-r--r-- | src/java/org/anarres/cpp/Feature.java | 5 | ||||
-rw-r--r-- | src/java/org/anarres/cpp/Macro.java | 25 | ||||
-rw-r--r-- | src/java/org/anarres/cpp/Preprocessor.java | 45 | ||||
-rw-r--r-- | src/java/org/anarres/cpp/Source.java | 3 | ||||
-rw-r--r-- | src/scripts/release.sh | 1 |
8 files changed, 77 insertions, 8 deletions
diff --git a/etc/MANIFEST b/etc/MANIFEST index 4355315..7401ff4 100644 --- a/etc/MANIFEST +++ b/etc/MANIFEST @@ -1,2 +1,2 @@ -Class-Path: log4j.jar gnu.getopt.jar +Class-Path: gnu.getopt.jar Main-Class: org.anarres.cpp.Main diff --git a/etc/targets/global-jar.xml b/etc/targets/global-jar.xml index 22b6cd4..045e85a 100644 --- a/etc/targets/global-jar.xml +++ b/etc/targets/global-jar.xml @@ -15,9 +15,11 @@ <fileset dir="${global.dir.build.classes}"> <include name="**" /> </fileset> + <!-- <fileset dir="${global.dir.src.resources}"> <include name="log4j.properties" /> </fileset> + --> </copy> <jar diff --git a/etc/targets/global-tar.xml b/etc/targets/global-tar.xml index 36f365f..778cf2f 100644 --- a/etc/targets/global-tar.xml +++ b/etc/targets/global-tar.xml @@ -9,9 +9,11 @@ <mkdir dir="${global.dir.build.javadoc}" /> <copy todir="${global.dir.build.tar}/lib"> + <!-- <fileset dir="${global.dir.lib}/log4j"> <include name="**/*.jar" /> </fileset> + --> <fileset dir="${global.dir.lib}/runtime"> <include name="**/*.jar" /> </fileset> diff --git a/src/java/org/anarres/cpp/Feature.java b/src/java/org/anarres/cpp/Feature.java index 935a94b..649f135 100644 --- a/src/java/org/anarres/cpp/Feature.java +++ b/src/java/org/anarres/cpp/Feature.java @@ -32,5 +32,8 @@ public enum Feature { /** Preserves comments in the lexed output. */ KEEPCOMMENTS, VERBOSE, - DEBUG + DEBUG, + + /** Supports lexing of objective-C. */ + OBJCSYNTAX } diff --git a/src/java/org/anarres/cpp/Macro.java b/src/java/org/anarres/cpp/Macro.java index c357493..b62810b 100644 --- a/src/java/org/anarres/cpp/Macro.java +++ b/src/java/org/anarres/cpp/Macro.java @@ -29,6 +29,7 @@ import java.util.List; * extra tokens {@link Token#M_ARG} and {@link Token#M_STRING}. */ public class Macro { + private Source source; private String name; /* It's an explicit decision to keep these around here. We don't * need to; the argument token type is M_ARG and the value @@ -38,13 +39,35 @@ public class Macro { private boolean variadic; private List<Token> tokens; - public Macro(String name) { + public Macro(Source source, String name) { + this.source = source; this.name = name; this.args = null; this.variadic = false; this.tokens = new ArrayList<Token>(); } + public Macro(String name) { + this(null, name); + } + + /** + * Sets the Source from which this macro was parsed. + */ + public void setSource(Source s) { + this.source = s; + } + + /** + * Returns the Source from which this macro was parsed. + * + * This method may return null if the macro was not parsed + * from a regular file. + */ + public Source getSource() { + return source; + } + /** * Returns the name of this macro. */ diff --git a/src/java/org/anarres/cpp/Preprocessor.java b/src/java/org/anarres/cpp/Preprocessor.java index 195a822..2f3e593 100644 --- a/src/java/org/anarres/cpp/Preprocessor.java +++ b/src/java/org/anarres/cpp/Preprocessor.java @@ -74,8 +74,24 @@ is what the flags mean: */ public class Preprocessor implements Closeable { - private static final Macro __LINE__ = new Macro("__LINE__"); - private static final Macro __FILE__ = new Macro("__FILE__"); + private static final Source INTERNAL = new Source() { + @Override + public Token token() + throws IOException, + LexerException { + throw new LexerException("Cannot read from " + getName()); + } + @Override + public String getPath() { + return "<internal-data>"; + } + @Override + public String getName() { + return "internal data"; + } + }; + private static final Macro __LINE__ = new Macro(INTERNAL, "__LINE__"); + private static final Macro __FILE__ = new Macro(INTERNAL, "__FILE__"); private List<Source> inputs; @@ -87,6 +103,7 @@ public class Preprocessor implements Closeable { /* Support junk to make it work like cpp */ private List<String> quoteincludepath; /* -iquote */ private List<String> sysincludepath; /* -I */ + private List<String> frameworkspath; private Set<Feature> features; private Set<Warning> warnings; private VirtualFileSystem filesystem; @@ -383,10 +400,28 @@ public class Preprocessor implements Closeable { } /** + * Sets the Objective-C frameworks path used by this Preprocessor. + */ + /* Note for future: Create an IncludeHandler? */ + public void setFrameworksPath(List<String> path) { + this.frameworkspath = path; + } + + /** + * Returns the Objective-C frameworks path used by this + * Preprocessor. + * + * This list may be freely modified by user code. + */ + public List<String> getFrameworksPath() { + return frameworkspath; + } + + /** * Returns the Map of Macros parsed during the run of this * Preprocessor. */ - protected Map<String,Macro> getMacros() { + public Map<String,Macro> getMacros() { return macros; } @@ -712,7 +747,7 @@ public class Preprocessor implements Closeable { } else if (m == __FILE__) { StringBuilder buf = new StringBuilder("\""); - String name = source.getName(); + String name = getSource().getName(); if (name == null) name = "<no file>"; for (int i = 0; i < name.length(); i++) { @@ -799,7 +834,7 @@ public class Preprocessor implements Closeable { return source_skipline(false); } - Macro m = new Macro(name); + Macro m = new Macro(getSource(), name); List<String> args; tok = source_token(); diff --git a/src/java/org/anarres/cpp/Source.java b/src/java/org/anarres/cpp/Source.java index d69a5c2..49277c7 100644 --- a/src/java/org/anarres/cpp/Source.java +++ b/src/java/org/anarres/cpp/Source.java @@ -143,6 +143,9 @@ public abstract class Source implements Iterable<Token>, Closeable { return null; } + /** + * Returns the human-readable name of the current Source. + */ /* pp */ String getName() { Source parent = getParent(); if (parent != null) diff --git a/src/scripts/release.sh b/src/scripts/release.sh index 7196d36..cd88d95 100644 --- a/src/scripts/release.sh +++ b/src/scripts/release.sh @@ -2,3 +2,4 @@ rsync -avP build/dist/anarres-cpp-*.tar.gz [email protected]:public_html/p rsync -avP --exclude=.svn --exclude=autohandler build/javadoc [email protected]:public_html/projects/jcpp/ cp build/tar/lib/anarres-cpp.jar /home/shevek/java/iengine/trunk/lib/runtime/jcpp/ cp build/tar/lib/anarres-cpp.jar /home/shevek/java/karma/trunk/lib/dp/ +cp build/tar/lib/anarres-cpp.jar /home/shevek/java/dp/trunk/lib/runtime/cpp/ |