semantic

package
v0.3.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 17

Documentation

Overview

Package semantic contains semantic checking for AST parsed from a IDL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deref added in v0.1.2

func Deref(ast *parser.Thrift, t *parser.Type) (*parser.Thrift, *parser.Type, error)

Deref returns the target type that t refers to and the AST it belongs to. Typedef will be dereferenced.

func IDLPrefix added in v0.1.2

func IDLPrefix(filename string) string

IDLPrefix returns the file name without extension.

func ResolveSymbols added in v0.1.2

func ResolveSymbols(ast *parser.Thrift) error

ResolveSymbols checks the existence of each symbol in the current AST and build a name-to-category mapping for all locally-defined symbols. If a type, a value or a service refers to another one from an external IDL, the index of that IDL in the include list will be recorded. ResolveSymbols stops when it encounters any error.

func SplitType added in v0.1.2

func SplitType(id string) []string

SplitType tries to split the given ID into two part: the name of an included IDL without file extension and the type name in that IDL. If ID is a type name containing no dot, then the it is returned unchanged.

func SplitValue added in v0.1.2

func SplitValue(id string) (sss [][]string)

SplitValue tries to find any possible resolution of the given ID assuming it is a name of a constant value or an enum value. When ID contains no dot, it is returned unchanged. Otherwise, this function tries to explain it as 'IDL.Value' or as 'IDL.EnumType.Value' and to return all possible divisions.

Types

type Checker

type Checker interface {
	CheckAll(t *parser.Thrift) (warns []string, err error)
}

Checker reports whether there are semantic errors in the AST and produces warning messages for non-fatal errors.

func NewChecker

func NewChecker(opt Options) Checker

NewChecker creates a checker.

type Options

type Options struct {
	FixWarnings bool
}

Options controls the behavior of the default checker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL