get recognizer name properly. Fixes #958

This commit is contained in:
parrt 2016-12-13 11:05:39 -08:00
parent ec5f2ecf31
commit a3aa610e3d
2 changed files with 25 additions and 1 deletions

View File

@ -10,6 +10,30 @@ import org.antlr.v4.test.runtime.BaseLexerTestDescriptor;
import org.antlr.v4.test.runtime.CommentHasStringValue;
public class SemPredEvalLexerDescriptors {
// Test for https://github.com/antlr/antlr4/issues/958
public static class RuleSempredFunction extends BaseLexerTestDescriptor {
public String input = "aaa";
/**
[@0,0:0='a',<1>,1:0]
[@1,1:1='a',<1>,1:1]
[@2,2:2='a',<1>,1:2]
[@3,3:2='<EOF>',<-1>,1:3]
*/
@CommentHasStringValue
public String output;
public String errors = null;
public String startRule = "";
public String grammarName = "L";
/**
lexer grammar L;
T : 'a' {<True()>}? ;
*/
@CommentHasStringValue
public String grammar;
}
public static class DisableRule extends BaseLexerTestDescriptor {
public String input = "enum abc";
/**

View File

@ -236,7 +236,7 @@ case <index>:
* overriding implementation impossible to maintain.
*/
RuleSempredFunction(r, actions) ::= <<
<if(parser)><parser.name><else><lexer.name><endif>.prototype.<r.name>_sempred = function(localctx, predIndex) {
<if (r.factory.g.lexer)><lexer.name><else><parser.name><endif>.prototype.<r.name>_sempred = function(localctx, predIndex) {
switch(predIndex) {
<actions:{index| case <index>:
return <actions.(index)>;}; separator="\n">