本文整理匯總了Golang中github.com/dgraph-io/dgraph/lex.Lexer.Errorf方法的典型用法代碼示例。如果您正苦於以下問題:Golang Lexer.Errorf方法的具體用法?Golang Lexer.Errorf怎麽用?Golang Lexer.Errorf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/dgraph-io/dgraph/lex.Lexer
的用法示例。
在下文中一共展示了Lexer.Errorf方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: lexObject
func lexObject(l *lex.Lexer) lex.StateFn {
for {
switch r := l.Next(); {
case r == rightCurl:
return lexText
case isSpace(r) || isEndOfLine(r):
l.Ignore()
case isNameBegin(r):
{
for {
r := l.Next()
if isNameSuffix(r) {
continue // absorb
}
l.Backup()
l.Emit(itemObject)
break
}
return lexObjectBlock
}
default:
return l.Errorf("Invalid schema. Unexpected %s", l.Input[l.Start:l.Pos])
}
}
}
示例2: 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)
}
}
}
示例3: lexInsideMutation
// lexInsideMutation lexes the text inside a mutation block.
func lexInsideMutation(l *lex.Lexer) lex.StateFn {
for {
switch r := l.Next(); {
case r == rightCurl:
l.Depth--
l.Emit(itemRightCurl)
if l.Depth == 0 {
return lexText
}
case r == leftCurl:
l.Depth++
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)
}
}
}
示例4: lexDirective
// lexDirective is called right after we see a @.
func lexDirective(l *lex.Lexer) lex.StateFn {
r := l.Next()
if !isNameBegin(r) {
return l.Errorf("Unrecognized character in lexDirective: %#U", r)
}
l.Backup()
// This gives our buffer an initial capacity. Its length is zero though. The
// buffer can grow beyond this initial capacity.
buf := bytes.NewBuffer(make([]byte, 0, 15))
for {
// The caller already checked isNameBegin, and absorbed one rune.
r = l.Next()
buf.WriteRune(r)
if isNameSuffix(r) {
continue
}
l.Backup()
l.Emit(itemDirectiveName)
directive := buf.Bytes()[:buf.Len()-1]
// The lexer may behave differently for different directives. Hence, we need
// to check the directive here and go into the right state.
if string(directive) == "filter" {
return lexFilterInside
}
return l.Errorf("Unhandled directive %s", directive)
}
return lexInside
}
示例5: lexTextMutation
// lexTextMutation lexes and absorbs the text inside a mutation operation block.
func lexTextMutation(l *lex.Lexer) lex.StateFn {
for {
r := l.Next()
if r == lex.EOF {
return l.Errorf("Unclosed mutation text")
}
if r == quote {
return lexMutationValue
}
if r == leftCurl {
l.Depth++
}
if r == rightCurl {
if l.Depth > 2 {
l.Depth--
continue
}
}
if r != rightCurl {
// Absorb everything until we find '}'.
continue
}
l.Backup()
l.Emit(itemMutationContent)
break
}
return lexInsideMutation
}
示例6: lexOperationType
// lexOperationType lexes a query or mutation operation type.
func lexOperationType(l *lex.Lexer) lex.StateFn {
for {
r := l.Next()
if isNameSuffix(r) {
continue // absorb
}
l.Backup()
// l.Pos would be index of the end of operation type + 1.
word := l.Input[l.Start:l.Pos]
if word == "mutation" {
l.Emit(itemOpType)
l.Mode = mutationMode
} else if word == "fragment" {
l.Emit(itemOpType)
l.Mode = fragmentMode
} else if word == "query" {
l.Emit(itemOpType)
l.Mode = queryMode
} else {
if l.Mode == 0 {
l.Errorf("Invalid operation type")
}
}
break
}
return lexText
}
示例7: lexVarInside
func lexVarInside(l *lex.Lexer) lex.StateFn {
for {
switch r := l.Next(); {
case r == lex.EOF:
return l.Errorf("unclosed argument")
case isSpace(r) || isEndOfLine(r):
l.Ignore()
case isDollar(r):
return lexVarName
case r == ':':
l.Ignore()
return lexVarType
case r == equal:
l.Emit(itemEqual)
l.Ignore()
return lexVarDefault
case r == rightRound:
l.Emit(itemRightRound)
return lexText
case r == comma:
l.Emit(itemComma)
l.Ignore()
default:
return l.Errorf("variable list invalid")
}
}
}
示例8: 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
}
示例9: 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)
}
示例10: lexPredicate
func lexPredicate(l *lex.Lexer) lex.StateFn {
r := l.Next()
// The predicate can only be an IRI according to the spec.
if r != '<' {
return l.Errorf("Invalid character in lexPredicate: %v", r)
}
l.Depth++
return lexUntilClosing(l, itemPredicate, lexText)
}
示例11: 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)
}
示例12: lexLanguage
func lexLanguage(l *lex.Lexer) lex.StateFn {
r := l.Next()
if r != '@' {
return l.Errorf("Expected @ prefix for lexLanguage")
}
l.Ignore()
r = l.Next()
if !isLangTagPrefix(r) {
return l.Errorf("Invalid language tag prefix: %v", r)
}
l.AcceptRun(isLangTag)
l.Emit(itemLanguage)
return lexText
}
示例13: 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)
}
示例14: 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)
}
示例15: lexScalarBlock
func lexScalarBlock(l *lex.Lexer) lex.StateFn {
for {
switch r := l.Next(); {
case r == ')':
l.Emit(itemRightRound)
return lexText
case isNameBegin(r):
l.Backup()
return lexScalarPair1
case isSpace(r) || isEndOfLine(r):
l.Ignore()
default:
return l.Errorf("Invalid schema. Unexpected %s", l.Input[l.Start:l.Pos])
}
}
}