📄 pgnlexer.java
字号:
// $ANTLR 2.7.1: "pgn.g" -> "PGNLexer.java"$package de.java_chess.javaChess.pgn;import antlr.*;import antlr.collections.*; 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;/** * A lexer for PGN files. */public class PGNLexer extends antlr.CharScanner implements PGNTokenTypes, TokenStream {public PGNLexer(InputStream in) { this(new ByteBuffer(in));}public PGNLexer(Reader in) { this(new CharBuffer(in));}public PGNLexer(InputBuffer ib) { this(new LexerSharedInputState(ib));}public PGNLexer(LexerSharedInputState state) { super(state); literals = new Hashtable(); literals.put(new ANTLRHashString("x", this), new Integer(9));caseSensitiveLiterals = true;setCaseSensitive(true);}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 switch ( LA(1)) { case '.': { mDOT(true); theRetToken=_returnToken; break; } case ';': { mSL_COMMENT(true); theRetToken=_returnToken; break; } case '"': { mSTRING_LITERAL(true); theRetToken=_returnToken; break; } case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': { mSQUARE_NAME(true); theRetToken=_returnToken; break; } case 'B': case 'K': case 'N': case 'P': case 'Q': case 'R': { mFIGURINE_LETTER_CODE(true); theRetToken=_returnToken; break; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { mMOVE_INDEX(true); theRetToken=_returnToken; break; } default: { if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);} else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());} } } if ( _returnToken==null ) continue tryAgain; // found SKIP token _ttype = _returnToken.getType(); _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 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 mSL_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = SL_COMMENT; int _saveIndex; match(";"); { _loop25: do { if ((_tokenSet_0.member(LA(1)))) { { match(_tokenSet_0); } } else { break _loop25; } } while (true); } { if ((LA(1)=='\r') && (LA(2)=='\n')) { match("\r\n"); } else if ((LA(1)=='\n')) { match("\n"); } else if ((LA(1)=='\r') && (true)) { match("\r"); } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine()); } } _ttype = Token.SKIP; 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 mSTRING_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = STRING_LITERAL; int _saveIndex; { match('"'); { _loop31: do { if ((_tokenSet_1.member(LA(1)))) { { match(_tokenSet_1); } } else { break _loop31; } } while (true); } 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 mSQUARE_NAME(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = SQUARE_NAME; int _saveIndex; matchRange('a','h'); matchRange('1','8'); 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 mFIGURINE_LETTER_CODE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = FIGURINE_LETTER_CODE; int _saveIndex; { switch ( LA(1)) { case 'P': { match('P'); break; } case 'N': { match('N'); break; } case 'B': { match('B'); break; } case 'R': { match('R'); break; } case 'Q': { match('Q'); break; } case 'K': { match('K'); break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine()); } } } 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 mMOVE_INDEX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = MOVE_INDEX; int _saveIndex; matchRange('1','9'); { _loop37: do { if (((LA(1) >= '0' && LA(1) <= '9'))) { matchRange('0','9'); } else { break _loop37; } } while (true); } mDOT(false); if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } private static final long _tokenSet_0_data_[] = { -9224L, -1L, -1L, -1L, 0L, 0L, 0L, 0L }; public static final BitSet _tokenSet_0 = new BitSet(_tokenSet_0_data_); private static final long _tokenSet_1_data_[] = { -17179869192L, -268435457L, -1L, -1L, 0L, 0L, 0L, 0L }; public static final BitSet _tokenSet_1 = new BitSet(_tokenSet_1_data_); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -