Documentation
¶
Index ¶
- Constants
- type Token
- func (tok Token) Is(other ...Token) bool
- func (tok Token) IsBinaryOperator() bool
- func (tok Token) IsBlockEnd() bool
- func (tok Token) IsBlockStart() bool
- func (tok Token) IsKeyword() bool
- func (tok Token) IsLiteral() bool
- func (tok Token) IsOperator() bool
- func (tok Token) IsUserBinaryOperator() bool
- func (tok Token) Name() string
- func (tok Token) Precedence() int
- func (tok Token) String() string
- func (tok Token) Valid() bool
Constants ¶
View Source
const LowestPrec = 0
LowestPrec represents lowest operator precedence.
View Source
const NumTokens = int(DoubleColon) + 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Token ¶
type Token int
Token represents a token.
const ( Illegal Token = iota EOF Comment ConfigStart ConfigEnd MixedValueStart MixedValueEnd MixedCodeStart MixedCodeEnd MixedText GroupLiteralBegin Ident Int Uint Float Decimal Char String RawString RawHeredoc Heredoc CodeStr Template Symbol Regex GroupLiteralEnd GroupOperatorBegin GroupBinaryOperatorBegin Add // + Sub // - Mul // * Pow // ** Quo // / Rem // % And // & Or // | Xor // ^ Shl // << Shr // >> AndNot // &^ LAnd // && Equal // == NotEqual // != Less // < Greater // > LessEq // <= GreaterEq // >= Tilde // ~ DoubleTilde // ~~ TripleTilde // ~~~ DotDot // .. TripleLess // <<< TripleGreater // >>> DoubleMod // %% Lambda // => Same // === NotSame // !== GroupBinaryOperatorEnd GroupDefaultOperatorBegin Nullich // ?? Absent // !? LOr // || GroupDefaultOperatorEnd GroupAssignOperatorBegin Define // := Assign // = GroupSelfAssignOperatorBegin AddAssign // += IncAssign // ++= SubAssign // -= DecAssign // --= MulAssign // *= PowAssign // **= QuoAssign // /= RemAssign // %= AndAssign // &= OrAssign // |= XorAssign // ^= ShlAssign // <<= ShrAssign // >>= TripleLessAssign // <<<= TripleGreaterAssign // >>>= DoubleModAssign // %%= AndNotAssign // &^= LOrAssign // ||= NullichAssign // ??= AbsentAssign // !?= GroupSelfAssignOperatorEnd GroupAssignOperatorEnd GroupUnaryOperatorBegin Inc // ++ Dec // -- GroupUnaryOperatorEnd Not // ! Null // a == nil || nil == a NotNull // a != nil || nil != a Pipe // .| Question // ? NullishSelector // ?. GroupOperatorEnd LParen // ( RParen // ) LBrack // [ RBrack // ] LBrace // { RBrace // } Semicolon // ; Colon // : Comma // , Period // . GroupKeywordBegin Break Continue Else For Func Method If Return True False Yes No In Nil Import Embed Param Global Var Const Try Catch Finally Throw StdIn StdOut StdErr Callee NamedArgs Args DotName DotFile IsMain Module Globals Export Raw Match Defer DeferOk DeferErr Deferb DeferbOk DeferbErr Prop Meti // Ain is the "array membership" operator `A ain B`: every value of A is a // member of B. Appended at the end of the keyword group so existing token // values are not shifted. Ain // With is the `with` context-manager statement/expression keyword. With // Class introduces a class expression/statement (`class [Name] [extends …] // { … }`). Appended at the end of the keyword group so existing token values // are not shifted. `extends`/`props`/`methods`/`new` are contextual idents in // the body, not reserved keywords. Class // Enum introduces an enum expression/statement (`enum [Name] { … }`). // Appended at the end of the keyword group so existing token values are not // shifted. `bit` inside the body is a contextual ident, not a keyword. Enum // Interface introduces an interface expression/statement (`interface [Name] // { … }`). Appended at the end of the keyword group so existing token values // are not shifted. `extends`/`get`/`set`/`parse` inside the body are // contextual idents, not reserved keywords (`prop`/`meti` reuse their tokens). Interface GroupKeywordEnd // DoubleColon is the assign-to-type operator `obj :: Type` (a checked cast // that returns obj when it is assignable to Type, else raises a type error; // chainable as `obj::T1::T2`). Placed after the keyword group so it is neither // a keyword nor shifts any existing token value; its operator behaviour comes // from Precedence and an explicit compiler case, not group membership. DoubleColon // :: )
List of tokens
func (Token) IsBinaryOperator ¶
IsBinaryOperator reports whether token is a binary operator.
func (Token) IsBlockEnd ¶
func (Token) IsBlockStart ¶
func (Token) IsOperator ¶
IsOperator returns true if the token is an operator.
func (Token) IsUserBinaryOperator ¶ added in v0.0.2
IsUserBinaryOperator reports whether tok is a binary operator that has no built-in semantics and must be implemented via `met gad.binOp` (and the self-assign forms via `met gad.selfAssignOp`): `<<<`, `>>>`, `%%`.
func (Token) Precedence ¶
Precedence returns the precedence for the operator token.
Click to show internal directories.
Click to hide internal directories.