@Override public void tokenize(SourceCode sourceCode, Tokens tokenEntries) { StringBuilder buffer = sourceCode.getCodeBuffer(); GroovyLexer lexer = new GroovyLexer(new StringReader(buffer.toString())); TokenStream tokenStream = lexer.plumb(); try { Token token = tokenStream.nextToken(); while (token.getType() != Token.EOF_TYPE) { TokenEntry tokenEntry = new TokenEntry(token.getText(), sourceCode.getFileName(), token.getLine()); tokenEntries.add(tokenEntry); token = tokenStream.nextToken(); } } catch (TokenStreamException err) { // Wrap exceptions of the Groovy tokenizer in a TokenMgrError, so // they are correctly handled // when CPD is executed with the '--skipLexicalErrors' command line // option throw new TokenMgrError("Lexical error in file " + sourceCode.getFileName() + " at line " + lexer.getLine() + ", column " + lexer.getColumn() + ". Encountered: " + err.getMessage(), TokenMgrError.LEXICAL_ERROR); } finally { tokenEntries.add(TokenEntry.getEOF()); } } }
protected final void mBIG_SUFFIX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = BIG_SUFFIX; int _saveIndex; switch ( LA(1)) { case 'g': { match('g'); break; } case 'G': { match('G'); break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; }
int _saveIndex; if (!(getLine() == 1 && getColumn() == 1)) throw new SemanticException("getLine() == 1 && getColumn() == 1"); match("#!");
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
if ( _cnt669>=1 ) { break _loop669; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
if ( _cnt746>=1 ) { break _loop746; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
if ( _cnt675>=1 ) { break _loop675; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());