aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/anarres/cpp/Macro.java3
-rw-r--r--src/main/java/org/anarres/cpp/Preprocessor.java4
2 files changed, 7 insertions, 0 deletions
diff --git a/src/main/java/org/anarres/cpp/Macro.java b/src/main/java/org/anarres/cpp/Macro.java
index f8a920a..ce00930 100644
--- a/src/main/java/org/anarres/cpp/Macro.java
+++ b/src/main/java/org/anarres/cpp/Macro.java
@@ -138,6 +138,9 @@ public class Macro {
/* pp */ List<Token> getTokens() {
return tokens;
}
+ /* pp */ void setTokens(final List<Token> tokens) {
+ this.tokens = tokens;
+ }
/* Paste tokens are inserted before the first of the two pasted
* tokens, so it's a kind of bytecode notation. This method
diff --git a/src/main/java/org/anarres/cpp/Preprocessor.java b/src/main/java/org/anarres/cpp/Preprocessor.java
index 77e63ec..f0e5528 100644
--- a/src/main/java/org/anarres/cpp/Preprocessor.java
+++ b/src/main/java/org/anarres/cpp/Preprocessor.java
@@ -364,6 +364,10 @@ public class Preprocessor implements Closeable {
/* Already handled as a source error in macro(). */
if ("defined".equals(name))
throw new LexerException("Cannot redefine name 'defined'");
+
+ if ( isActive() && null != source && !source.isExpanding(m) ) {
+ m.setTokens( expand( m.getTokens() ) );
+ }
macros.put(m.getName(), m);
}