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