forked from jasder/antlr
Remove getSpeculativeText since getText works again
This commit is contained in:
parent
a4ba562210
commit
d748271816
|
@ -315,13 +315,6 @@ public abstract class Lexer extends Recognizer<Integer, LexerATNSimulator>
|
|||
return getInterpreter().getText(_input);
|
||||
}
|
||||
|
||||
/** Get the text from start of token to current lookahead char.
|
||||
* Use this in predicates to test text matched so far in a lexer rule.
|
||||
*/
|
||||
public String getSpeculativeText() {
|
||||
return getInterpreter().getSpeculativeText(_input);
|
||||
}
|
||||
|
||||
/** Set the complete text of this token; it wipes any previous
|
||||
* changes to the text.
|
||||
*/
|
||||
|
|
|
@ -698,15 +698,6 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
return input.getText(Interval.of(startIndex, input.index()-1));
|
||||
}
|
||||
|
||||
/** Get the text from start of token to current lookahead char.
|
||||
* Use this in predicates to test text matched so far in a lexer rule.
|
||||
*/
|
||||
@NotNull
|
||||
public String getSpeculativeText(@NotNull CharStream input) {
|
||||
// index is first lookahead char, don't include.
|
||||
return input.getText(Interval.of(startIndex, input.index()));
|
||||
}
|
||||
|
||||
public int getLine() {
|
||||
return line;
|
||||
}
|
||||
|
|
|
@ -267,9 +267,6 @@ public class TestLexerExec extends BaseTest {
|
|||
}
|
||||
|
||||
@Test public void testLexerInputPositionSensitivePredicates() throws Exception {
|
||||
// The predicates here make sense on the left edge, but are currently
|
||||
// only working on the right edge... resolving this would remove the
|
||||
// need for Lexer.getSpeculativeText as well.
|
||||
String grammar =
|
||||
"lexer grammar L;\n"+
|
||||
"WORD1 : ID1+ {System.out.println(getText());} ;\n"+
|
||||
|
|
|
@ -67,7 +67,7 @@ public class TestSemPredEvalLexer extends BaseTest {
|
|||
@Test public void testEnumNotID() throws Exception {
|
||||
String grammar =
|
||||
"lexer grammar L;\n"+
|
||||
"ENUM : [a-z]+ {getSpeculativeText().equals(\"enum\")}? ;\n" +
|
||||
"ENUM : [a-z]+ {getText().equals(\"enum\")}? ;\n" +
|
||||
"ID : [a-z]+ ;\n"+
|
||||
"WS : (' '|'\\n') {skip();} ;";
|
||||
String found = execLexer("L.g4", grammar, "L", "enum abc enum", true);
|
||||
|
|
Loading…
Reference in New Issue