antlrlexer.java
来自「SRI international 发布的OAA框架软件」· Java 代码 · 共 1,637 行 · 第 1/3 页
JAVA
1,637 行
int _ttype; Token _token=null; int _begin=text.length();
_ttype = DIGIT;
int _saveIndex;
matchRange('0','9');
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 mVOCAB(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = VOCAB;
int _saveIndex;
matchRange('\3','\176');
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 mINT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = INT;
int _saveIndex;
{
int _cnt199=0;
_loop199:
do {
if (((LA(1) >= '0' && LA(1) <= '9'))) {
matchRange('0','9');
}
else {
if ( _cnt199>=1 ) { break _loop199; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());}
}
_cnt199++;
} 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 mARG_ACTION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ARG_ACTION;
int _saveIndex;
mNESTED_ARG_ACTION(false);
if ( inputState.guessing==0 ) {
setText(Tool.stripFrontBack(getText(), "[", "]"));
}
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 mNESTED_ARG_ACTION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NESTED_ARG_ACTION;
int _saveIndex;
match('[');
{
_loop203:
do {
switch ( LA(1)) {
case '[':
{
mNESTED_ARG_ACTION(false);
break;
}
case '\n':
{
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
break;
}
case '\'':
{
mCHAR_LITERAL(false);
break;
}
case '"':
{
mSTRING_LITERAL(false);
break;
}
case '\u0003': case '\u0004': case '\u0005': case '\u0006':
case '\u0007': case '\u0008': case '\t': case '\u000b':
case '\u000c': case '\u000e': case '\u000f': case '\u0010':
case '\u0011': case '\u0012': case '\u0013': case '\u0014':
case '\u0015': case '\u0016': case '\u0017': case '\u0018':
case '\u0019': case '\u001a': case '\u001b': case '\u001c':
case '\u001d': case '\u001e': case '\u001f': case ' ':
case '!': case '#': case '$': case '%':
case '&': case '(': case ')': case '*':
case '+': case ',': case '-': case '.':
case '/': case '0': case '1': case '2':
case '3': case '4': case '5': case '6':
case '7': case '8': case '9': case ':':
case ';': case '<': case '=': case '>':
case '?': 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':
case '\\': case '^': case '_': 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': case '{': case '|':
case '}': case '~':
{
matchNot(']');
break;
}
default:
if ((LA(1)=='\r') && (LA(2)=='\n')) {
match('\r');
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
}
else if ((LA(1)=='\r') && ((LA(2) >= '\u0003' && LA(2) <= '~'))) {
match('\r');
if ( inputState.guessing==0 ) {
newline();
}
}
else {
break _loop203;
}
}
} 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 mACTION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ACTION;
int _saveIndex;
int actionLine=getLine();
mNESTED_ACTION(false);
{
if ((LA(1)=='?')) {
match('?');
if ( inputState.guessing==0 ) {
_ttype = SEMPRED;
}
}
else {
}
}
if ( inputState.guessing==0 ) {
if ( _ttype==ACTION ) {
setText(Tool.stripFrontBack(getText(), "{", "}"));
}
else {
setText(Tool.stripFrontBack(getText(), "{", "}?"));
}
CommonToken t = new CommonToken(_ttype,new String(text.getBuffer(),_begin,text.length()-_begin));
t.setLine(actionLine); // set action line to start
_token = t;
}
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 mNESTED_ACTION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NESTED_ACTION;
int _saveIndex;
match('{');
{
_loop209:
do {
// nongreedy exit test
if ((LA(1)=='}') && (true)) break _loop209;
if ((LA(1)=='\n'||LA(1)=='\r') && ((LA(2) >= '\u0003' && LA(2) <= '~'))) {
{
if ((LA(1)=='\r') && (LA(2)=='\n')) {
match('\r');
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
}
else if ((LA(1)=='\r') && ((LA(2) >= '\u0003' && LA(2) <= '~'))) {
match('\r');
if ( inputState.guessing==0 ) {
newline();
}
}
else if ((LA(1)=='\n')) {
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
}
else {
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine());
}
}
}
else if ((LA(1)=='{') && ((LA(2) >= '\u0003' && LA(2) <= '~'))) {
mNESTED_ACTION(false);
}
else if ((LA(1)=='\'') && (_tokenSet_1.member(LA(2)))) {
mCHAR_LITERAL(false);
}
else if ((LA(1)=='/') && (LA(2)=='*'||LA(2)=='/')) {
mCOMMENT(false);
}
else if ((LA(1)=='"') && ((LA(2) >= '\u0003' && LA(2) <= '~'))) {
mSTRING_LITERAL(false);
}
else if (((LA(1) >= '\u0003' && LA(1) <= '~')) && ((LA(2) >= '\u0003' && LA(2) <= '~'))) {
matchNot(EOF_CHAR);
}
else {
break _loop209;
}
} 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 mTOKEN_REF(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = TOKEN_REF;
int _saveIndex;
matchRange('A','Z');
{
_loop212:
do {
switch ( LA(1)) {
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':
{
matchRange('a','z');
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':
{
matchRange('A','Z');
break;
}
case '_':
{
match('_');
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
matchRange('0','9');
break;
}
default:
{
break _loop212;
}
}
} while (true);
}
_ttype = testLiteralsTable(_ttype);
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 mRULE_REF(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RULE_REF;
int _saveIndex;
int t=0;
t=mINTERNAL_RULE_REF(false);
if ( inputState.guessing==0 ) {
_ttype=t;
}
{
if (true&&(t==LITERAL_options)) {
mWS_LOOP(false);
{
if ((LA(1)=='{')) {
match('{');
if ( inputState.guessing==0 ) {
_ttype = OPTIONS;
}
}
else {
}
}
}
else if (true&&(t==LITERAL_tokens)) {
mWS_LOOP(false);
{
if ((LA(1)=='{')) {
match('{');
if ( inputState.guessing==0 ) {
_ttype = TOKENS;
}
}
else {
}
}
}
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 int mINTERNAL_RULE_REF(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int t;
int _ttype; Token _token=null; int _begin=text.length();
_ttype = INTERNAL_RULE_REF;
int _saveIndex;
t = RULE_REF;
matchRange('a','z');
{
_loop222:
do {
switch ( LA(1)) {
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':
{
matchRange('a','z');
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':
{
matchRange('A','Z');
break;
}
case '_':
{
match('_');
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
matchRange('0','9');
break;
}
default:
{
break _loop222;
}
}
} while (true);
}
if ( inputState.guessing==0 ) {
t = testLiteralsTable(t);
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
return t;
}
protected final void mWS_LOOP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WS_LOOP;
int _saveIndex;
{
_loop219:
do {
switch ( LA(1)) {
case '\t': case '\n': case '\r': case ' ':
{
mWS(false);
break;
}
case '/':
{
mCOMMENT(false);
break;
}
default:
{
break _loop219;
}
}
} while (true);
}
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 mWS_OPT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WS_OPT;
int _saveIndex;
{
if ((_tokenSet_2.member(LA(1)))) {
mWS(false);
}
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 mNOT_USEFUL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NOT_USEFUL;
int _saveIndex;
boolean synPredMatched227 = false;
if (((LA(1)=='a') && (true))) {
int _m227 = mark();
synPredMatched227 = true;
inputState.guessing++;
try {
{
match('a');
}
}
catch (RecognitionException pe) {
synPredMatched227 = false;
}
rewind(_m227);
inputState.guessing--;
}
if ( synPredMatched227 ) {
match('a');
}
else if ((LA(1)=='a') && (true)) {
match('a');
}
else {
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;
}
private static final long _tokenSet_0_data_[] = { -9224L, 9223372036854775807L, 0L, 0L };
public static final BitSet _tokenSet_0 = new BitSet(_tokenSet_0_data_);
private static final long _tokenSet_1_data_[] = { -549755813896L, 9223372036854775807L, 0L, 0L };
public static final BitSet _tokenSet_1 = new BitSet(_tokenSet_1_data_);
private static final long _tokenSet_2_data_[] = { 4294977024L, 0L, 0L };
public static final BitSet _tokenSet_2 = new BitSet(_tokenSet_2_data_);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?