public void match(String s) throws MismatchedCharException, CharStreamException { int len = s.length(); for (int i = 0; i < len; i++) { if (LA(1) != s.charAt(i)) { throw new MismatchedCharException(LA(1), s.charAt(i), false, this); } consume(); } }
public void match(char c) throws MismatchedCharException, CharStreamException { if (LA(1) != c) { throw new MismatchedCharException(LA(1), c, false, this); } consume(); }
public void matchNot(char c) throws MismatchedCharException, CharStreamException { if (LA(1) == c) { throw new MismatchedCharException(LA(1), c, true, this); } consume(); }
public void match(BitSet b) throws MismatchedCharException, CharStreamException { if (!b.member(LA(1))) { throw new MismatchedCharException(LA(1), b, false, this); } else { consume(); } }
public void matchRange(char c1, char c2) throws MismatchedCharException, CharStreamException { if (LA(1) < c1 || LA(1) > c2) throw new MismatchedCharException(LA(1), c1, c2, false, this); consume(); }
protected final void mSTRING_NL(boolean _createToken, boolean allowNewline ) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = STRING_NL; int _saveIndex; if ( inputState.guessing==0 ) { if (!allowNewline) throw new MismatchedCharException('\n', '\n', true, this); } mONE_NL(false,false); if ( inputState.guessing==0 ) { text.setLength(_begin); text.append('\n'); } 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 mSTRING_NL(boolean _createToken, boolean allowNewline ) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = STRING_NL; int _saveIndex; if ( inputState.guessing==0 ) { if (!allowNewline) throw new MismatchedCharException('\n', '\n', true, this); } mONE_NL(false,false); if ( inputState.guessing==0 ) { text.setLength(_begin); text.append('\n'); } 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 mSTRING_NL(boolean _createToken, boolean allowNewline ) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = STRING_NL; int _saveIndex; if ( inputState.guessing==0 ) { if (!allowNewline) throw new MismatchedCharException('\n', '\n', true, this); } mONE_NL(false,false); if ( inputState.guessing==0 ) { text.setLength(_begin); text.append('\n'); } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; }