Search in sources :

Example 11 with Token

use of antlr.Token in project hibernate-orm by hibernate.

the class SqlASTFactory method createUsingCtor.

@SuppressWarnings("unchecked")
protected AST createUsingCtor(Token token, String className) {
    Class c;
    AST t;
    try {
        c = Class.forName(className);
        Class[] tokenArgType = new Class[] { antlr.Token.class };
        Constructor ctor = c.getConstructor(tokenArgType);
        if (ctor != null) {
            t = (AST) ctor.newInstance(token);
            initializeSqlNode(t);
        } else {
            // just do the regular thing if you can't find the ctor
            // Your AST must have default ctor to use this.
            t = create(c);
        }
    } catch (Exception e) {
        throw new IllegalArgumentException("Invalid class or can't make instance, " + className);
    }
    return t;
}
Also used : AST(antlr.collections.AST) Constructor(java.lang.reflect.Constructor) Token(antlr.Token)

Example 12 with Token

use of antlr.Token in project groovy by apache.

the class LexerFrame method actionPerformed.

public void actionPerformed(ActionEvent ae) {
    Token token = (Token) ((JComponent) ae.getSource()).getClientProperty("token");
    if (token.getType() == Token.EOF_TYPE) {
        scriptPane.select(0, 0);
        return;
    }
    try {
        int start = scriptPane.getLineStartOffset(token.getLine() - 1) + token.getColumn() - 1;
        scriptPane.select(start, start + token.getText().length());
        scriptPane.requestFocus();
    } catch (BadLocationException ex) {
    // IGNORE
    }
}
Also used : Token(antlr.Token) BadLocationException(javax.swing.text.BadLocationException)

Example 13 with Token

use of antlr.Token in project sonarqube by SonarSource.

the class ValidWhenLexer method mLESSTHANSIGN.

public final void mLESSTHANSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = LESSTHANSIGN;
    int _saveIndex;
    match('<');
    if (_createToken && _token == null && _ttype != Token.SKIP) {
        _token = makeToken(_ttype);
        _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
    }
    _returnToken = _token;
}
Also used : Token(antlr.Token) CommonToken(antlr.CommonToken) ANTLRHashString(antlr.ANTLRHashString)

Example 14 with Token

use of antlr.Token in project sonarqube by SonarSource.

the class ValidWhenLexer method mEQUALSIGN.

public final void mEQUALSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = EQUALSIGN;
    int _saveIndex;
    match('=');
    match('=');
    if (_createToken && _token == null && _ttype != Token.SKIP) {
        _token = makeToken(_ttype);
        _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
    }
    _returnToken = _token;
}
Also used : Token(antlr.Token) CommonToken(antlr.CommonToken) ANTLRHashString(antlr.ANTLRHashString)

Example 15 with Token

use of antlr.Token in project sonarqube by SonarSource.

the class ValidWhenLexer method mGREATEREQUALSIGN.

public final void mGREATEREQUALSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype;
    Token _token = null;
    int _begin = text.length();
    _ttype = GREATEREQUALSIGN;
    int _saveIndex;
    match('>');
    match('=');
    if (_createToken && _token == null && _ttype != Token.SKIP) {
        _token = makeToken(_ttype);
        _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
    }
    _returnToken = _token;
}
Also used : Token(antlr.Token) CommonToken(antlr.CommonToken) ANTLRHashString(antlr.ANTLRHashString)

Aggregations

Token (antlr.Token)26 CommonToken (antlr.CommonToken)18 ANTLRHashString (antlr.ANTLRHashString)17 NoViableAltForCharException (antlr.NoViableAltForCharException)6 Constructor (java.lang.reflect.Constructor)2 GroovyLexer (org.codehaus.groovy.antlr.parser.GroovyLexer)2 GroovyRecognizer (org.codehaus.groovy.antlr.parser.GroovyRecognizer)2 CharScanner (antlr.CharScanner)1 CharStreamException (antlr.CharStreamException)1 CharStreamIOException (antlr.CharStreamIOException)1 NoViableAltException (antlr.NoViableAltException)1 RecognitionException (antlr.RecognitionException)1 TokenStreamException (antlr.TokenStreamException)1 TokenStreamIOException (antlr.TokenStreamIOException)1 TokenStreamRecognitionException (antlr.TokenStreamRecognitionException)1 AST (antlr.collections.AST)1 BadLocationException (javax.swing.text.BadLocationException)1