public void mSUM_OPERATOR(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = SUM_OPERATOR; switch (LA(1)) { case '+': { match('+'); break; } case '-': { match('-'); break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
public BooToken(antlr.Token original, int type, string text) { setType(type); setText(text); setFilename(original.getFilename()); setLine(original.getLine()); setColumn(original.getColumn()); }
public void mDECREMENT(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = DECREMENT; match("--"); if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
protected void mDIGIT(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = DIGIT; matchRange('0', '9'); if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
public void mASSIGN(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = ASSIGN; match('='); { if ((LA(1) == '=' || LA(1) == '~')) { { switch (LA(1)) { case '=': { match('='); break; } case '~': { match('~'); break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } _ttype = CMP_OPERATOR; } else { } } if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
public void mCMP_OPERATOR(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = CMP_OPERATOR; if ((LA(1) == '<') && (LA(2) == '=')) { match("<="); } else if ((LA(1) == '>') && (LA(2) == '=')) { match(">="); } else if ((LA(1) == '!') && (LA(2) == '~')) { match("!~"); } else if ((LA(1) == '!') && (LA(2) == '=')) { match("!="); } else if ((LA(1) == '<') && (true)) { match('<'); } else if ((LA(1) == '>') && (true)) { match('>'); } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
public void mSINGLE_QUOTED_STRING(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = SINGLE_QUOTED_STRING; int _saveIndex = 0; _saveIndex = text.Length; match('\''); text.Length = _saveIndex; { // ( ... )* for (;;) { if ((LA(1) == '\\')) { mSQS_ESC(false); } else if ((tokenSet_0_.member(LA(1)))) { { match(tokenSet_0_); } } else { goto _loop30_breakloop; } } _loop30_breakloop :; } // ( ... )* _saveIndex = text.Length; match('\''); text.Length = _saveIndex; if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
public void mINT(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = INT; { // ( ... )+ int _cnt7 = 0; for (;;) { if (((LA(1) >= '0' && LA(1) <= '9'))) { mDIGIT(false); } else { if (_cnt7 >= 1) { goto _loop7_breakloop; } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());; } } _cnt7++; } _loop7_breakloop :; } // ( ... )+ if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
protected void mID_LETTER(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = ID_LETTER; { switch (LA(1)) { case '_': { match('_'); 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 '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; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
public void mID(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = ID; mID_LETTER(false); { // ( ... )* for (;;) { 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': 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_LETTER(false); break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { mDIGIT(false); break; } default: { goto _loop3_breakloop; } } } _loop3_breakloop :; } // ( ... )* _ttype = testLiteralsTable(_ttype); if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
void EnqueueIndent(antlr.Token originalToken) { _pendingTokens.Enqueue(CreateToken(originalToken, _indentTokenType, "<INDENT>")); }
public void mWS(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = WS; { // ( ... )+ int _cnt25 = 0; for (;;) { switch (LA(1)) { case ' ': { match(' '); break; } case '\t': { match('\t'); break; } case '\r': { match('\r'); break; } case '\n': { match('\n'); newline(); break; } default: { if (_cnt25 >= 1) { goto _loop25_breakloop; } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());; } } break; } _cnt25++; } _loop25_breakloop :; } // ( ... )+ _ttype = Token.SKIP; if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
public virtual void initialize(Token t) { }
antlr.Token CreateToken(antlr.Token originalToken, int newTokenType, string newTokenText) { return(new BooToken(originalToken, newTokenType, newTokenText)); }
void EnqueueEOS(antlr.Token originalToken) { _pendingTokens.Enqueue(CreateToken(originalToken, _eosTokenType, "<EOS>")); }
void EnqueueDedent(antlr.Token originalToken) { _pendingTokens.Enqueue(CreateToken(originalToken, _dedentTokenType, "<DEDENT>")); }
protected void mSQS_ESC(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token = null; int _begin = text.Length; _ttype = SQS_ESC; int _saveIndex = 0; _saveIndex = text.Length; match('\\'); text.Length = _saveIndex; { switch (LA(1)) { case '\'': { { match('\''); } break; } case 'r': { { match('r'); text.Length = _begin; text.Append("\r"); } break; } case 'n': { { match('n'); text.Length = _begin; text.Append("\n"); } break; } case 't': { { match('t'); text.Length = _begin; text.Append("\t"); } break; } case '\\': { { match('\\'); } break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); _token.setText(text.ToString(_begin, text.Length - _begin)); } returnToken_ = _token; }
public new 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 '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(true); theRetToken = returnToken_; break; } case '.': { mDOT(true); theRetToken = returnToken_; break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { mINT(true); theRetToken = returnToken_; break; } case ',': { mCOMMA(true); theRetToken = returnToken_; break; } case ':': { mCOLON(true); theRetToken = returnToken_; break; } case '?': { mQMARK(true); theRetToken = returnToken_; break; } case '(': { mLPAREN(true); theRetToken = returnToken_; break; } case ')': { mRPAREN(true); theRetToken = returnToken_; break; } case '[': { mLBRACK(true); theRetToken = returnToken_; break; } case ']': { mRBRACK(true); theRetToken = returnToken_; break; } case '%': case '*': case '/': { mMULT_OPERATOR(true); theRetToken = returnToken_; break; } case '!': case '<': case '>': { mCMP_OPERATOR(true); theRetToken = returnToken_; break; } case '=': { mASSIGN(true); theRetToken = returnToken_; break; } case '\t': case '\n': case '\r': case ' ': { mWS(true); theRetToken = returnToken_; break; } case '}': { mRBRACE(true); theRetToken = returnToken_; break; } case '\'': { mSINGLE_QUOTED_STRING(true); theRetToken = returnToken_; break; } default: if ((LA(1) == '+') && (LA(2) == '+')) { mINCREMENT(true); theRetToken = returnToken_; } else if ((LA(1) == '-') && (LA(2) == '-')) { mDECREMENT(true); theRetToken = returnToken_; } else if ((LA(1) == '+' || LA(1) == '-') && (true)) { mSUM_OPERATOR(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()); } } break; } if (null == returnToken_) { goto tryAgain; // found SKIP token } _ttype = returnToken_.Type; returnToken_.Type = _ttype; return(returnToken_); } catch (RecognitionException e) { throw new TokenStreamRecognitionException(e); } } catch (CharStreamException cse) { if (cse is CharStreamIOException) { throw new TokenStreamIOException(((CharStreamIOException)cse).io); } else { throw new TokenStreamException(cse.Message); } } } }
public antlr.Token nextToken() { if (_pendingTokens.Count > 0) { return((antlr.Token)_pendingTokens.Dequeue()); } antlr.Token token = _istream.nextToken(); while (null != token) { if (_wsTokenType == token.Type) { string text = token.getText(); string[] lines = text.Split('\r', '\n'); if (lines.Length < 2) { token = _istream.nextToken(); } else { string lastLine = lines[lines.Length - 1]; if (lastLine.Length > CurrentIndentLevel) { EnqueueIndent(token); _indentStack.Push(lastLine.Length); break; } else if (lastLine.Length < CurrentIndentLevel) { EnqueueEOS(token); do { EnqueueDedent(token); _indentStack.Pop(); }while (lastLine.Length < CurrentIndentLevel); break; } else { EnqueueEOS(token); token = _istream.nextToken(); } } } else if (antlr.Token.EOF_TYPE == token.Type) { EnqueueEOS(token); while (CurrentIndentLevel > 0) { EnqueueDedent(token); _indentStack.Pop(); } _pendingTokens.Enqueue(token); break; } else { _pendingTokens.Enqueue(token); break; } } return((antlr.Token)_pendingTokens.Dequeue()); }