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(); } }
sb.append("expecting "); appendCharName(sb, expecting); sb.append(", found "); appendCharName(sb, foundChar); break; case NOT_CHAR: sb.append("expecting anything but '"); appendCharName(sb, expecting); sb.append("'; got it anyway"); break; sb.append("NOT "); sb.append("in range: "); appendCharName(sb, expecting); sb.append(".."); appendCharName(sb, upper); sb.append(", found "); appendCharName(sb, foundChar); break; case SET: int[] elems = set.toArray(); for (int i = 0; i < elems.length; i++) { appendCharName(sb, elems[i]); appendCharName(sb, foundChar); break; default :
if (mismatched.mismatchType == MismatchedCharException.CHAR) { if (mismatched.foundChar == EOF_CHAR) { ErrorMsg.error(mismatched.getLine(), mismatched.getColumn(), ErrorMsg.error(mismatched.getLine(), mismatched.getColumn(), I18NHelper.getMessage(msgs, "EXC_ExpectedCharFound", //NOI18N String.valueOf((char)mismatched.expecting),
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; }