本文整理了Java中org.antlr.runtime.Parser.getTokenNames()
方法的一些代码示例,展示了Parser.getTokenNames()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getTokenNames()
方法的具体详情如下:
包路径:org.antlr.runtime.Parser
类名称:Parser
方法名:getTokenNames
暂无
代码示例来源:origin: org.antlr/antlr4
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: uk.co.nichesolutions/antlr4
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: com.tunnelvisionlabs/antlr4
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
protected Object getMissingSymbol(IntStream input,
RecognitionException e,
int expectedTokenType,
BitSet follow)
{
String tokenText = null;
if ( expectedTokenType==Token.EOF ) tokenText = "<missing EOF>";
else tokenText = "<missing "+getTokenNames()[expectedTokenType]+">";
CommonToken t = new CommonToken(expectedTokenType, tokenText);
Token current = ((TokenStream)input).LT(1);
if ( current.getType() == Token.EOF ) {
current = ((TokenStream)input).LT(-1);
}
t.line = current.getLine();
t.charPositionInLine = current.getCharPositionInLine();
t.channel = DEFAULT_TOKEN_CHANNEL;
return t;
}
代码示例来源:origin: antlr/antlr3
@Override
protected Object getMissingSymbol(IntStream input,
RecognitionException e,
int expectedTokenType,
BitSet follow)
{
String tokenText;
if ( expectedTokenType==Token.EOF ) tokenText = "<missing EOF>";
else tokenText = "<missing "+getTokenNames()[expectedTokenType]+">";
CommonToken t = new CommonToken(expectedTokenType, tokenText);
Token current = ((TokenStream)input).LT(1);
if ( current.getType() == Token.EOF ) {
current = ((TokenStream)input).LT(-1);
}
t.line = current.getLine();
t.charPositionInLine = current.getCharPositionInLine();
t.channel = DEFAULT_TOKEN_CHANNEL;
t.input = current.getInputStream();
return t;
}
代码示例来源:origin: antlr/antlr3
@Override
protected Object getMissingSymbol(IntStream input,
RecognitionException e,
int expectedTokenType,
BitSet follow)
{
String tokenText;
if ( expectedTokenType==Token.EOF ) tokenText = "<missing EOF>";
else tokenText = "<missing "+getTokenNames()[expectedTokenType]+">";
CommonToken t = new CommonToken(expectedTokenType, tokenText);
Token current = ((TokenStream)input).LT(1);
if ( current.getType() == Token.EOF ) {
current = ((TokenStream)input).LT(-1);
}
t.line = current.getLine();
t.charPositionInLine = current.getCharPositionInLine();
t.channel = DEFAULT_TOKEN_CHANNEL;
t.input = current.getInputStream();
return t;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr-runtime
@Override
protected Object getMissingSymbol(IntStream input,
RecognitionException e,
int expectedTokenType,
BitSet follow)
{
String tokenText;
if ( expectedTokenType==Token.EOF ) tokenText = "<missing EOF>";
else tokenText = "<missing "+getTokenNames()[expectedTokenType]+">";
CommonToken t = new CommonToken(expectedTokenType, tokenText);
Token current = ((TokenStream)input).LT(1);
if ( current.getType() == Token.EOF ) {
current = ((TokenStream)input).LT(-1);
}
t.line = current.getLine();
t.charPositionInLine = current.getCharPositionInLine();
t.channel = DEFAULT_TOKEN_CHANNEL;
t.input = current.getInputStream();
return t;
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
@Override
protected Object getMissingSymbol(IntStream input,
RecognitionException e,
int expectedTokenType,
BitSet follow)
{
String tokenText;
if ( expectedTokenType==Token.EOF ) tokenText = "<missing EOF>";
else tokenText = "<missing "+getTokenNames()[expectedTokenType]+">";
CommonToken t = new CommonToken(expectedTokenType, tokenText);
Token current = ((TokenStream)input).LT(1);
if ( current.getType() == Token.EOF ) {
current = ((TokenStream)input).LT(-1);
}
t.line = current.getLine();
t.charPositionInLine = current.getCharPositionInLine();
t.channel = DEFAULT_TOKEN_CHANNEL;
t.input = current.getInputStream();
return t;
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
@Override
protected Object getMissingSymbol(IntStream input,
RecognitionException e,
int expectedTokenType,
BitSet follow)
{
String tokenText;
if ( expectedTokenType==Token.EOF ) tokenText = "<missing EOF>";
else tokenText = "<missing "+getTokenNames()[expectedTokenType]+">";
CommonToken t = new CommonToken(expectedTokenType, tokenText);
Token current = ((TokenStream)input).LT(1);
if ( current.getType() == Token.EOF ) {
current = ((TokenStream)input).LT(-1);
}
t.line = current.getLine();
t.charPositionInLine = current.getCharPositionInLine();
t.channel = DEFAULT_TOKEN_CHANNEL;
t.input = current.getInputStream();
return t;
}
代码示例来源:origin: antlr/stringtemplate4
protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken,
Parser parser, RecognitionException re)
{
if ( re.token.getType() == STLexer.EOF_TYPE ) {
String msg = "premature EOF";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( re instanceof NoViableAltException) {
String msg = "'"+re.token.getText()+"' came as a complete surprise to me";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.index() == 0 ) { // couldn't parse anything
String msg = "this doesn't look like a template: \""+tokens+"\"";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.LA(1) == STLexer.LDELIM ) { // couldn't parse expr
String msg = "doesn't look like an expression";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else {
String msg = parser.getErrorMessage(re, parser.getTokenNames());
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
throw new STException(); // we have reported the error, so just blast out
}
代码示例来源:origin: org.antlr/stringtemplate
protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken,
Parser parser, RecognitionException re)
{
if ( re.token.getType() == STLexer.EOF_TYPE ) {
String msg = "premature EOF";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( re instanceof NoViableAltException) {
String msg = "'"+re.token.getText()+"' came as a complete surprise to me";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.index() == 0 ) { // couldn't parse anything
String msg = "this doesn't look like a template: \""+tokens+"\"";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.LA(1) == STLexer.LDELIM ) { // couldn't parse expr
String msg = "doesn't look like an expression";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else {
String msg = parser.getErrorMessage(re, parser.getTokenNames());
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
throw new STException(); // we have reported the error, so just blast out
}
代码示例来源:origin: apache/servicemix-bundles
protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken,
Parser parser, RecognitionException re)
{
if ( re.token.getType() == STLexer.EOF_TYPE ) {
String msg = "premature EOF";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( re instanceof NoViableAltException) {
String msg = "'"+re.token.getText()+"' came as a complete surprise to me";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.index() == 0 ) { // couldn't parse anything
String msg = "this doesn't look like a template: \""+tokens+"\"";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.LA(1) == STLexer.LDELIM ) { // couldn't parse expr
String msg = "doesn't look like an expression";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else {
String msg = parser.getErrorMessage(re, parser.getTokenNames());
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
throw new STException(); // we have reported the error, so just blast out
}
代码示例来源:origin: org.antlr/ST4
protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken,
Parser parser, RecognitionException re)
{
if ( re.token.getType() == STLexer.EOF_TYPE ) {
String msg = "premature EOF";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( re instanceof NoViableAltException) {
String msg = "'"+re.token.getText()+"' came as a complete surprise to me";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.index() == 0 ) { // couldn't parse anything
String msg = "this doesn't look like a template: \""+tokens+"\"";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.LA(1) == STLexer.LDELIM ) { // couldn't parse expr
String msg = "doesn't look like an expression";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else {
String msg = parser.getErrorMessage(re, parser.getTokenNames());
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
throw new STException(); // we have reported the error, so just blast out
}
代码示例来源:origin: antlr/antlr3
protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken,
Parser parser, RecognitionException re)
{
if ( re.token.getType() == STLexer.EOF_TYPE ) {
String msg = "premature EOF";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( re instanceof NoViableAltException) {
String msg = "'"+re.token.getText()+"' came as a complete surprise to me";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.index() == 0 ) { // couldn't parse anything
String msg = "this doesn't look like a template: \""+tokens+"\"";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.LA(1) == STLexer.LDELIM ) { // couldn't parse expr
String msg = "doesn't look like an expression";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else {
String msg = parser.getErrorMessage(re, parser.getTokenNames());
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
throw new STException(); // we have reported the error, so just blast out
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken,
Parser parser, RecognitionException re)
{
if ( re.token.getType() == STLexer.EOF_TYPE ) {
String msg = "premature EOF";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( re instanceof NoViableAltException) {
String msg = "'"+re.token.getText()+"' came as a complete surprise to me";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.index() == 0 ) { // couldn't parse anything
String msg = "this doesn't look like a template: \""+tokens+"\"";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else if ( tokens.LA(1) == STLexer.LDELIM ) { // couldn't parse expr
String msg = "doesn't look like an expression";
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
else {
String msg = parser.getErrorMessage(re, parser.getTokenNames());
group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg);
}
throw new STException(); // we have reported the error, so just blast out
}
内容来源于网络,如有侵权,请联系作者删除!