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


Golang Lexer.Accept方法代碼示例

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


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

示例1: emitQuotedToken

// emitQuotedToken transmits the quoted-string value from <name>=<value>
func emitQuotedToken(l *lexrec.Lexer, t lexrec.ItemType) {
	if !l.Accept("=") {
		l.Errorf("emitQuotedToken: expected '=' after '%s', got %q'", itemName(t), l.Peek())
		return
	}

	l.Skip()

	if !lexrec.Quote(l, t, true) {
		l.Errorf("emitToken: expected a quoted string after '%s=', got %q", itemName(t), l.Peek())
	}
}
開發者ID:jimrobinson,項目名稱:httpclient,代碼行數:13,代碼來源:lexauth.go

示例2: emitToken

// emitToken emits the token value from <name>=<value>
func emitToken(l *lexrec.Lexer, t lexrec.ItemType) {
	if !l.Accept("=") {
		l.Errorf("emitToken expected '=' after '%s', got %q'", itemName(t), l.Peek())
		return
	}

	l.Skip()

	if !l.ExceptRun(nontoken) {
		l.Errorf("emitToken expected a token character, got %q", l.Peek())
		return
	}

	l.Emit(t)
}
開發者ID:jimrobinson,項目名稱:httpclient,代碼行數:16,代碼來源:lexauth.go

示例3: emitBoolToken

// emitBoolToken emits the token value from <name>=<value>, where the
// value is either "true" or "false" (case insensitive)
func emitBoolToken(l *lexrec.Lexer, t lexrec.ItemType) {
	if !l.Accept("=") {
		l.Errorf("emitBoolToken: expected '=' after '%s', got %q'", itemName(t), l.Peek())
		return
	}

	l.Skip()

	if !l.ExceptRun(nontoken) {
		l.Errorf("emitBoolToken: expected a token character, got %q", l.Peek())
		return
	}

	s := strings.ToLower(string(l.Bytes()))
	if s == "true" || s == "false" {
		l.Emit(t)
		return
	} else {
		l.Errorf("emitBoolToken: expected token to be 'true' or 'false', got %q", s)
	}
}
開發者ID:jimrobinson,項目名稱:httpclient,代碼行數:23,代碼來源:lexauth.go

示例4: ignoreToken

// ignoreToken skips past <name>=<value>, where the value may be a
// token or a quoted-string.
func ignoreToken(l *lexrec.Lexer) {

	p := string(l.Bytes())
	l.Skip()

	if !l.Accept("=") {
		l.Errorf("ignoreToken: after '%s' expected '=', got %q'", p, l.Peek())
		return
	} else {
		l.Skip()
	}

	if l.Peek() == '"' {
		if lexrec.Quote(l, ItemAuthParam, false) {
			l.Skip()
		}
	} else {
		if l.ExceptRun(nontoken) {
			l.Skip()
		} else {
			l.Errorf("ignoreToken: expected a token character, got %q", l.Peek())
		}
	}
}
開發者ID:jimrobinson,項目名稱:httpclient,代碼行數:26,代碼來源:lexauth.go

示例5: advanceChallenge

// advanceChallenge skips over an unrecognized WWW-Authenticate challenge.
func advanceChallenge(l *lexrec.Lexer) {
	if l.AcceptRun(whitespace) {
		l.Skip()
	}

	expectParam := true
	for expectParam {
		if l.ExceptRun(nontoken) {
			r := l.Peek()
			if r == '=' {
				l.Accept("=")
				l.Skip()
				if l.Peek() == '"' {
					if lexrec.Quote(l, ItemAuthParam, false) {
						l.Skip()
					}
				} else {
					if l.ExceptRun(nontoken) {
						l.Skip()
					} else {
						l.Errorf("advanceChallenge: expected a token character, got %q", l.Peek())
					}
				}
			} else if isSpace(r) {
				return
			} else {
				l.Errorf("advanceChallenge: expected either whitespace or '=', got %q", l.Peek())
				return
			}

			expectParam = advanceParam(l)
		} else {
			return
		}
	}
}
開發者ID:jimrobinson,項目名稱:httpclient,代碼行數:37,代碼來源:lexauth.go


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