Java 类org.antlr.runtime.NoViableAltException 实例源码

项目:codebuff    文件:STLexer.java   
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;
  }
项目:SecureDB    文件:ParseDriver.java   
@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;
}
项目:power-matchmaker    文件:AddressParser.java   
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; 
}
项目:PDFReporter-Studio    文件:InternalJavaJRExpressionParser.java   
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;
}
项目:PDFReporter-Studio    文件:InternalJavaJRExpressionParser.java   
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
    TokenStream input = (TokenStream)_input;
    int _s = s;
    switch ( s ) {
            case 0 : 
                int LA36_1 = input.LA(1);


                int index36_1 = input.index();
                input.rewind();
                s = -1;
                if ( (synpred12_InternalJavaJRExpression()) ) {s = 22;}

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


                input.seek(index36_1);
                if ( s>=0 ) return s;
                break;
    }
    if (state.backtracking>0) {state.failed=true; return -1;}
    NoViableAltException nvae =
        new NoViableAltException(getDescription(), 36, _s, input);
    error(nvae);
    throw nvae;
}
项目:PDFReporter-Studio    文件:InternalJavaJRExpressionParser.java   
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;
}
项目:PDFReporter-Studio    文件:InternalJavaJRExpressionParser.java   
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
    TokenStream input = (TokenStream)_input;
    int _s = s;
    switch ( s ) {
            case 0 : 
                int LA39_1 = input.LA(1);


                int index39_1 = input.index();
                input.rewind();
                s = -1;
                if ( (synpred63_InternalJavaJRExpression()) ) {s = 22;}

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


                input.seek(index39_1);
                if ( s>=0 ) return s;
                break;
    }
    if (state.backtracking>0) {state.failed=true; return -1;}
    NoViableAltException nvae =
        new NoViableAltException(getDescription(), 39, _s, input);
    error(nvae);
    throw nvae;
}
项目:goworks    文件:ANTLRErrorProvidingParser.java   
@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() + ">";
}
项目:templates4j    文件:STLexer.java   
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;
  }
项目:asup    文件:LexerHelper.java   
/**
    * 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);
   }
项目:asup    文件:ParserHelper.java   
/**
 * 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);
   }
项目:antlrworks2    文件:ANTLRErrorProvidingParser.java   
@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() + ">";
}
项目:n4js    文件:InternalHighlightingParser.java   
@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;
}
项目:n4js    文件:InternalSemicolonInjectingParser.java   
@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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}
项目:codebuff    文件:STLexer.java   
/** 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();
}
项目:codebuff    文件:STLexer.java   
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;
}