📄 preprocessorlexer.java
字号:
// $ANTLR 2.7.1: "preproc.g" -> "PreprocessorLexer.java"$
package antlr_oaa.preprocessor;
import java.io.InputStream;
import antlr_oaa.TokenStreamException;
import antlr_oaa.TokenStreamIOException;
import antlr_oaa.TokenStreamRecognitionException;
import antlr_oaa.CharStreamException;
import antlr_oaa.CharStreamIOException;
import antlr_oaa.ANTLRException;
import java.io.Reader;
import java.util.Hashtable;
import antlr_oaa.CharScanner;
import antlr_oaa.InputBuffer;
import antlr_oaa.ByteBuffer;
import antlr_oaa.CharBuffer;
import antlr_oaa.Token;
import antlr_oaa.CommonToken;
import antlr_oaa.RecognitionException;
import antlr_oaa.NoViableAltForCharException;
import antlr_oaa.MismatchedCharException;
import antlr_oaa.TokenStream;
import antlr_oaa.ANTLRHashString;
import antlr_oaa.LexerSharedInputState;
import antlr_oaa.collections.impl.BitSet;
import antlr_oaa.SemanticException;
public class PreprocessorLexer extends antlr_oaa.CharScanner implements PreprocessorTokenTypes, TokenStream
{
public PreprocessorLexer(InputStream in) {
this(new ByteBuffer(in));
}
public PreprocessorLexer(Reader in) {
this(new CharBuffer(in));
}
public PreprocessorLexer(InputBuffer ib) {
this(new LexerSharedInputState(ib));
}
public PreprocessorLexer(LexerSharedInputState state) {
super(state);
literals = new Hashtable();
literals.put(new ANTLRHashString("catch", this), new Integer(25));
literals.put(new ANTLRHashString("exception", this), new Integer(24));
literals.put(new ANTLRHashString("class", this), new Integer(7));
literals.put(new ANTLRHashString("public", this), new Integer(17));
literals.put(new ANTLRHashString("tokens", this), new Integer(4));
literals.put(new ANTLRHashString("returns", this), new Integer(20));
literals.put(new ANTLRHashString("private", this), new Integer(16));
literals.put(new ANTLRHashString("protected", this), new Integer(15));
literals.put(new ANTLRHashString("throws", this), new Integer(22));
literals.put(new ANTLRHashString("extends", 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 ':':
{
mRULE_BLOCK(true);
theRetToken=_returnToken;
break;
}
case '\t': case '\n': case '\r': case ' ':
{
mWS(true);
theRetToken=_returnToken;
break;
}
case '(':
{
mSUBRULE_BLOCK(true);
theRetToken=_returnToken;
break;
}
case '/':
{
mCOMMENT(true);
theRetToken=_returnToken;
break;
}
case '{':
{
mACTION(true);
theRetToken=_returnToken;
break;
}
case '"':
{
mSTRING_LITERAL(true);
theRetToken=_returnToken;
break;
}
case '\'':
{
mCHAR_LITERAL(true);
theRetToken=_returnToken;
break;
}
case '!':
{
mBANG(true);
theRetToken=_returnToken;
break;
}
case ';':
{
mSEMI(true);
theRetToken=_returnToken;
break;
}
case ',':
{
mCOMMA(true);
theRetToken=_returnToken;
break;
}
case '}':
{
mRCURLY(true);
theRetToken=_returnToken;
break;
}
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': 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_OR_KEYWORD(true);
theRetToken=_returnToken;
break;
}
case '=':
{
mASSIGN_RHS(true);
theRetToken=_returnToken;
break;
}
case '[':
{
mARG_ACTION(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();
_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 mRULE_BLOCK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RULE_BLOCK;
int _saveIndex;
match(':');
{
if ((_tokenSet_0.member(LA(1))) && (_tokenSet_1.member(LA(2)))) {
_saveIndex=text.length();
mWS(false);
text.setLength(_saveIndex);
}
else if ((_tokenSet_1.member(LA(1))) && (true)) {
}
else {
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());
}
}
mALT(false);
{
switch ( LA(1)) {
case '\t': case '\n': case '\r': case ' ':
{
_saveIndex=text.length();
mWS(false);
text.setLength(_saveIndex);
break;
}
case ';': case '|':
{
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());
}
}
}
{
_loop42:
do {
if ((LA(1)=='|')) {
match('|');
{
if ((_tokenSet_0.member(LA(1))) && (_tokenSet_1.member(LA(2)))) {
_saveIndex=text.length();
mWS(false);
text.setLength(_saveIndex);
}
else if ((_tokenSet_1.member(LA(1))) && (true)) {
}
else {
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());
}
}
mALT(false);
{
switch ( LA(1)) {
case '\t': case '\n': case '\r': case ' ':
{
_saveIndex=text.length();
mWS(false);
text.setLength(_saveIndex);
break;
}
case ';': case '|':
{
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());
}
}
}
}
else {
break _loop42;
}
} 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 mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WS;
int _saveIndex;
{
int _cnt82=0;
_loop82:
do {
if ((LA(1)==' ') && (true)) {
match(' ');
}
else if ((LA(1)=='\t') && (true)) {
match('\t');
}
else if ((LA(1)=='\n'||LA(1)=='\r') && (true)) {
mNEWLINE(false);
}
else {
if ( _cnt82>=1 ) { break _loop82; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());}
}
_cnt82++;
} while (true);
}
_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;
}
protected final void mALT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ALT;
int _saveIndex;
{
_loop53:
do {
if ((_tokenSet_2.member(LA(1))) && ((LA(2) >= '\u0003' && LA(2) <= '~'))) {
mELEMENT(false);
}
else {
break _loop53;
}
} while (true);
}
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 mSUBRULE_BLOCK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = SUBRULE_BLOCK;
int _saveIndex;
match('(');
{
if ((_tokenSet_0.member(LA(1))) && (_tokenSet_3.member(LA(2)))) {
mWS(false);
}
else if ((_tokenSet_3.member(LA(1))) && (true)) {
}
else {
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());
}
}
mALT(false);
{
_loop48:
do {
if ((_tokenSet_4.member(LA(1))) && (_tokenSet_3.member(LA(2)))) {
{
switch ( LA(1)) {
case '\t': case '\n': case '\r': case ' ':
{
mWS(false);
break;
}
case '|':
{
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());
}
}
}
match('|');
{
if ((_tokenSet_0.member(LA(1))) && (_tokenSet_3.member(LA(2)))) {
mWS(false);
}
else if ((_tokenSet_3.member(LA(1))) && (true)) {
}
else {
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());
}
}
mALT(false);
}
else {
break _loop48;
}
} while (true);
}
{
switch ( LA(1)) {
case '\t': case '\n': case '\r': case ' ':
{
mWS(false);
break;
}
case ')':
{
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());
}
}
}
match(')');
{
if ((LA(1)=='=') && (LA(2)=='>')) {
match("=>");
}
else if ((LA(1)=='*') && (true)) {
match('*');
}
else if ((LA(1)=='+') && (true)) {
match('+');
}
else if ((LA(1)=='?') && (true)) {
match('?');
}
else {
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mELEMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ELEMENT;
int _saveIndex;
switch ( LA(1)) {
case '/':
{
mCOMMENT(false);
break;
}
case '{':
{
mACTION(false);
break;
}
case '"':
{
mSTRING_LITERAL(false);
break;
}
case '\'':
{
mCHAR_LITERAL(false);
break;
}
case '(':
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -