jshop2lexer.java

来自「SHOP2 一个人工智能里面关于任务分解和任务规划的系统。JSHOP2是其jav」· Java 代码 · 共 967 行 · 第 1/2 页

JAVA
967
字号
// $ANTLR 2.7.2: "JSHOP2.g" -> "JSHOP2Lexer.java"$  package JSHOP2;  import java.io.IOException;  import java.util.LinkedList;  import java.util.Vector;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 JSHOP2Lexer extends antlr.CharScanner implements JSHOP2TokenTypes, TokenStream {public JSHOP2Lexer(InputStream in) {	this(new ByteBuffer(in));}public JSHOP2Lexer(Reader in) {	this(new CharBuffer(in));}public JSHOP2Lexer(InputBuffer ib) {	this(new LexerSharedInputState(ib));}public JSHOP2Lexer(LexerSharedInputState state) {	super(state);	caseSensitiveLiterals = false;	setCaseSensitive(false);	literals = new Hashtable();	literals.put(new ANTLRHashString("imply", this), new Integer(24));	literals.put(new ANTLRHashString("nil", this), new Integer(8));	literals.put(new ANTLRHashString("call", this), new Integer(26));	literals.put(new ANTLRHashString("member", this), new Integer(33));	literals.put(new ANTLRHashString("stdlib", this), new Integer(42));	literals.put(new ANTLRHashString("def-problem-set", this), new Integer(41));	literals.put(new ANTLRHashString("or", this), new Integer(22));	literals.put(new ANTLRHashString("defproblem", this), new Integer(5));	literals.put(new ANTLRHashString("assign", this), new Integer(25));	literals.put(new ANTLRHashString("forall", this), new Integer(15));	literals.put(new ANTLRHashString("defdomain", this), new Integer(9));	literals.put(new ANTLRHashString("not", this), new Integer(23));	literals.put(new ANTLRHashString("and", this), new Integer(21));}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 '/':				{					mDIV(true);					theRetToken=_returnToken;					break;				}				case '.':				{					mDOT(true);					theRetToken=_returnToken;					break;				}				case '=':				{					mEQUAL(true);					theRetToken=_returnToken;					break;				}				case '(':				{					mLP(true);					theRetToken=_returnToken;					break;				}				case '\t':  case '\n':  case '\u000c':  case '\r':				case ' ':				{					mWS(true);					theRetToken=_returnToken;					break;				}				case '*':				{					mMULT(true);					theRetToken=_returnToken;					break;				}				case '^':				{					mPOWER(true);					theRetToken=_returnToken;					break;				}				case ')':				{					mRP(true);					theRetToken=_returnToken;					break;				}				case ';':				{					mCOMMENT(true);					theRetToken=_returnToken;					break;				}				case '_':  case 'a':  case 'b':  case 'c':				case 'd':  case 'e':  case 'f':  case 'g':				case 'h':  case 'i':  case 'j':  case 'k':				case 'l':  case 'm':  case 'n':  case 'o':				case 'p':  case 'q':  case 'r':  case 's':				case 't':  case 'u':  case 'v':  case 'w':				case 'x':  case 'y':  case 'z':				{					mID(true);					theRetToken=_returnToken;					break;				}				case '?':				{					mVARID(true);					theRetToken=_returnToken;					break;				}				default:					if ((LA(1)==':') && (LA(2)=='-')) {						mAXIOM(true);						theRetToken=_returnToken;					}					else if ((LA(1)=='<') && (LA(2)=='=')) {						mLESSEQ(true);						theRetToken=_returnToken;					}					else if ((LA(1)=='-') && (_tokenSet_0.member(LA(2)))) {						mMINUS(true);						theRetToken=_returnToken;					}					else if ((LA(1)=='>') && (LA(2)=='=')) {						mMOREEQ(true);						theRetToken=_returnToken;					}					else if ((LA(1)=='!') && (LA(2)=='=')) {						mNOTEQ(true);						theRetToken=_returnToken;					}					else if ((LA(1)=='+') && (_tokenSet_0.member(LA(2)))) {						mPLUS(true);						theRetToken=_returnToken;					}					else if ((LA(1)==':') && (LA(2)=='f')) {						mFIRST(true);						theRetToken=_returnToken;					}					else if ((LA(1)==':') && (LA(2)=='i')) {						mIMMEDIATE(true);						theRetToken=_returnToken;					}					else if ((LA(1)==':') && (LA(2)=='m')) {						mMETHOD(true);						theRetToken=_returnToken;					}					else if ((LA(1)==':') && (LA(2)=='o')) {						mOPERATOR(true);						theRetToken=_returnToken;					}					else if ((LA(1)==':') && (LA(2)=='p')) {						mPROTECTION(true);						theRetToken=_returnToken;					}					else if ((LA(1)==':') && (LA(2)=='s')) {						mSORT(true);						theRetToken=_returnToken;					}					else if ((LA(1)==':') && (LA(2)=='u')) {						mUNORDERED(true);						theRetToken=_returnToken;					}					else if ((LA(1)=='<') && (true)) {						mLESS(true);						theRetToken=_returnToken;					}					else if ((LA(1)=='>') && (true)) {						mMORE(true);						theRetToken=_returnToken;					}					else if ((LA(1)=='!') && (true)) {						mOPID(true);						theRetToken=_returnToken;					}					else if ((_tokenSet_1.member(LA(1))) && (true)) {						mNUM(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();				_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 mAXIOM(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = AXIOM;		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 mDIV(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = DIV;		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 mEQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = EQUAL;		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 mLESS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = LESS;		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 mLESSEQ(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = LESSEQ;		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 mLP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = LP;		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 mMINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = MINUS;		int _saveIndex;				match('-');		mWS(false);		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 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;		}		case '\u000c':		{			match('\f');			break;		}		case '\n':  case '\r':		{			{			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();						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 mMORE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = MORE;		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 mMOREEQ(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = MOREEQ;		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 mMULT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = MULT;		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 mNOTEQ(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = NOTEQ;		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 mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = PLUS;		int _saveIndex;				match('+');		mWS(false);		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 mPOWER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {		int _ttype; Token _token=null; int _begin=text.length();		_ttype = POWER;		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;	}	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?