📄 textlexer.java
字号:
/*
* Copyright (C) 2007 ETH Zurich
*
* This file is part of Fosstrak (www.fosstrak.org).
*
* Fosstrak is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* Fosstrak is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Fosstrak; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
// $ANTLR : "reply_new.g" -> "TextLexer.java"$
package org.fosstrak.reader.rprm.core.msg.reply;
import java.io.InputStream;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.TokenStreamRecognitionException;
import antlr.CharStreamException;
import antlr.CharStreamIOException;
import antlr.ANTLRException;
import java.io.Reader;
import java.util.Hashtable;
import antlr.CharScanner;
import antlr.InputBuffer;
import antlr.ByteBuffer;
import antlr.CharBuffer;
import antlr.Token;
import antlr.CommonToken;
import antlr.RecognitionException;
import antlr.NoViableAltForCharException;
import antlr.MismatchedCharException;
import antlr.TokenStream;
import antlr.ANTLRHashString;
import antlr.LexerSharedInputState;
import antlr.collections.impl.BitSet;
import antlr.SemanticException;
public class TextLexer extends antlr.CharScanner implements TextReplyParserTokenTypes, TokenStream
{
public TextLexer(InputStream in) {
this(new ByteBuffer(in));
}
public TextLexer(Reader in) {
this(new CharBuffer(in));
}
public TextLexer(InputBuffer ib) {
this(new LexerSharedInputState(ib));
}
public TextLexer(LexerSharedInputState state) {
super(state);
caseSensitiveLiterals = false;
setCaseSensitive(true);
literals = new Hashtable();
literals.put(new ANTLRHashString("OK", this), new Integer(4));
literals.put(new ANTLRHashString("ERR", this), new Integer(5));
}
public Token nextToken() throws TokenStreamException {
Token theRetToken=null;
tryAgain:
for (;;) {
Token _token = null;
int _ttype = Token.INVALID_TYPE;
resetText();
try { // for char stream error handling
try { // for lexical error handling
if ((LA(1)=='\t'||LA(1)==' ') && (true)) {
mWS(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='\n'||LA(1)=='\r')) {
mLF(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='#') && (true)) {
mSHARP(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='.') && (true)) {
mDOT(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='!') && (true)) {
mEXCLAMATION(true);
theRetToken=_returnToken;
}
else if ((LA(1)==',') && (true)) {
mCOMMA(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='{') && (true)) {
mLBRACKET(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='}') && (true)) {
mRBRACKET(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='=') && (true)) {
mASSIGN(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='\\') && (true)) {
mESCAPE(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='>') && (true)) {
mCOMMAND_REPLY_TERMINATOR(true);
theRetToken=_returnToken;
}
else if (((LA(1) >= '0' && LA(1) <= '9')) && (true)) {
mINT(true);
theRetToken=_returnToken;
}
else if ((_tokenSet_0.member(LA(1))) && (true)) {
mSTRING(true);
theRetToken=_returnToken;
}
else if ((_tokenSet_1.member(LA(1))) && (true)) {
mSTRINGCHAR1(true);
theRetToken=_returnToken;
}
else if (((LA(1) >= ' ' && LA(1) <= '~')) && (true)) {
mSTRINGCHAR2(true);
theRetToken=_returnToken;
}
else if ((_tokenSet_2.member(LA(1))) && (true)) {
mIDENT(true);
theRetToken=_returnToken;
}
else {
if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
}
if ( _returnToken==null ) continue tryAgain; // found SKIP token
_ttype = _returnToken.getType();
_ttype = testLiteralsTable(_ttype);
_returnToken.setType(_ttype);
return _returnToken;
}
catch (RecognitionException e) {
throw new TokenStreamRecognitionException(e);
}
}
catch (CharStreamException cse) {
if ( cse instanceof CharStreamIOException ) {
throw new TokenStreamIOException(((CharStreamIOException)cse).io);
}
else {
throw new TokenStreamException(cse.getMessage());
}
}
}
}
public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WS;
int _saveIndex;
{
switch ( LA(1)) {
case ' ':
{
match(' ');
break;
}
case '\t':
{
match('\t');
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
}
_ttype = Token.SKIP;
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mLF(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = LF;
int _saveIndex;
{
if ((LA(1)=='\r') && (LA(2)=='\n')) {
match("\r\n");
}
else if ((LA(1)=='\r') && (true)) {
match('\r');
}
else if ((LA(1)=='\n')) {
match('\n');
}
else {
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
newline();
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mSHARP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = SHARP;
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;
}
public final void mDOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = DOT;
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;
}
public final void mEXCLAMATION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = EXCLAMATION;
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;
}
public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = COMMA;
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;
}
public final void mLBRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = LBRACKET;
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;
}
public final void mRBRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RBRACKET;
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;
}
public final void mASSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ASSIGN;
int _saveIndex;
match("=");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -