當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Lexer.AcceptUntil方法代碼示例

本文整理匯總了Golang中github.com/dgraph-io/dgraph/lex.Lexer.AcceptUntil方法的典型用法代碼示例。如果您正苦於以下問題:Golang Lexer.AcceptUntil方法的具體用法?Golang Lexer.AcceptUntil怎麽用?Golang Lexer.AcceptUntil使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/dgraph-io/dgraph/lex.Lexer的用法示例。


在下文中一共展示了Lexer.AcceptUntil方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: lexUntilClosing

func lexUntilClosing(l *lex.Lexer, styp lex.ItemType,
	sfn lex.StateFn) lex.StateFn {

	l.AcceptUntil(isClosingBracket)
	r := l.Next()
	if r == lex.EOF {
		return l.Errorf("Unexpected end of subject")
	}
	if r == '>' {
		l.Emit(styp)
		return sfn
	}
	return l.Errorf("Invalid character %v found for itemType: %v", r, styp)
}
開發者ID:cayleydb,項目名稱:dgraph,代碼行數:14,代碼來源:state.go

示例2: lexBlankNode

// Assumes that the current rune is '_'.
func lexBlankNode(l *lex.Lexer, styp lex.ItemType,
	sfn lex.StateFn) lex.StateFn {

	// RDF Blank Node.
	// TODO: At some point do checkings based on the guidelines. For now,
	// just accept everything until space.
	l.AcceptUntil(isSpace)
	r := l.Peek()
	if r == lex.EOF {
		return l.Errorf("Unexpected end of subject")
	}

	if isSpace(r) {
		l.Emit(styp)
		return sfn
	}

	return l.Errorf("Invalid character %v found for itemType: %v", r, styp)
}
開發者ID:dgraph-io,項目名稱:dgraph,代碼行數:20,代碼來源:state.go

示例3: lexFilterFuncInside

// lexFilterFuncInside expects input to look like ("...", "...").
func lexFilterFuncInside(l *lex.Lexer) lex.StateFn {
	l.AcceptRun(isSpace)
	l.Ignore() // Any spaces encountered.

	for {
		r := l.Next()
		if isSpace(r) || r == ',' {
			l.Ignore()
		} else if r == leftRound {
			l.Emit(itemLeftRound)
		} else if r == rightRound {
			l.Emit(itemRightRound)
			return lexFilterInside
		} else if isEndLiteral(r) {
			l.Ignore()
			l.AcceptUntil(isEndLiteral) // This call will backup the ending ".
			l.Emit(itemFilterFuncArg)
			l.Next() // Consume " and ignore it.
			l.Ignore()
		} else {
			return l.Errorf("Expected quotation mark in lexFilterFuncArgs")
		}
	}
}
開發者ID:dgraph-io,項目名稱:dgraph,代碼行數:25,代碼來源:state.go

示例4: lexUidNode

func lexUidNode(l *lex.Lexer, styp lex.ItemType, sfn lex.StateFn) lex.StateFn {
	l.AcceptUntil(isSpace)
	r := l.Peek()
	if r == lex.EOF {
		return l.Errorf("Unexpected end of uid subject")
	}

	in := l.Input[l.Start:l.Pos]
	if !strings.HasPrefix(in, "_uid_:") {
		return l.Errorf("Expected _uid_: Found: %v", l.Input[l.Start:l.Pos])
	}

	if _, err := strconv.ParseUint(in[6:], 0, 64); err != nil {
		return l.Errorf("Unable to convert '%v' to UID", in[6:])
	}

	if isSpace(r) {
		l.Emit(styp)
		return sfn
	}

	return l.Errorf("Invalid character %v found for UID node itemType: %v", r,
		styp)
}
開發者ID:dgraph-io,項目名稱:dgraph,代碼行數:24,代碼來源:state.go


注:本文中的github.com/dgraph-io/dgraph/lex.Lexer.AcceptUntil方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。