Documentation ¶
Overview ¶
Copyright © 2020 aggronmagi <czy463@163.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 aggronmagi <czy463@163.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2023 aggronmagi <czy463@163.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 aggronmagi <czy463@163.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func NewError(tok *token.Token, format string, args ...interface{}) error
- func NewError2(tok *token.Token, err error) error
- func NewErrorPos(pos token.Pos, format string, args ...interface{}) error
- func NewErrorPos2(pos token.Pos, err error) error
- type Context
- type MethodFlag
- type RecursionAnalyseFunc
- type RecursionAnalyser
- type YTBaseType
- type YTCustomType
- type YTDoc
- type YTEnumDef
- type YTEnumValue
- type YTField
- type YTFieldType
- type YTImport
- type YTListType
- type YTMapTypee
- type YTMessage
- type YTMethod
- type YTMethodNo
- type YTOption
- type YTOptionValue
- type YTOptions
- type YTPackage
- type YTProgram
- type YTProject
- type YTService
Constants ¶
const (
// ProtobufOptionSyntax syntax = "proto2" 选项
ProtobufOptionSyntax = "proto.syntax"
)
protobuf 消息解析设置选项
Variables ¶
var Flag = &astFlag{}
Flag ast包导出标记
Functions ¶
Types ¶
type RecursionAnalyseFunc ¶
RecursionAnalyseFunc 递归解析函数
type RecursionAnalyser ¶
RecursionAnalyser 递归分析接口
var RegisterRecursionAnalyser RecursionAnalyser = nil
本地全局.递归解析函数
type YTBaseType ¶
type YTBaseType int
YTBaseType 基本类型
var ( // BaseTypeInt8 Int8 BaseTypeInt8 *YTBaseType // BaseTypeUint8 Uint8 BaseTypeUint8 *YTBaseType // BaseTypeInt16 Int16 BaseTypeInt16 *YTBaseType // BaseTypeUint16 Uint16 BaseTypeUint16 *YTBaseType // BaseTypeInt32 Int32 BaseTypeInt32 *YTBaseType // BaseTypeUint32 Uint32 BaseTypeUint32 *YTBaseType // BaseTypeInt64 Int64 BaseTypeInt64 *YTBaseType // BaseTypeUint64 Uint64 BaseTypeUint64 *YTBaseType // BaseTypeString String BaseTypeString *YTBaseType // BaseTypeBinary Binary BaseTypeBinary *YTBaseType // BaseTypeBool Bool BaseTypeBool *YTBaseType // BaseTypeFloat32 float32 float BaseTypeFloat32 *YTBaseType // BaseTypeFloat64 float64 double BaseTypeFloat64 *YTBaseType )
func (*YTBaseType) String ¶
func (typ *YTBaseType) String() string
type YTEnumDef ¶
type YTEnumDef struct { *YTDoc YTOptions DefPos token.Pos Name string Values []*YTEnumValue // contains filtered or unexported fields }
YTEnumDef 枚举定义
type YTEnumValue ¶
YTEnumValue 枚举值
type YTFieldType ¶
type YTFieldType struct { *YTBaseType *YTListType *YTMapTypee *YTCustomType }
YTFieldType 字段类型
type YTMessage ¶
type YTMessage struct { *YTDoc DefPos token.Pos YTOptions Name string Fields []*YTField ProtobufFlag bool SubMsgs []*YTMessage // contains filtered or unexported fields }
YTMessage 消息定义
type YTMethod ¶
type YTMethod struct { *YTDoc YTOptions DefPos token.Pos Flag MethodFlag Name string Request *YTMessage Reply *YTMessage No *YTMethodNo }
YTMethod 函数,方法定义
func ProtoNewMethod ¶
ProtoNewMethod 新建方法 "rpc" tok_identifier "(" tok_identifier ")" "returns" "(" tok_identifier ")" "{" "}"
type YTMethodNo ¶
type YTMethodNo struct { DefPos token.Pos Macro *YTCustomType Value *int64 }
YTMethodNo 方法ID
type YTOption ¶
type YTOption struct { *YTDoc DefPos token.Pos Key string Value *YTOptionValue }
YTOption 定义选项节点
func ProtoNewOption ¶
ProtoNewOption 新建选项 Option: "option" tok_identifier tok_literal ";"
func ProtoNewSyntax ¶
////////////////////////////////////////////////////////// NOTE: protobuf 支持 NewSyntax protobuf 支持. 语法 Syntax: "syntax" "=" tok_identifier ";"
type YTOptionValue ¶
YTOptionValue 选项值
func (*YTOptionValue) String ¶
func (val *YTOptionValue) String() (desc string)
type YTOptions ¶
type YTOptions struct { Opts []*YTOption // contains filtered or unexported fields }
YTOptions 选项
func (*YTOptions) GetOptionString ¶
GetOptionString 获取选项值
func (*YTOptions) GetOptionValue ¶
func (opts *YTOptions) GetOptionValue(key string) *YTOptionValue
GetOptionValue 获取选项值
type YTProgram ¶
type YTProgram struct { YTOptions // 包 选项 Pkg *YTPackage // 包定义 Imports []*YTImport // 导入文件 EnumDefs []*YTEnumDef // 枚举定义 Messages []*YTMessage // 消息定义 Services []*YTService // 服务定义 Projects []*YTProject // 项目定义 // File 文件名 - 只有整个文件解析成功才会赋值 File string // contains filtered or unexported fields }
YTProgram 文件语法树
func (*YTProgram) AnalyseProgram ¶
AnalyseProgram 分析检测Program合理性
func (*YTProgram) ApplyCmdOptions ¶
ApplyCmdOptions 应用命令行参数添加的全局选项 全局Options. 格式为 "xx.xxx=66" "xx.x1" "xx.xx2=xxx"
func (*YTProgram) GetFileDesc ¶
GetFileDesc 获取文件描述
func (*YTProgram) GetFileDescWithImports ¶
GetFileDescWithImports 获取文件描述(包含依赖)