当前位置: 首页>>代码示例>>Java>>正文


Java NoViableAltException类代码示例

本文整理汇总了Java中org.antlr.runtime.NoViableAltException的典型用法代码示例。如果您正苦于以下问题:Java NoViableAltException类的具体用法?Java NoViableAltException怎么用?Java NoViableAltException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NoViableAltException类属于org.antlr.runtime包,在下文中一共展示了NoViableAltException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ESCAPE

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
Token ESCAPE() {
startCharIndex = input.index();
startCharPositionInLine = input.getCharPositionInLine();
consume(); // kill \\
if ( c=='u') return UNICODE();
String text;
      switch ( c ) {
          case '\\' : LINEBREAK(); return SKIP;
	case 'n'  : text = "\n"; break;
	case 't'  : text = "\t"; break;
	case ' '  : text = " "; break;
          default :
              NoViableAltException e = new NoViableAltException("",0,0,input);
              errMgr.lexerError(input.getSourceName(), "invalid escaped char: '"+str(c)+"'", templateToken, e);
		consume();
		match(delimiterStopChar);
		return SKIP;
      }
      consume();
Token t = newToken(TEXT, text, input.getCharPositionInLine()-2);
      match(delimiterStopChar);
      return t;
  }
 
开发者ID:antlr,项目名称:codebuff,代码行数:24,代码来源:STLexer.java

示例2: getErrorMessage

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
@Override
public String getErrorMessage(RecognitionException e, String[] tokenNames) {
  String msg = null;

  if (e instanceof NoViableAltException) {
    @SuppressWarnings("unused")
    NoViableAltException nvae = (NoViableAltException) e;
    // for development, can add
    // "decision=<<"+nvae.grammarDecisionDescription+">>"
    // and "(decision="+nvae.decisionNumber+") and
    // "state "+nvae.stateNumber
    msg = "character " + getCharErrorDisplay(e.c) + " not supported here";
  } else {
    msg = super.getErrorMessage(e, tokenNames);
  }

  return msg;
}
 
开发者ID:andyhehk,项目名称:SecureDB,代码行数:19,代码来源:ParseDriver.java

示例3: getErrorMessage

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
public String getErrorMessage(RecognitionException e, 
String[] tokenNames) 
{ 
List stack = getRuleInvocationStack(e, this.getClass().getName()); 
String msg = null; 
if ( e instanceof NoViableAltException ) { 
NoViableAltException nvae = (NoViableAltException)e; 
msg = " no viable alt; token="+e.token+ 
" (decision="+nvae.decisionNumber+ 
" state "+nvae.stateNumber+")"+ 
" decision=<<"+nvae.grammarDecisionDescription+">>"; 
} 
else { 
msg = super.getErrorMessage(e, tokenNames); 
} 
return stack+" "+msg; 
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:18,代码来源:AddressParser.java

示例4: specialStateTransition

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
    TokenStream input = (TokenStream)_input;
	int _s = s;
    switch ( s ) {
            case 0 : 
                int LA14_3 = input.LA(1);

                 
                int index14_3 = input.index();
                input.rewind();
                s = -1;
                if ( (synpred9_InternalJavaJRExpression()) ) {s = 19;}

                else if ( (true) ) {s = 4;}

                 
                input.seek(index14_3);
                if ( s>=0 ) return s;
                break;
    }
    if (state.backtracking>0) {state.failed=true; return -1;}
    NoViableAltException nvae =
        new NoViableAltException(getDescription(), 14, _s, input);
    error(nvae);
    throw nvae;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:27,代码来源:InternalJavaJRExpressionParser.java

示例5: specialStateTransition

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
    TokenStream input = (TokenStream)_input;
	int _s = s;
    switch ( s ) {
            case 0 : 
                int LA6_3 = input.LA(1);

                 
                int index6_3 = input.index();
                input.rewind();
                s = -1;
                if ( (synpred10_InternalJavaJRExpression()) ) {s = 19;}

                else if ( (true) ) {s = 4;}

                 
                input.seek(index6_3);
                if ( s>=0 ) return s;
                break;
    }
    if (state.backtracking>0) {state.failed=true; return -1;}
    NoViableAltException nvae =
        new NoViableAltException(getDescription(), 6, _s, input);
    error(nvae);
    throw nvae;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:27,代码来源:InternalJavaJRExpressionParser.java

示例6: toString

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
@Override
public String toString()
{
    if (trappedException instanceof MissingTokenException)
    {
        return "<missing type: " +
               ( (MissingTokenException)trappedException ).getMissingType() +
               ">";
    } else if (trappedException instanceof UnwantedTokenException) {
        return "<extraneous: " +
               ( (UnwantedTokenException)trappedException ).getUnexpectedToken() +
               ", resync=" + getText() + ">";
    } else if (trappedException instanceof MismatchedTokenException) {
        return "<mismatched token: " + trappedException.token + ", resync=" + getText() + ">";
    } else if (trappedException instanceof NoViableAltException) {
        return "<unexpected: " + trappedException.token +
               ", resync=" + getText() + ">";
    }
    return "<error: " + getText() + ">";
}
 
开发者ID:tunnelvisionlabs,项目名称:goworks,代码行数:21,代码来源:ANTLRErrorProvidingParser.java

示例7: ESCAPE

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
Token ESCAPE() {
startCharIndex = input.index();
startCharPositionInLine = input.getCharPositionInLine();
consume(); // kill \\
if ( c=='u') return UNICODE();
String text = null;
      switch ( c ) {
          case '\\' : LINEBREAK(); return SKIP;
	case 'n'  : text = "\n"; break;
	case 't'  : text = "\t"; break;
	case ' '  : text = " "; break;
          default :
              NoViableAltException e = new NoViableAltException("",0,0,input);
              errMgr.lexerError(input.getSourceName(), "invalid escaped char: '"+str(c)+"'", templateToken, e);
		consume();
		matchAndConsumeDelimiterStop();
		return SKIP;
      }
      consume();
Token t = newToken(TEXT, text, input.getCharPositionInLine()-2);
matchAndConsumeDelimiterStop();
      return t;
  }
 
开发者ID:danishdynamite,项目名称:templates4j,代码行数:24,代码来源:STLexer.java

示例8: createException

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
/**
    * Method called in AntLR grammars for AntLR lexer to CLScript exceptions conversion
 * 
    * @param e
    * @return
    */
public RuntimeException createException(RecognitionException e) {
       String message = "";
       
       if (e instanceof NoViableAltException) {
           message = "Syntax error. ";
       } else if (e instanceof MissingTokenException) {
           message = "Missing token ";
       } else if (e instanceof UnwantedTokenException) {
           UnwantedTokenException ex = (UnwantedTokenException) e;
           ex.getUnexpectedToken().getText();
           message = "Unkow token '" + ex.getUnexpectedToken().getText() + "' at line " + e.token.getLine() + ":" + e.token.getCharPositionInLine();        
       } else {
           message = "Syntax error near ";
       }
       
       return new CLScriptException(message,e);
   }
 
开发者ID:asupdev,项目名称:asup,代码行数:24,代码来源:LexerHelper.java

示例9: createException

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
/**
 * Method called in AntLR grammars for AntLR parser to CLScript exceptions conversion
 * 
 * @param e
 * @return
 */
public RuntimeException createException(RecognitionException e) {
       String message = "";
       boolean addTokenAndLine = true;
       if (e instanceof NoViableAltException) {
           message = "Syntax error. ";
       } else if (e instanceof MissingTokenException) {
           message = "Missing token ";
       } else if (e instanceof UnwantedTokenException) {
           UnwantedTokenException ex = (UnwantedTokenException) e;
           ex.getUnexpectedToken().getText();
           message = "Unkow token '" + ex.getUnexpectedToken().getText() + "' at line " + e.token.getLine() + ":" + e.token.getCharPositionInLine();
           addTokenAndLine = false;
       } else if(e instanceof ParserHelperException){
       	message = e.toString();        	
       }
       else {
           message = "Syntax error near ";
       }
       if (addTokenAndLine) {
           message = message + "'" + e.token.getText() + "' at line " + e.token.getLine() + ":" + e.token.getCharPositionInLine();
       }
       return new CLScriptException(message,e);
   }
 
开发者ID:asupdev,项目名称:asup,代码行数:30,代码来源:ParserHelper.java

示例10: allowASI

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
@Override
public boolean allowASI(final RecognitionException re) {
	if (re instanceof NoViableAltException) {
		final NoViableAltException nvae = (NoViableAltException) re;
		if (asiRecoveredEx != null && re.index == asiRecoveredEx.index
				&& nvae.decisionNumber == asiRecoveredEx.decisionNumber) {
			return false;
		}
		asiRecoveredEx = nvae;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:13,代码来源:InternalHighlightingParser.java

示例11: match

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
/** Consume if {@code x} is next character on the input stream.
 */

public void match(char x) {
    if ( c!= x ) {
        NoViableAltException e = new NoViableAltException("", 0, 0, input);
        errMgr.lexerError(input.getSourceName(),
                          "expecting '" +x+"', found '"+str(c)+"'",
                          templateToken,
                          e);
    }
    consume();
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:14,代码来源:STLexer.java

示例12: ESCAPE

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
Token ESCAPE() {
    startCharIndex = input.index();
    startCharPositionInLine = input.getCharPositionInLine();
    consume(); // kill \\
    if ( c=='u' ) return UNICODE();
    String text;
    switch (c) {
        case '\\':
            LINEBREAK();
            return SKIP;
        case 'n':
            text = "\n";
            break;
        case 't':
            text = "\t";
            break;
        case ' ':
            text = " ";
            break;
        default:
            NoViableAltException e = new NoViableAltException("", 0, 0, input);
            errMgr.lexerError(input.getSourceName(),
                              "invalid escaped char: '" +str(c)+"'",
                              templateToken,
                              e);
            consume();
            match(delimiterStopChar);
            return SKIP;
    }
    consume();
    Token t = newToken(TEXT, text, input.getCharPositionInLine() -2);
    match(delimiterStopChar);
    return t;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:35,代码来源:STLexer.java

示例13: ESCAPE

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
Token ESCAPE() {
    startCharIndex = input.index();
    startCharPositionInLine = input.getCharPositionInLine();
    consume(); // kill \\
    if ( c=='u' ) return UNICODE();
    String text;
    switch (c) {
        case '\\' :
            LINEBREAK();
            return SKIP;
        case 'n' :
            text = "\n";
            break;
        case 't' :
            text = "\t";
            break;
        case ' ' :
            text = " ";
            break;
        default:
            NoViableAltException e = new NoViableAltException("", 0, 0, input);
            errMgr.lexerError(input.getSourceName(),
                              "invalid escaped char: '" +str(c)+"'",
                              templateToken,
                              e);
            consume();
            match(delimiterStopChar);
            return SKIP;
    }
    consume();
    Token t = newToken(TEXT, text, input.getCharPositionInLine() -2);
    match(delimiterStopChar);
    return t;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:35,代码来源:STLexer.java

示例14: match

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
/** Consume if {@code x} is next character on the input stream.
 */

public void match(char x) {
    if ( c!= x ) {
        NoViableAltException e = new NoViableAltException("", 0, 0, input);
        errMgr.lexerError(input.getSourceName(), "expecting '"+x+"', found '"+str(c)+"'", templateToken, e);
    }
    consume();
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:11,代码来源:STLexer.java

示例15: ESCAPE

import org.antlr.runtime.NoViableAltException; //导入依赖的package包/类
Token ESCAPE() {
    startCharIndex = input.index();
    startCharPositionInLine = input.getCharPositionInLine();
    consume(); // kill \\
    if ( c=='u' ) return UNICODE();
    String text;
    switch (c) {
        case '\\' :
            LINEBREAK();
            return SKIP;
        case 'n' :
            text = "\n";
            break;
        case 't' :
            text = "\t";
            break;
        case ' ' :
            text = " ";
            break;
        default:
            NoViableAltException e = new NoViableAltException("", 0, 0, input);
            errMgr.lexerError(input.getSourceName(), "invalid escaped char: '"+str(c)+"'", templateToken, e);
            consume();
            match(delimiterStopChar);
            return SKIP;
    }
    consume();
    Token t = newToken(TEXT, text, input.getCharPositionInLine() -2);
    match(delimiterStopChar);
    return t;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:32,代码来源:STLexer.java


注:本文中的org.antlr.runtime.NoViableAltException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。