本文整理匯總了Golang中github.com/couchbaselabs/tuqtng/ast.Expression.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang Expression.String方法的具體用法?Golang Expression.String怎麽用?Golang Expression.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbaselabs/tuqtng/ast.Expression
的用法示例。
在下文中一共展示了Expression.String方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Visit
// inorder traversal of the AST to get JS expression out of it
func (this *JsStatement) Visit(e ast.Expression) (ast.Expression, error) {
switch expr := e.(type) {
case *ast.DotMemberOperator:
if this.js.Len() == 0 {
this.js.WriteString("doc.")
}
_, err := expr.Left.Accept(this)
if err != nil {
return nil, err
}
this.js.WriteString(".")
_, err = expr.Right.Accept(this)
if err != nil {
return nil, err
}
case *ast.BracketMemberOperator:
if this.js.Len() == 0 {
this.js.WriteString("doc.")
}
_, err := expr.Left.Accept(this)
if err != nil {
return nil, err
}
this.js.WriteString("[")
_, err = expr.Right.Accept(this)
if err != nil {
return nil, err
}
this.js.WriteString("]")
case *ast.Property:
if this.js.Len() == 0 {
this.js.WriteString("doc.")
}
this.js.WriteString(expr.Path)
case *ast.LiteralNumber:
this.js.WriteString(fmt.Sprintf("%v", expr.Val))
case *ast.LiteralString:
this.js.WriteString(expr.Val)
default:
return e, errors.New("Expression is not supported by indexing currently: " + e.String())
}
return e, nil
}