diff --git a/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/IParser.java b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/IParser.java index 1dcb9585ca7d56d0f5352788fcb05cc1f424da6b..ba7e1bd73d5055549766b479c5f3f579965ee220 100644 --- a/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/IParser.java +++ b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/IParser.java @@ -10,5 +10,10 @@ import java.util.Map; public interface IParser { + /** + * @deprecated All generated token classes store their own position info. + * Use the {@link PositionedNode} or {@link IToken} APIs to access the positions stored in the tokens. + */ + @Deprecated public Map<PositionedNode, SourcecodeRange> getMapping(); } diff --git a/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/ITokenListContainer.java b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/ITokenListContainer.java index eb5eb885b4944beaa8dc15105ac33a0b8c2a7670..eb07fe5602f8b75df630419a334952d13cc5cf0d 100644 --- a/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/ITokenListContainer.java +++ b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/ITokenListContainer.java @@ -8,6 +8,16 @@ package de.hhu.stups.sablecc.patch; import java.util.List; +/** + * @deprecated In the future, the generated lexers will not store all tokens anymore, because this leads to significant memory usage for large inputs. + * If you really need this list, please create it yourself, using a custom lexer subclass if necessary. + */ +@Deprecated public interface ITokenListContainer { + /** + * @deprecated In the future, the generated lexers will not store all tokens anymore, because this leads to significant memory usage for large inputs. + * If you really need this list, please create it yourself, using a custom lexer subclass if necessary. + */ + @Deprecated public List<IToken> getTokenList(); } diff --git a/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcePositions.java b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcePositions.java index 0c30041a68683e38cffc6399ab07abad7f4a570f..7dc66fd2e9d77ca876b9fc7a2454656f4fecac34 100644 --- a/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcePositions.java +++ b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcePositions.java @@ -10,6 +10,11 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +/** + * @deprecated All generated token classes store their own position info. + * Use the {@link PositionedNode} or {@link IToken} APIs to access the positions stored in the tokens. + */ +@Deprecated public class SourcePositions { private final List<IToken> tokenList; private final Map<PositionedNode, SourcecodeRange> positions; diff --git a/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcecodeRange.java b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcecodeRange.java index 7f25cd153241510857a2e3f7b3ae2681ab35e8c9..f447a79ece3d80c995d1201fb0a12d45c860e87f 100644 --- a/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcecodeRange.java +++ b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcecodeRange.java @@ -6,6 +6,7 @@ package de.hhu.stups.sablecc.patch; +@Deprecated public class SourcecodeRange { private final int beginIndex; private final int endIndex; diff --git a/src/main/java/org/sablecc/sablecc/lexer/Lexer.java b/src/main/java/org/sablecc/sablecc/lexer/Lexer.java index 9a4ac88cf2fd600b260126cf2d6e05fc0fe772e1..88b92d80838b97fcfbc1fb179ba27212e6ce5d49 100644 --- a/src/main/java/org/sablecc/sablecc/lexer/Lexer.java +++ b/src/main/java/org/sablecc/sablecc/lexer/Lexer.java @@ -17,7 +17,7 @@ import de.hhu.stups.sablecc.patch.ITokenListContainer; import org.sablecc.sablecc.node.*; -@SuppressWarnings({"unused"}) +@SuppressWarnings({"deprecation", "unused"}) // ITokenListContainer is deprecated, but the generated lexer still implements it for compatibility public class Lexer implements ITokenListContainer { protected Token token; @@ -37,6 +37,11 @@ public class Lexer implements ITokenListContainer return nextList; } + /** + * @deprecated In the future, the generated lexers will not store all tokens anymore, because this leads to significant memory usage for large inputs. + * If you really need this list, please create it yourself, using a custom lexer subclass if necessary. + */ + @Deprecated @Override public List<IToken> getTokenList() { return tokenList; @@ -46,7 +51,11 @@ public class Lexer implements ITokenListContainer token = t; } - + /** + * @deprecated In the future, the generated lexers will not store all tokens anymore, because this leads to significant memory usage for large inputs. + * If you really need this list, please create it yourself, using a custom lexer subclass if necessary. + */ + @Deprecated public void setTokenList(final List<IToken> list) { tokenList = list; } diff --git a/src/main/java/org/sablecc/sablecc/parser/Parser.java b/src/main/java/org/sablecc/sablecc/parser/Parser.java index a5f017486eb7566db6f6dac4c1ef2384dde835f1..28bbe35ebec81dbc4b25e20e817b561c61ea55af 100644 --- a/src/main/java/org/sablecc/sablecc/parser/Parser.java +++ b/src/main/java/org/sablecc/sablecc/parser/Parser.java @@ -22,7 +22,7 @@ import org.sablecc.sablecc.lexer.Lexer; import org.sablecc.sablecc.lexer.LexerException; import org.sablecc.sablecc.node.*; -@SuppressWarnings({"rawtypes","unchecked","unused"}) +@SuppressWarnings({"deprecation", "rawtypes", "unchecked", "unused"}) // getMapping() is deprecated, but the generated parser still populates it for compatibility public class Parser implements IParser { protected List<Object> nodeList; @@ -45,8 +45,13 @@ public class Parser implements IParser this.lexer = lexer; } - + @Deprecated private Map<PositionedNode, SourcecodeRange> mapping = new HashMap<PositionedNode, SourcecodeRange>(); + /** + * @deprecated All generated token classes store their own position info. + * Use the {@link PositionedNode} or {@link IToken} APIs to access the positions stored in the tokens. + */ + @Deprecated @Override public Map<PositionedNode, SourcecodeRange> getMapping() { return this.mapping; } diff --git a/src/main/resources/org/sablecc/sablecc/lexer.txt b/src/main/resources/org/sablecc/sablecc/lexer.txt index 44e22aeb2d9d6f4132d0d1ded45a690adbd466fa..5651a1f7a25dcb950ec7ac530463232d1e35b713 100644 --- a/src/main/resources/org/sablecc/sablecc/lexer.txt +++ b/src/main/resources/org/sablecc/sablecc/lexer.txt @@ -41,7 +41,7 @@ import de.hhu.stups.sablecc.patch.ITokenListContainer; import $0$node.*; -@SuppressWarnings({"unused"}) +@SuppressWarnings({"deprecation", "unused"}) // ITokenListContainer is deprecated, but the generated lexer still implements it for compatibility public class Lexer implements ITokenListContainer { protected Token token; @@ -61,6 +61,11 @@ public class Lexer implements ITokenListContainer return nextList; } + /** + * @deprecated In the future, the generated lexers will not store all tokens anymore, because this leads to significant memory usage for large inputs. + * If you really need this list, please create it yourself, using a custom lexer subclass if necessary. + */ + @Deprecated @Override public List<IToken> getTokenList() { return tokenList; @@ -70,7 +75,11 @@ public class Lexer implements ITokenListContainer token = t; } - + /** + * @deprecated In the future, the generated lexers will not store all tokens anymore, because this leads to significant memory usage for large inputs. + * If you really need this list, please create it yourself, using a custom lexer subclass if necessary. + */ + @Deprecated public void setTokenList(final List<IToken> list) { tokenList = list; } diff --git a/src/main/resources/org/sablecc/sablecc/parser.txt b/src/main/resources/org/sablecc/sablecc/parser.txt index f5b39aa373c285e46bb9aca3de684250dac8d7dd..f7ebae738fbe8b00d4bb75c972125ab5918820f2 100644 --- a/src/main/resources/org/sablecc/sablecc/parser.txt +++ b/src/main/resources/org/sablecc/sablecc/parser.txt @@ -30,7 +30,7 @@ import $0$lexer.Lexer; import $0$lexer.LexerException; import $0$node.*; -@SuppressWarnings({"rawtypes","unchecked","unused"}) +@SuppressWarnings({"deprecation", "rawtypes", "unchecked", "unused"}) // getMapping() is deprecated, but the generated parser still populates it for compatibility public class Parser implements IParser { protected List<Object> nodeList; @@ -53,8 +53,13 @@ public class Parser implements IParser this.lexer = lexer; } - + @Deprecated private Map<PositionedNode, SourcecodeRange> mapping = new HashMap<PositionedNode, SourcecodeRange>(); + /** + * @deprecated All generated token classes store their own position info. + * Use the {@link PositionedNode} or {@link IToken} APIs to access the positions stored in the tokens. + */ + @Deprecated @Override public Map<PositionedNode, SourcecodeRange> getMapping() { return this.mapping; }