token

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 1 Imported by: 2

Documentation

Index

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 FromName

func FromName(name string) (t Token)

FromName return a Token from name

func Lookup

func Lookup(ident string) Token

Lookup returns corresponding keyword if ident is a keyword.

func Unassign

func Unassign(tok Token) Token

Unassign convert an assignable Token to your non assignable Token

func (Token) Is

func (tok Token) Is(other ...Token) bool

Is returns true if then token equals one of args.

func (Token) IsBinaryOperator

func (tok Token) IsBinaryOperator() bool

IsBinaryOperator reports whether token is a binary operator.

func (Token) IsBlockEnd

func (tok Token) IsBlockEnd() bool

func (Token) IsBlockStart

func (tok Token) IsBlockStart() bool

func (Token) IsKeyword

func (tok Token) IsKeyword() bool

IsKeyword returns true if the token is a keyword.

func (Token) IsLiteral

func (tok Token) IsLiteral() bool

IsLiteral returns true if the token is a literal.

func (Token) IsOperator

func (tok Token) IsOperator() bool

IsOperator returns true if the token is an operator.

func (Token) IsUserBinaryOperator added in v0.0.2

func (tok Token) IsUserBinaryOperator() bool

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) Name

func (tok Token) Name() string

func (Token) Precedence

func (tok Token) Precedence() int

Precedence returns the precedence for the operator token.

func (Token) String

func (tok Token) String() string

func (Token) Valid added in v0.0.2

func (tok Token) Valid() bool

Jump to

Keyboard shortcuts

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