Documentation ¶
Index ¶
- Constants
- Variables
- func AddGlobalVariable(k, v string)
- func Execute(opt *config.GOptions) error
- func GetGlobalVariable(k string) string
- func IsExported(name string) bool
- func IsIdentifier(name string) bool
- func IsKeyword(name string) bool
- func Start(path string) error
- func StartConfig(cfg *config.Config) error
- func StartHTTPServer(path string) error
- func StartHTTPServerConfig(c *config.HttpServers) error
- func StopAll()
- type ErrorHandler
- type JsonCmp
- type Scanner
- type Token
Constants ¶
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" )
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.
const AND_OP = 57352
const ASSIGN_OP = 57354
const CMD_EXEC = 57358
const COMP_OP = 57349
const EQUAL_OP = 57350
const IDENTITY = 57346
const LITERAL = 57347
const LOGIC_OP = 57351
const OR_OP = 57353
const UNARY_ARITH_OP = 57348
const V_ARGUMENT = 57359
const V_GLOBAL = 57356
const V_JSON = 57357
const V_LOCAL = 57355
Variables ¶
var (
EofError = io.EOF
)
Functions ¶
func AddGlobalVariable ¶ added in v0.0.12
func AddGlobalVariable(k, v string)
func GetGlobalVariable ¶ added in v0.0.12
func IsExported ¶ added in v0.1.0
IsExported reports whether name starts with an upper-case letter.
func IsIdentifier ¶ added in v0.1.0
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
IsKeyword reports whether name is a Go keyword, such as "func" or "return".
func Start ¶
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 StartHTTPServer ¶ added in v0.0.7
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
Types ¶
type ErrorHandler ¶ added in v0.1.0
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)
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) 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) Scan ¶ added in v0.1.0
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
Lookup maps an identifier to its keyword token or IDENT (if not a keyword).
func (Token) IsLiteral ¶ added in v0.1.0
IsLiteral returns true for tokens corresponding to identifiers and basic type literals; it returns false otherwise.
func (Token) IsOperator ¶ added in v0.1.0
IsOperator returns true for tokens corresponding to operators and delimiters; it returns false otherwise.
func (Token) Precedence ¶ added in v0.1.0
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
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").