Documentation
¶
Index ¶
- Constants
- Variables
- func IsComma(t Typ) bool
- func IsLogicalOperator(t Typ) bool
- type Lookup
- type Token
- type Tokens
- type Typ
- func (t Typ) IsAddOrSubtract() bool
- func (t Typ) IsBoolean() bool
- func (t Typ) IsBreakable() bool
- func (t Typ) IsEOF() bool
- func (t Typ) IsErr() bool
- func (t Typ) IsGTorGTE() bool
- func (t Typ) IsGreaterOrLessThan() bool
- func (t Typ) IsLTorLTE() bool
- func (t Typ) IsMathOperator() bool
- func (t Typ) IsOrEquals() bool
- func (t Typ) IsSpaceChar() bool
- func (t Typ) String() string
- type TypLookup
- type TypeCheckFunc
Constants ¶
const ( TokenValPlus = "+" TokenValMinus = "-" TokenValStar = "*" TokenValSlash = "/" TokenValPercent = "%" TokenValComma = "," TokenValTrue = "true" TokenValFalse = "false" )
Common Tokens
Variables ¶
var ErrInvalidToken = errors.New("invalid token")
ErrInvalidToken indicates a general invalid token (e.g., nil reference)
var ErrParsingInt = errors.New("error parsing input for integer")
ErrParsingInt indicates a general integer parsing error
Functions ¶
func IsLogicalOperator ¶
IsLogicalOperator returns true if the subject Typ falls in the Logical Operator range
Types ¶
type Token ¶
type Token struct {
Typ Typ // The type of this Token.
Pos int // The starting position, in bytes, of this Token in the input string.
Val string // The value of this Token.
}
Token represents a token or text string returned from the scanner.
type Tokens ¶
type Tokens []*Token
Tokens represents a slice of Tokens
type Typ ¶
type Typ uint
Typ identifies the type of lex items.
const ( Error Typ = iota // error occurred; value is text of error EOF // end of the input was reached and there are no more tokens coming Char // printable ASCII character; grab bag for comma etc. Equals // equals ('=') introducing an assignment Bool // boolean constant Complex // complex constant (1+2i); imaginary is just a number Identifier // unquoted, non-keyword alphanumeric identifier not starting with '.' LeftParen // '(' Number // simple number, including imaginary RightParen // ')' Space // run of spaces separating arguments String // quoted string (includes quotes) LessThan // < GreaterThan // > LessThanOrEqual // <= GreaterThanOrEqual // >= InequalityOperator // !, NOT, depending upon the applied language specification NotEqualOperator // != Comma // ',' // // TokenTypeLogicalOps is the value after where Logical Operators start TokenTypeLogicalOps Typ = iota + 32 // this value boundary should not be used for an item.Typ LogicalAnd // AND, &&, etc., depending upon the applied language specification LogicalOr // OR, ||, etc., depending upon the applied language specification TokenTypeLogicalOpsEnd // this value boundary should not be used for an item.Typ // // TypeMathOps is the value after where Mathemathical Operators start TokenTypeMathOps Typ = iota + 48 // this value boundary is should not be used for an item.Typ Plus Minus Multiply Divide Modulo TokenTypeMathOpsEnd // this value boundary should not be used for an item.Typ // // CustomNonKeyword is the value after which custom implementations start custom item types CustomNonKeyword Typ = 1024 // // CustomNonKeyword is the value after where custom non-Keywords end CustomNonKeywordEnd Typ = 65535 // CustomKeyword defines the value after where custom Keywords item types start // We pad to 65K, so that any custom expansions can use the Type value space as regular item or keywords CustomKeyword Typ = 65536 // used only to delimit Keywords )
Types
func (Typ) IsAddOrSubtract ¶
IsAddOrSubtract returns true if the subject Typ is Plus or Minus
func (Typ) IsBoolean ¶
IsBoolean returns true if the subject Typ falls in the Boolean Operator range
func (Typ) IsBreakable ¶
IsBreakable returns true if the Typ is EOF or Error
func (Typ) IsGreaterOrLessThan ¶
IsGreaterOrLessThan returns true if the Typ is >, >=, <, or <=
func (Typ) IsMathOperator ¶
IsMathOperator returns true if the subject Typ falls in the Math Operator range
func (Typ) IsOrEquals ¶
IsOrEquals returns true if the Typ is <= or >=
func (Typ) IsSpaceChar ¶
IsSpaceChar returns true if the Typ is a Space, Tab, CR or LF
type TypeCheckFunc ¶
TypeCheckFunc represents a function that returns true or false based on the Typ