进入每个扫描方法之前 peek() 处于可用状态，不需要 next()
每个扫描方法内部是否要 next() 移动，取决定具体情况
每个扫描方法成功返回前，将 forward 置于下一次扫描需要处理的地方
让下个扫描方法不必 next()
紧靠 scanText() 之前的扫描方法在失败后必须保持住forward
这是 scanText() 可以一直向前的保障
542991
public List<Token> scan() {
		while (peek() != EOF) {
			if (peek() == '#') {
				if (scanDire()) {
					continue ;
				}
				if (scanSingleLineComment()) {
					continue ;
				}
				if (scanMultiLineComment()) {
					continue ;
				}
				if (scanNoParse()) {
					continue ;
				}
			}
			
			scanText();
		}
		return tokens;
	}
1166599
public Sentence next() throws IOException
    {
        gisb.clear();
        int c, pos = -1;
        
        while ( (c = readNext()) != -1 ) {
            //clear the whitespace of the begainning
            if ( StringUtil.isWhitespace(c) ) continue;
            if ( c == '\n' || c == '\t' || c == '…' ) continue;
            if ( StringUtil.isCnPunctuation(c) ) {
                switch ( (char)c ) {
                case '“':
                case '【':
                case '（':
                case '《':
                case '｛':
                    break;
                default: continue;
                }
            }
            
            if ( StringUtil.isEnPunctuation(c)) {
                switch ( (char)c ) {
                case '"':
                /*case '[':
                case '(':
                case '{':
                case '<':*/
                    break;
                default: continue;
                }
            }
             
            pos = idx;
            gisb.clear().append((char)c);
            
            while ( (c = readNext()) != -1 ) {
                boolean endTag = false;
                
                /*
                 * here, define the sentence end tag
                 * punctuation like the following:
                 * .。\n;；?？!！:： 
                */
                switch ((char)c) {
                case '"': gisb.append('"'); readUntil('"');  break;
                case '“': gisb.append('“'); readUntil('”');  break;
                case '【': gisb.append('【'); readUntil('】'); break;
                case '《': gisb.append('《'); readUntil('》'); break;
                case '.': {
                    int chr = readNext();
                    gisb.append((char)c);
                    if ( StringUtil.isEnLetter(chr) )  {
                        reader.unread(chr);
                        continue;
                    } else {
                        endTag = true;
                    }
                    
                    break;
                }
                case '。':
                case ';':
                case '；':
                case '?':
                case '？':
                case '!':
                case '！':
                case '…': {
                    endTag = true;
                    gisb.append((char)c);
                    break;
                }
                case ':':
                case '：':
                case '\n': {
                    endTag = true;
                    break;
                }
                default:
                    gisb.append((char)c);
                }
                
                if ( endTag ) break;
            }

            //clear the whitespace from the back
            for ( int i = gisb.length() - 1; i >= 0; i-- ) {
                char chr = gisb.charAt(i);
                if ( chr == ' ' || chr == '\t' ) gisb.deleteCharAt(i);
                else break;
            }
            
            if ( gisb.length() <= 1 ) continue;
            return new Sentence(gisb.toString(), pos);
        }
                
        return null;
    }
431146
def peek(self, n=0, skip=None, drop=False):
        
        buffer = self._buffer
        popleft = buffer.popleft
        datum = None
        if skip is not None:
            stack = []
            stackpush = stack.append
            while n >= 0:
                try:
                    datum = popleft()
                except IndexError:
                    self._buffer_fill()
                    datum = popleft()
                if not skip(datum):
                    n -= 1
                    stackpush(datum)
                elif not drop:
                    stackpush(datum)
            buffer.extendleft(reversed(stack))
        else:
            self._buffer_fill(n + 1)
            datum = buffer[n]
        return datum
914188
def peek(self):
        '''
        '''

        if self.position >= len(self.tokens):
            return None

        return self.tokens[self.position]
1353580
final Object peek() {
        int size = stack.size();
        return size == 0 ? null : stack.get(size - 1);
    }
806992
function peek(tok) {
        if (typeof(tok) === 'string') {
            return input.charAt(i) === tok;
        } else {
            return tok.test(current);
        }
    }
360028
private static int locateNextStop(FastStr str, int start) {
        final int sz = str.length();
        if (start >= sz - 1) {
            return -1;
        }
        char c0 = str.charAt(start);
        boolean isDigit = Character.isDigit(c0);
        boolean isLetter = !isDigit && Character.isLetter(c0);
        boolean isLower = isLetter && Character.isLowerCase(c0);
        boolean isUpper = isLetter && !isLower;
        if (isUpper) {
            char c1 = str.charAt(start + 1);
            boolean c2IsSeparator = isSeparator(c1);
            if (c2IsSeparator) {
                return start + 1;
            }
            boolean c2IsDigit = !c2IsSeparator && Character.isDigit(c1);
            if (c2IsDigit) {
                // H1
                return start + 1;
            }
            boolean c2IsLetter = Character.isLetter(c1);
            if (!c2IsLetter) {
                return start + 1;
            }
            boolean c2IsLower = Character.isLowerCase(c1);
            if (c2IsLower) {
                // HttpProtocol
                return locateNextStop(str, start + 1);
            } else {
                int pos = start + 2;
                while (pos < sz) {
                    char ch = str.charAt(pos);
                    boolean curIsLetter = Character.isLetter(ch);
                    if (!curIsLetter) {
                        // HTTP-Protocol
                        break;
                    }
                    boolean curIsLower = Character.isLowerCase(ch);
                    if (curIsLower) {
                        // HTTPProtocol
                        pos--;
                        break;
                    }
                    pos++;
                }
                return pos;
            }
        }
        int pos = start + 1;
        while (pos < sz) {
            char ch = str.charAt(pos);
            if (isSeparator(ch)) {
                break;
            }
            if (isDigit) {
                if (!Character.isDigit(ch)) {
                    break;
                }
            } else {
                if (Character.isDigit(ch)) {
                    break;
                }
                if (isLower) {
                    if (!Character.isLowerCase(ch)) {
                        break;
                    }
                } else {

                }
            }
            pos++;
        }
        return pos;
    }
1334584
def num_forward_until(self, condition):
        
        i, c = 0, ''
        while self.hasNext() and not condition(self.peek()):
            c += self.forward(1)
            i += 1
        assert self.backward(i) == c
        return i
694114
def peek(self, length):
		
		t = self.current_position + length
		if not self.current_segment.inrange(t):
			raise Exception('Would read over segment boundaries!')
		return self.current_segment.data[self.current_position - self.current_segment.start_address :t - self.current_segment.start_address]
1314041
public void next(Action action,String depClass) {

		assert (!isFinalState());

		// 左焦点词在句子中的位置
		int lNode = trees.get(leftFocus).id;
		int rNode = trees.get(leftFocus + 1).id;

		switch (action) {
		case LEFT:
			trees.get(leftFocus + 1).setDepClass(depClass);  			
			trees.get(leftFocus).addRightChild(trees.get(leftFocus + 1));
			trees.remove(leftFocus + 1);
			isUpdated = true;

			break;
		case RIGHT:
			trees.get(leftFocus).setDepClass(depClass);			
			trees.get(leftFocus + 1).addLeftChild(trees.get(leftFocus));
			trees.remove(leftFocus);
			isUpdated = true;
			break;
		default:
			leftFocus++;
		}

		if (leftFocus >= trees.size() - 1) {
			if (!isUpdated) {
				isFinal = true;
			}
			back();
		}
	}
1341106
def forward_char(event):
    "  "
    buff = event.current_buffer
    buff.cursor_position += buff.document.get_cursor_right_position(count=event.arg)
901949
def peek(self, steps=1):
        """"""
        try:
            tokens = iter(self)
            for _ in six.moves.range(steps):
                next(tokens)

            return next(tokens)
        except StopIteration:
            return None
335055
protected boolean lookahead() {
        assert next == null : "looking ahead when next is already loaded";
        while(inner.hasNext()) {
            next = transform(inner.next());
            if(next!=null) {
                return true;
            }
        }
        noteExhausted();
        return false;
    }
307468
protected synchronized void skipForward(int eventsToSkip)
			throws IOException {
		int offset = 0;
		for (int i = 0; i < eventsToSkip; i++) {
			// adjust position for reading offset
			storage.seek(position);
			// read forward skip offset
			offset = storage.readInt();
			// set file pointer to next event position
			position += offset;
			// adjust index
			index++;
		}
	}
1349860
def _peek(self, n):  # type: (int) -> str
        
        # we always want to restore after exiting this scope
        with self._state(restore=True):
            buf = ""
            for _ in range(n):
                if self._current not in " \t\n\r#,]}":
                    buf += self._current
                    self.inc()
                    continue

                break
            return buf
647038
function peek(callback, main, alt) {
		var mw = core.base();
		mw.enabled = true;
		mw.main = (main || common.plain());
		mw.alt = (alt || common.plain());
		mw.callback = (callback || function (str, def /*, type, main, alt*/) {
			return def(String(str));
		});

		mw.error = function (str) {
			str = String(str);
			if (mw.enabled && mw.callback) {
				var tmp = mw.callback(str, mw.main.error, 'error', mw.main, mw.alt);
				if (typeof tmp !== 'string') {
					return mw.main.error(str);
				}
				return tmp;
			}
			return mw.alt.error(str);
		};
		mw.warning = function (str) {
			str = String(str);
			if (mw.enabled && mw.callback) {
				var tmp = mw.callback(str, mw.main.warning, 'warning', mw.main, mw.alt);
				if (typeof tmp !== 'string') {
					return mw.main.warning(str);
				}
				return tmp;
			}
			return mw.alt.warning(str);
		};
		mw.success = function (str) {
			str = String(str);
			if (mw.enabled && mw.callback) {
				var tmp = mw.callback(str, mw.main.success, 'success', mw.main, mw.alt);
				if (typeof tmp !== 'string') {
					return mw.main.success(str);
				}
				return tmp;
			}
			return mw.alt.success(str);
		};
		mw.accent = function (str) {
			str = String(str);
			if (mw.enabled && mw.callback) {
				var tmp = mw.callback(str, mw.main.accent, 'accent', mw.main, mw.alt);
				if (typeof tmp !== 'string') {
					return mw.main.accent(str);
				}
				return tmp;
			}
			return mw.alt.accent(str);
		};
		mw.signal = function (str) {
			str = String(str);
			if (mw.enabled && mw.callback) {
				var tmp = mw.callback(str, mw.main.signal, 'signal', mw.main, mw.alt);
				if (typeof tmp !== 'string') {
					return mw.main.signal(str);
				}
				return tmp;
			}
			return mw.alt.accent(str);
		};
		mw.muted = function (str) {
			str = String(str);
			if (mw.enabled && mw.callback) {
				var tmp = mw.callback(str, mw.main.muted, 'muted', mw.main, mw.alt);
				if (typeof tmp !== 'string') {
					return mw.main.muted(str);
				}
				return tmp;
			}
			return mw.alt.muted(str);
		};
		mw.plain = function (str) {
			str = String(str);
			if (mw.enabled && mw.callback) {
				var tmp = mw.callback(str, mw.main.plain, 'plain', mw.main, mw.alt);
				if (typeof tmp !== 'string') {
					return mw.main.plain(str);
				}
				return tmp;
			}
			return mw.alt.plain(str);
		};
		// html encode?
		mw.wrap = function (str, style) {
			return '<span class="' + mw.prefix + style + '">' + str + '</span>';
		};
		mw.toString = function () {
			return '<ministyle-peek>';
		};
		return mw;
	}
783311
protected void readForward(Decoder decoder) throws IOException {
    short numberOfTokens = decoder.in.readVarShort(3);
    if (0 < numberOfTokens) {
      long seek = decoder.in.peekLongCoord(decoder.node.getCursorCount());
      TrieNode toNode = decoder.node.traverse(seek + decoder.node.getCursorIndex());
      while (toNode.getDepth() > decoder.node.getDepth() + numberOfTokens) toNode = toNode.getParent();
      Interval interval = decoder.node.intervalTo(toNode);
      String str = toNode.getString(decoder.node);
      Bits bits = interval.toBits();
      if (verbose != null) {
        verbose.println(String.format("Read %s forward from %s to %s = %s", numberOfTokens, decoder.node.getDebugString(), toNode.getDebugString(), bits));
      }
      decoder.in.expect(bits);
      decoder.out.append(str);
      decoder.node = toNode;
    }
    else {
      assert (0 == decoder.node.index);
    }
  }