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


Golang Lexer.Depth方法代碼示例

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


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

示例1: lexInside

func lexInside(l *lex.Lexer) lex.StateFn {
	for {
		switch r := l.Next(); {
		case r == rightCurl:
			l.Depth -= 1
			l.Emit(itemRightCurl)
			if l.Depth == 0 {
				return lexText
			}
		case r == leftCurl:
			l.Depth += 1
			l.Emit(itemLeftCurl)
		case r == lex.EOF:
			return l.Errorf("unclosed action")
		case isSpace(r) || isEndOfLine(r) || r == ',':
			l.Ignore()
		case isNameBegin(r):
			return lexName
		case r == '#':
			l.Backup()
			return lexComment
		case r == '(':
			l.Emit(itemLeftRound)
			return lexArgInside
		default:
			return l.Errorf("Unrecognized character in lexInside: %#U", r)
		}
	}
}
開發者ID:cayleydb,項目名稱:dgraph,代碼行數:29,代碼來源:state.go

示例2: lexInsideMutation

func lexInsideMutation(l *lex.Lexer) lex.StateFn {
	for {
		switch r := l.Next(); {
		case r == rightCurl:
			l.Depth -= 1
			l.Emit(itemRightCurl)
			if l.Depth == 0 {
				return lexText
			}
		case r == leftCurl:
			l.Depth += 1
			l.Emit(itemLeftCurl)
			if l.Depth >= 2 {
				return lexTextMutation
			}
		case r == lex.EOF:
			return l.Errorf("Unclosed mutation action")
		case isSpace(r) || isEndOfLine(r):
			l.Ignore()
		case isNameBegin(r):
			return lexNameMutation
		default:
			return l.Errorf("Unrecognized character in lexInsideMutation: %#U", r)
		}
	}
}
開發者ID:ashwin95r,項目名稱:dgraph,代碼行數:26,代碼來源:state.go

示例3: lexLabel

func lexLabel(l *lex.Lexer) lex.StateFn {
	r := l.Next()
	if r == '<' {
		l.Depth += 1
		return lexUntilClosing(l, itemLabel, lexText)
	}
	if r == '_' {
		l.Depth += 1
		return lexBlankNode(l, itemLabel, lexText)
	}
	return l.Errorf("Invalid char: %v at lexLabel", r)
}
開發者ID:cayleydb,項目名稱:dgraph,代碼行數:12,代碼來源:state.go

示例4: lexSubject

func lexSubject(l *lex.Lexer) lex.StateFn {
	r := l.Next()
	if r == '<' {
		l.Depth += 1
		return lexUntilClosing(l, itemSubject, lexText)
	}

	if r == '_' {
		l.Depth += 1
		return lexBlankNode(l, itemSubject, lexText)
	}

	return l.Errorf("Invalid character during lexSubject: %v", r)
}
開發者ID:cayleydb,項目名稱:dgraph,代碼行數:14,代碼來源:state.go

示例5: lexText

func lexText(l *lex.Lexer) lex.StateFn {
Loop:
	for {
		switch r := l.Next(); {
		case r == leftCurl:
			l.Backup()
			l.Emit(itemText) // emit whatever we have so far.
			l.Next()         // advance one to get back to where we saw leftCurl.
			l.Depth += 1     // one level down.
			l.Emit(itemLeftCurl)
			return lexInside // we're in.

		case r == rightCurl:
			return l.Errorf("Too many right characters")
		case r == lex.EOF:
			break Loop
		case isNameBegin(r):
			l.Backup()
			l.Emit(itemText)
			return lexOperationType
		}
	}
	if l.Pos > l.Start {
		l.Emit(itemText)
	}
	l.Emit(lex.ItemEOF)
	return nil
}
開發者ID:cayleydb,項目名稱:dgraph,代碼行數:28,代碼來源:state.go

示例6: lexLiteral

// Assumes '"' has already been encountered.
func lexLiteral(l *lex.Lexer) lex.StateFn {
	for {
		r := l.Next()
		if r == '\u005c' { // backslash
			r = l.Next()
			continue // This would skip over the escaped rune.
		}

		if r == lex.EOF || isEndLiteral(r) {
			break
		}
	}
	l.Backup()

	l.Emit(itemLiteral)
	l.Next()   // Move to end literal.
	l.Ignore() // Ignore end literal.
	l.Depth += 1

	r := l.Peek()
	if r == '@' {
		return lexLanguage(l)

	} else if r == '^' {
		return lexObjectType(l)

	} else {
		return lexText
	}
}
開發者ID:cayleydb,項目名稱:dgraph,代碼行數:31,代碼來源:state.go

示例7: lexObject

func lexObject(l *lex.Lexer) lex.StateFn {
	r := l.Next()
	if r == '<' {
		l.Depth += 1
		return lexUntilClosing(l, itemObject, lexText)
	}
	if r == '_' {
		l.Depth += 1
		return lexBlankNode(l, itemObject, lexText)
	}
	if r == '"' {
		l.Ignore()
		return lexLiteral(l)
	}

	return l.Errorf("Invalid char: %v at lexObject", r)
}
開發者ID:cayleydb,項目名稱:dgraph,代碼行數:17,代碼來源:state.go

示例8: lexPredicate

func lexPredicate(l *lex.Lexer) lex.StateFn {
	r := l.Next()
	if r != '<' {
		return l.Errorf("Invalid character in lexPredicate: %v", r)
	}
	l.Depth += 1
	return lexUntilClosing(l, itemPredicate, lexText)
}
開發者ID:cayleydb,項目名稱:dgraph,代碼行數:8,代碼來源:state.go


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