示例#1
0
func handleColon(tok common.Token, tb *tokBuf) bool {
  if tok.Type() == common.TOK_COLON {
    curTok := tb.tokBuf.PushBack(tok);
    tok2 := tb.getFilteredToken();  // whats behind the colon?
    if tok2.Type() != common.TOK_NL {
      // No TOK_NL: just 2 normal tokens then
      tb.tokBuf.PushBack(tok2);
    } else {
      curTok.Value = tb.lx.NewAnyTok(common.TOK_BLOCK_START,
          tok.SourcePiece().Start(), tok2.SourcePiece().End());
    }
    tb.curTok = curTok;
    return true;
  }
  return false;
}
示例#2
0
func (lx *Lexer) NewCopyTok(typ common.TokEnum, tok common.Token) common.Token {
	return &SimpleToken{typ, tok.SourcePiece()}
}
示例#3
0
// remove old lines from the underlying source buffer
func (tb *tokBuf) ClearUpTo(tok common.Token) {
  tb.lx.ClearUpTo(tok.SourcePiece().Start());
}