meter

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Global
	KeyDebug    = "DEBUG"
	KeyConfig   = "CONFIG"
	KeySchedule = "SCHEDULE"
	KeyTPath    = "TPATH"
	KeyCWD      = "CWD"

	// Local
	KeyTest     = "TEST"
	KeyRoutine  = "ROUTINE"
	KeySequence = "SEQUENCE"
	KeyURL      = "URL"
	KeyRequest  = "REQUEST"
	KeyStatus   = "STATUS"
	KeyResponse = "RESPONSE"
	KeyInput    = "INPUT"
	KeyOutput   = "OUTPUT"
	KeyError    = "ERROR"

	KeyFailure = "FAILURE"
	EOF        = "EOF"
)
View Source
const (
	LowestPrec  = 0 // non-operators
	UnaryPrec   = 6
	HighestPrec = 7
)

A set of constants for precedence-based expression parsing. Non-operators have lowest precedence, followed by operators starting with precedence 1 up to unary operators. The highest precedence serves as "catch-all" precedence for selector, indexing, and other operator and delimiter tokens.

View Source
const AND_OP = 57352
View Source
const ASSIGN_OP = 57354
View Source
const CMD_EXEC = 57358
View Source
const COMP_OP = 57349
View Source
const EQUAL_OP = 57350
View Source
const IDENTITY = 57346
View Source
const LITERAL = 57347
View Source
const LOGIC_OP = 57351
View Source
const OR_OP = 57353
View Source
const UNARY_ARITH_OP = 57348
View Source
const V_ARGUMENT = 57359
View Source
const V_GLOBAL = 57356
View Source
const V_JSON = 57357
View Source
const V_LOCAL = 57355

Variables

View Source
var (
	EofError = io.EOF
)

Functions

func AddGlobalVariable added in v0.0.12

func AddGlobalVariable(k, v string)

func Execute added in v0.1.1

func Execute(opt *config.GOptions) error

func GetGlobalVariable added in v0.0.12

func GetGlobalVariable(k string) string

func IsExported added in v0.1.0

func IsExported(name string) bool

IsExported reports whether name starts with an upper-case letter.

func IsIdentifier added in v0.1.0

func IsIdentifier(name string) bool

IsIdentifier reports whether name is a Go identifier, that is, a non-empty string made up of letters, digits, and underscores, where the first character is not a digit. Keywords are not identifiers.

func IsKeyword added in v0.1.0

func IsKeyword(name string) bool

IsKeyword reports whether name is a Go keyword, such as "func" or "return".

func Start

func Start(path string) error

Start a test, path is the configure json file path, which must be able to be unmarshal to config.Config

func StartConfig added in v0.0.6

func StartConfig(cfg *config.Config) error

func StartHTTPServer added in v0.0.7

func StartHTTPServer(path string) error

Start a test, path is the configure json file path, which must be able to be unmarshal to config.Config

func StartHTTPServerConfig added in v0.0.7

func StartHTTPServerConfig(c *config.HttpServers) error

func StopAll added in v0.0.7

func StopAll()

Types

type ErrorHandler added in v0.1.0

type ErrorHandler func(pos int, msg string)

An ErrorHandler may be provided to Scanner.Init. If a syntax error is encountered and a handler was installed, the handler is called with a position and an error message. The position points to the beginning of the offending token.

type JsonCmp added in v0.1.7

type JsonCmp struct {
	// contains filtered or unexported fields
}

func MakeJsonComparator added in v0.1.7

func MakeJsonComparator(message json.RawMessage) (*JsonCmp, error)

func (*JsonCmp) Compare added in v0.1.7

func (j *JsonCmp) Compare(message json.RawMessage) error

func (*JsonCmp) Get added in v0.1.7

func (j *JsonCmp) Get(key string) string

func (*JsonCmp) Reset added in v0.1.8

func (j *JsonCmp) Reset()

func (*JsonCmp) Set added in v0.1.7

func (j *JsonCmp) Set(key, value string)

type Scanner added in v0.1.0

type Scanner struct {

	// public state - ok to modify
	ErrorCount int // number of errors encountered
	// contains filtered or unexported fields
}

A Scanner holds the scanner's internal state while processing a given text. It can be allocated as part of another data structure but must be initialized via Init before use.

func (*Scanner) Error added in v0.1.0

func (s *Scanner) Error(str string)

func (*Scanner) Init added in v0.1.0

func (s *Scanner) Init(src []byte, err ErrorHandler)

Init prepares the scanner s to tokenize the text src by setting the scanner at the beginning of src. The scanner uses the file set file for position information and it adds line information for each line. It is ok to re-use the same file when re-scanning the same file as line information which is already present is ignored. Init causes a panic if the file size does not match the src size.

Calls to Scan will invoke the error handler err if they encounter a syntax error and err is not nil. Also, for each error encountered, the Scanner field ErrorCount is incremented by one. The mode parameter determines how comments are handled.

Note that Init may call err if there is an error in the first character of the file.

func (*Scanner) Lex added in v0.1.0

func (s *Scanner) Lex(lval *yySymType) int

func (*Scanner) Scan added in v0.1.0

func (s *Scanner) Scan() (pos int, tok Token, lit string)

Scan scans the next token and returns the token position, the token, and its literal string if applicable. The source end is indicated by EOF.

If the returned token is a literal (IDENT, INT, FLOAT, IMAG, CHAR, STRING) or COMMENT, the literal string has the corresponding value.

If the returned token is a keyword, the literal string is the keyword.

If the returned token is SEMICOLON, the corresponding literal string is ";" if the semicolon was present in the source, and "\n" if the semicolon was inserted because of a newline or at EOF.

If the returned token is ILLEGAL, the literal string is the offending character.

In all other cases, Scan returns an empty literal string.

For more tolerant parsing, Scan will return a valid token if possible even if a syntax error was encountered. Thus, even if the resulting token sequence contains no illegal tokens, a client may not assume that no error occurred. Instead it must check the scanner's ErrorCount or the number of calls of the error handler, if there was one installed.

Scan adds line information to the file added to the file set with Init. Token positions are relative to that file and thus relative to the file set.

type Token added in v0.1.0

type Token int

Token is the set of lexical tokens

const (
	ILLEGAL Token = iota
	Eof

	// Identifiers and basic type literals
	// (these tokens stand for classes of literals)
	IDENT  // main
	INT    // 12345
	FLOAT  // 123.45
	STRING // 'abc'

	// Operators and delimiters
	ADD // +
	SUB // -
	MUL // *
	QUO // /
	REM // %

	LAND // &&
	LOR  // ||

	INC // ++
	DEC // --

	EQL    // ==
	LSS    // <
	GTR    // >
	ASSIGN // =
	NOT    // !

	NEQ // !=
	LEQ // <=
	GEQ // >=

	ADD_ASSIGN // +=
	SUB_ASSIGN // -=
	MUL_ASSIGN // *=
	QUO_ASSIGN // /=
	REM_ASSIGN // %=

	LPAREN // (

	RPAREN // )

	SEMICOLON // ;

	COMMAND    // $(@xxx)
	LOCAL_VAR  // $(xxx)
	GLOBAL_VAR // ${xxx}
	JSON_VAR   // $<xxx>
	ARGUMENT   // $1, $2, ...

)

func Lookup added in v0.1.0

func Lookup(ident string) Token

Lookup maps an identifier to its keyword token or IDENT (if not a keyword).

func (Token) IsLiteral added in v0.1.0

func (tok Token) IsLiteral() bool

IsLiteral returns true for tokens corresponding to identifiers and basic type literals; it returns false otherwise.

func (Token) IsOperator added in v0.1.0

func (tok Token) IsOperator() bool

IsOperator returns true for tokens corresponding to operators and delimiters; it returns false otherwise.

func (Token) Precedence added in v0.1.0

func (op Token) Precedence() int

Precedence returns the operator precedence of the binary operator op. If op is not a binary operator, the result is LowestPrecedence.

func (Token) String added in v0.1.0

func (tok Token) String() string

String returns the string corresponding to the token tok. For operators, delimiters, and keywords the string is the actual token character sequence (e.g., for the token ADD, the string is "+"). For all other tokens the string corresponds to the token constant name (e.g. for the token IDENT, the string is "IDENT").

Jump to

Keyboard shortcuts

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