当前位置: 首页>>代码示例>>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;未经允许,请勿转载。