summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java2
-rw-r--r--src/main/java/org/anarres/cpp/Preprocessor.java9
-rw-r--r--src/main/java/org/anarres/cpp/PreprocessorListener.java7
-rw-r--r--src/test/java/org/anarres/cpp/LexerSourceTest.java6
-rw-r--r--src/test/java/org/anarres/cpp/PreprocessorTest.java8
5 files changed, 19 insertions, 13 deletions
diff --git a/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java b/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java
index 68f6e89..40a8686 100644
--- a/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java
+++ b/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java
@@ -91,7 +91,7 @@ public class DefaultPreprocessorListener implements PreprocessorListener {
}
@Override
- public void handleSourceChange(Source source, String event) {
+ public void handleSourceChange(Source source, SourceChangeEvent event) {
}
}
diff --git a/src/main/java/org/anarres/cpp/Preprocessor.java b/src/main/java/org/anarres/cpp/Preprocessor.java
index 18a0605..f4e93cd 100644
--- a/src/main/java/org/anarres/cpp/Preprocessor.java
+++ b/src/main/java/org/anarres/cpp/Preprocessor.java
@@ -36,6 +36,7 @@ import javax.annotation.Nonnull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.anarres.cpp.PreprocessorCommand.*;
+import org.anarres.cpp.PreprocessorListener.SourceChangeEvent;
import static org.anarres.cpp.Token.*;
/**
@@ -526,10 +527,10 @@ public class Preprocessor implements Closeable {
source.setParent(this.source, autopop);
// source.setListener(listener);
if (listener != null)
- listener.handleSourceChange(this.source, "suspend");
+ listener.handleSourceChange(this.source, SourceChangeEvent.SUSPEND);
this.source = source;
if (listener != null)
- listener.handleSourceChange(this.source, "push");
+ listener.handleSourceChange(this.source, SourceChangeEvent.PUSH);
}
/**
@@ -542,13 +543,13 @@ public class Preprocessor implements Closeable {
protected Token pop_source(boolean linemarker)
throws IOException {
if (listener != null)
- listener.handleSourceChange(this.source, "pop");
+ listener.handleSourceChange(this.source, SourceChangeEvent.POP);
Source s = this.source;
this.source = s.getParent();
/* Always a noop unless called externally. */
s.close();
if (listener != null && this.source != null)
- listener.handleSourceChange(this.source, "resume");
+ listener.handleSourceChange(this.source, SourceChangeEvent.RESUME);
Source t = getSource();
if (getFeature(Feature.LINEMARKERS)
diff --git a/src/main/java/org/anarres/cpp/PreprocessorListener.java b/src/main/java/org/anarres/cpp/PreprocessorListener.java
index 3443714..0d3f7fc 100644
--- a/src/main/java/org/anarres/cpp/PreprocessorListener.java
+++ b/src/main/java/org/anarres/cpp/PreprocessorListener.java
@@ -49,6 +49,11 @@ public interface PreprocessorListener {
@Nonnull String msg)
throws LexerException;
- public void handleSourceChange(@Nonnull Source source, @Nonnull String event);
+ public enum SourceChangeEvent {
+
+ SUSPEND, PUSH, POP, RESUME;
+ }
+
+ public void handleSourceChange(@Nonnull Source source, @Nonnull SourceChangeEvent event);
}
diff --git a/src/test/java/org/anarres/cpp/LexerSourceTest.java b/src/test/java/org/anarres/cpp/LexerSourceTest.java
index e21aa01..96ec4a3 100644
--- a/src/test/java/org/anarres/cpp/LexerSourceTest.java
+++ b/src/test/java/org/anarres/cpp/LexerSourceTest.java
@@ -1,16 +1,16 @@
package org.anarres.cpp;
import java.util.Arrays;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.anarres.cpp.PreprocessorTest.assertType;
import static org.anarres.cpp.Token.*;
import static org.junit.Assert.*;
public class LexerSourceTest {
- private static final Log LOG = LogFactory.getLog(LexerSourceTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(LexerSourceTest.class);
public static void testLexerSource(String in, boolean textmatch, int... out)
throws Exception {
diff --git a/src/test/java/org/anarres/cpp/PreprocessorTest.java b/src/test/java/org/anarres/cpp/PreprocessorTest.java
index 84e7e31..e55b568 100644
--- a/src/test/java/org/anarres/cpp/PreprocessorTest.java
+++ b/src/test/java/org/anarres/cpp/PreprocessorTest.java
@@ -4,16 +4,16 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.anarres.cpp.Token.*;
import static org.junit.Assert.*;
public class PreprocessorTest {
- private static final Log LOG = LogFactory.getLog(PreprocessorTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PreprocessorTest.class);
private OutputStreamWriter writer;
private Preprocessor p;
@@ -193,7 +193,7 @@ public class PreprocessorTest {
writer.flush();
for (Object v : out) {
Token t = p.token();
- LOG.info(t);
+ LOG.info(String.valueOf(t));
if (v instanceof String) {
if (t.getType() != STRING)
fail("Expected STRING, but got " + t);