Move pos forward to the end of the next word. Words are composed of
    alphanumeric characters (letters and digits).
16761
def _forward_word(text, pos):
    
    while pos < len(text) and not text[pos].isalnum():
        pos += 1
    while pos < len(text) and text[pos].isalnum():
        pos += 1
    return text, pos
520805
protected IWord nextLatinWord(int c, int pos) throws IOException 
    {
        isb.clear();
        if ( c > 65280 ) c -= 65248;
        if ( c >= 65 && c <= 90 ) c += 32; 
        isb.append((char)c);
        
        int ch;
        //EC word, single units control variables.
        boolean _check  = false;
        boolean _wspace = false;
        
        //Secondary segmentation
        int _ctype = 0;
        int tcount = 1;                                  //number of different char type.
        int _TYPE  = StringUtil.getEnCharType(c);        //current char type.
        ctrlMask &= ~ISegment.START_SS_MASK;            //reset the secondary segment mask.
        
        while ( ( ch = readNext() ) != -1 ) {
            //Covert the full-width char to half-width char.
            if ( ch > 65280 ) ch -= 65248;
            _ctype = StringUtil.getEnCharType(ch);
            
            //Whitespace check.
            if ( _ctype == StringUtil.EN_WHITESPACE ) {
                _wspace = true;
                break;
            }
            
            //English punctuation check.
            if ( _ctype == StringUtil.EN_PUNCTUATION ) {
                if ( ! config.isKeepPunctuation((char)ch) ) {
                    pushBack(ch);
                    break;
                }
            }
            
            //Not EN_KNOW, and it could be letter, numeric.
            if ( _ctype == StringUtil.EN_UNKNOW ) {
                pushBack(ch);
                if ( StringUtil.isCJKChar( ch ) ) {
                    _check = true;
                }
                
                break;
            }
            
            //covert the lower case letter to upper case.
            if ( ch >= 65 && ch <= 90 ) ch += 32;
            
            //append the char to the buffer.
            isb.append((char)ch);
            
            /* Char type counter. 
             * condition to start the secondary segmentation.
             * @reader: we could do better.
             * 
             * @added 2013-12-16
            */
            if ( _ctype != _TYPE ) {
                tcount++;
                _TYPE = _ctype;
            }
            
            /*
             * global English word length limitation 
            */
            if ( isb.length() > config.MAX_LATIN_LENGTH ) {
                break;
            }
        }
        
        String __str = isb.toString();
        IWord w = null;
        boolean chkunits = true;
        
        /* 
         * @step 2: 
         * 1. clear the useless English punctuation from the end.
         * 2. try to find the English and punctuation mixed word.
         * 
         * set _ctype as the status for the existence of punctuation
         * at the end of the isb cause we need to plus the tcount 
         * to avoid the secondary check for words like chenxin+, c+.
        */
        _ctype = 0;
        for ( int t = isb.length() - 1; t > 0 
                && isb.charAt(t) != '%'
                && StringUtil.isEnPunctuation(isb.charAt(t)); t-- ) {
            /*
             * try to find a English and punctuation mixed word.
             * this will clear all the punctuation until a mixed word is found.
             * like "i love c++.", c++ will be found from token "c++.".
             * 
             * @Note: added at 2013/08/31 
            */
            if ( dic.match(ILexicon.CJK_WORD, __str) ) {
                w = dic.get(ILexicon.CJK_WORD, __str).clone();
                w.setPartSpeech(IWord.EN_POSPEECH);
                chkunits = false;
                break;
            }
            
            /*
             * keep the English punctuation.
             * @date 2013/09/06 
             */
            pushBack(isb.charAt(t));
            isb.deleteCharAt(t);
            __str = isb.toString();
            
            /*check and plus the tcount.*/
            if ( _ctype == 0 ) {
                tcount--;
                _ctype = 1;
            }
        }
        
        //condition to start the secondary segmentation.
        boolean ssseg = (tcount > 1) && chkunits;
        
        /* @step 3: check the end condition.
         * and the check if the token loop was break by whitespace
         * cause there is no need to continue all the following work if it is.
         * 
         * @added 2013-11-19 
        */
        if ( ch == -1 || _wspace ) {
            w = new Word(__str, IWord.T_BASIC_LATIN);
            w.setPartSpeech(IWord.EN_POSPEECH);
            if ( ssseg ) ctrlMask |= ISegment.START_SS_MASK;
            return w;
        }
        
        if ( ! _check ) {    
            /* 
             * @reader: (2013-09-25)
             * we check the units here, so we can recognize
             * many other units that is not Chinese like '℉,℃' eg..
            */
            if ( chkunits && ( StringUtil.isDigit(__str) 
                        || StringUtil.isDecimal(__str) ) ) {
                ch = readNext();
                if ( dic.match(ILexicon.CJK_UNIT, ((char)ch)+"") ) {
                    w = new Word(new String(__str+((char)ch)), IWord.T_MIXED_WORD);
                    w.setPartSpeech(IWord.NUMERIC_POSPEECH);
                } else {
                    pushBack(ch);
                }
            }
            
            if ( w == null ) {
                w = new Word(__str, IWord.T_BASIC_LATIN);
                w.setPartSpeech(IWord.EN_POSPEECH);
                if ( ssseg ) ctrlMask |= ISegment.START_SS_MASK;
            }
            
            return w;
        }
        
        
        //@step 4: check and get English and Chinese mixed word like 'B超'.
        IStringBuffer ibuffer = new IStringBuffer();
        ibuffer.append(__str);
        String _temp = null;
        int mc = 0, j = 0;        //the number of char that readed from the stream.
        
        //replace width IntArrayList at 2013-09-08
        //ArrayList<Integer> chArr = new ArrayList<Integer>(config.MIX_CN_LENGTH);
        ialist.clear();
        
        /* 
         * Attention:
         * make sure that (ch = readNext()) is after j < Config.MIX_CN_LENGTH.
         * or it cause the miss of the next char. 
         * 
         * @reader: (2013-09-25)
         * we do not check the type of the char readed next.
         * so, words started with English and its length except the start English part
         * less than config.MIX_CN_LENGTH in the EC dictionary could be recognized.
         * 
         * @Note added at 2017/08/05
         * Add the ibuffer.length checking logic to follow the limitation 
         * of the maximum length of the current token 
        */
        for ( ; j < dic.mixSuffixLength 
                && ibuffer.length() < config.MAX_LENGTH 
                    && (ch = readNext()) != -1; j++ ) {
            /* 
             * Attention:
             *  it is a accident that Jcseg works fine for 
             *  we break the loop directly when we meet a whitespace.
             *  1. if a EC word is found, unit check process will be ignore.
             *  2. if matches no EC word, certainly return of readNext() 
             *      will make sure the units check process works find.
             */
            if ( StringUtil.isWhitespace(ch) ) {
                pushBack(ch);
                break;
            }
            
            ibuffer.append((char)ch);
            ialist.add(ch);
            _temp = ibuffer.toString();
            if ( dic.match(ILexicon.CJK_WORD, _temp) ) {
                w  = dic.get(ILexicon.CJK_WORD, _temp);
                mc = j + 1;
            }
        }
        
        ibuffer.clear();
        ibuffer = null;        //Let gc do it's work.
        
        //push back the read chars.
        for ( int i = j - 1; i >= mc; i-- ) pushBack(ialist.get(i));
        //chArr.clear();chArr = null;
        
        /* @step 5: check if there is a units for the digit.
         * @reader: (2013-09-25)
         * now we check the units before the step 4, so we can recognize
         * many other units that is not Chinese like '℉,℃'
        */
        if ( chkunits && mc == 0 ) {
            if ( StringUtil.isDigit(__str) || StringUtil.isDecimal(__str) ) {
                ch = readNext();
                if ( dic.match(ILexicon.CJK_UNIT, ((char)ch)+"") ) {
                    w = new Word(new String(__str+((char)ch)), IWord.T_MIXED_WORD);
                    w.setPartSpeech(IWord.NUMERIC_POSPEECH);
                } else {
                    pushBack(ch);
                }
            }
        }
        
        /* simply return the combination of English char, Arabic
         * numeric, English punctuation if matches no single units or EC word.
        */
        if ( w == null ) {
            w = new Word(__str, IWord.T_BASIC_LATIN);
            w.setPartSpeech(IWord.EN_POSPEECH);
            if ( ssseg ) ctrlMask |= ISegment.START_SS_MASK;
        } else if ( mc > 0 ) {
            w = w.clone();
        }
        
        return w;
    }
1339758
private boolean nextButOneIsModal(AnalyzedTokenReadings[] tokens, int pos) {
    return pos < tokens.length - 2 && tokens[pos+2].hasPartialPosTag(":MOD:");
  }
1343377
function consumeWord(forward) {
            log.debug("consumeWord called, forward is " + forward);
            var pos, textChar;
            var newChars = [], it = forward ? forwardIterator : backwardIterator;

            var passedWordBoundary = false, insideWord = false;

            while ( (pos = it.next()) ) {
                textChar = pos.character;

                log.debug("Testing char '" + textChar + "'");

                if (allWhiteSpaceRegex.test(textChar)) {
                    if (insideWord) {
                        insideWord = false;
                        passedWordBoundary = true;
                    }
                } else {
                    log.debug("Got non-whitespace, passedWordBoundary is " + passedWordBoundary);
                    if (passedWordBoundary) {
                        it.rewind();
                        break;
                    } else {
                        insideWord = true;
                    }
                }
                newChars.push(pos);
            }

            log.debug("consumeWord done, pos is " + (pos ? pos.inspect() : "non-existent"));

            log.debug("consumeWord got new chars " + newChars.join(""));
            return newChars;
        }
1032838
function _advance()
	{
		$i = $this->_current_char;
		$formula_length = strlen($this->_formula);
		// eat up white spaces
		if ($i < $formula_length) {
			while ($this->_formula{$i} == " ") {
				++$i;
			}

			if ($i < ($formula_length - 1)) {
				$this->_lookahead = $this->_formula{$i+1};
			}
			$token = '';
		}

		while ($i < $formula_length) {
			$token .= $this->_formula{$i};

			if ($i < ($formula_length - 1)) {
				$this->_lookahead = $this->_formula{$i+1};
			} else {
				$this->_lookahead = '';
			}

			if ($this->_match($token) != '') {
				//if ($i < strlen($this->_formula) - 1) {
				//    $this->_lookahead = $this->_formula{$i+1};
				//}
				$this->_current_char = $i + 1;
				$this->_current_token = $token;
				return 1;
			}

			if ($i < ($formula_length - 2)) {
				$this->_lookahead = $this->_formula{$i+2};
			} else { // if we run out of characters _lookahead becomes empty
				$this->_lookahead = '';
			}
			++$i;
		}
		//die("Lexical error ".$this->_current_char);
	}
208882
public boolean nextLine() {
	while (isValidIndex() && text[pos] != '\n') {
	    next();
	}
	if (isValidIndex() && text[pos] == '\n') {
	    next();
	    return isValidIndex();
	}
	return false;
    }
521220
def _forward(self):
        
        try:
            self.current_token = next(self.tokens)
        except StopIteration:
            raise MissingTokensError("Unexpected end of token stream at %d." %
                self.current_pos)
        self.current_pos += 1
1022377
def move_pos(line=1, column=1, file=sys.stdout):
    
    move.pos(line=line, col=column).write(file=file)
896991
def advance(self, length):
        """"""
        new_position = self._position + length
        if new_position < 0 or new_position > len(self._data):
            raise Exception('Invalid advance amount (%s) for cursor.  '
                            'Position=%s' % (length, new_position))
        self._position = new_position
1297537
def forward_word(event):
    
    buff = event.current_buffer
    pos = buff.document.find_next_word_ending(count=event.arg)

    if pos:
        buff.cursor_position += pos
317590
public void advance() {
        String s = null;
        if (baseIterator.hasNext())
            next = baseIterator.next();
        else
            next = null;
    }
664567
def backward_word(event):
    
    buff = event.current_buffer
    pos = buff.document.find_previous_word_beginning(count=event.arg)

    if pos:
        buff.cursor_position += pos
1142918
private void scanLitChar(int pos) {
        if (reader.ch == '\\') {
            if (reader.peekChar() == '\\' && !reader.isUnicode()) {
                reader.skipChar();
                reader.putChar('\\', true);
            } else {
                reader.scanChar();
                switch (reader.ch) {
                case '0': case '1': case '2': case '3':
                case '4': case '5': case '6': case '7':
                    char leadch = reader.ch;
                    int oct = reader.digit(pos, 8);
                    reader.scanChar();
                    if ('0' <= reader.ch && reader.ch <= '7') {
                        oct = oct * 8 + reader.digit(pos, 8);
                        reader.scanChar();
                        if (leadch <= '3' && '0' <= reader.ch && reader.ch <= '7') {
                            oct = oct * 8 + reader.digit(pos, 8);
                            reader.scanChar();
                        }
                    }
                    reader.putChar((char)oct);
                    break;
                case 'b':
                    reader.putChar('\b', true); break;
                case 't':
                    reader.putChar('\t', true); break;
                case 'n':
                    reader.putChar('\n', true); break;
                case 'f':
                    reader.putChar('\f', true); break;
                case 'r':
                    reader.putChar('\r', true); break;
                case '\'':
                    reader.putChar('\'', true); break;
                case '\"':
                    reader.putChar('\"', true); break;
                case '\\':
                    reader.putChar('\\', true); break;
                default:
                    lexError(reader.bp, "illegal.esc.char");
                }
            }
        } else if (reader.bp != reader.buflen) {
            reader.putChar(true);
        }
    }
1351042
def token_at_cursor(code, pos=0):
    
    l = len(code)
    end = start = pos
    # Go forwards while we get alphanumeric chars
    while end < l and code[end].isalpha():
        end += 1
    # Go backwards while we get alphanumeric chars
    while start > 0 and code[start-1].isalpha():
        start -= 1
    # If previous character is a %, add it (potential magic)
    if start > 0 and code[start-1] == '%':
        start -= 1
    return code[start:end], start
855057
def _kill_word(text, pos):
    
    text, end_pos = _forward_word(text, pos)
    return text[:pos] + text[end_pos:], pos
1360116
def _downcase_word(text, pos):
    """"""
    text, new_pos = _forward_word(text, pos)
    return text[:pos] + text[pos:new_pos].lower() + text[new_pos:], new_pos
806223
def _upcase_word(text, pos):
    """"""
    text, new_pos = _forward_word(text, pos)
    return text[:pos] + text[pos:new_pos].upper() + text[new_pos:], new_pos