Documentation
¶
Index ¶
- Variables
- func Length() int
- func Types() iter.Seq2[uint16, string]
- type Token
- func (t *Token) AnsiStyling() []color.Attribute
- func (t *Token) BackgroundColor() prompt.Color
- func (*Token) Class() *value.Class
- func (t *Token) Color() prompt.Color
- func (t *Token) Copy() value.Reference
- func (*Token) DirectClass() *value.Class
- func (t *Token) DisplayAttributes() []prompt.DisplayAttribute
- func (t *Token) Equal(other *Token) bool
- func (t *Token) Error() string
- func (t *Token) FetchValue() string
- func (t *Token) FirstByteIndex() pstrings.ByteNumber
- func (t *Token) Inspect() string
- func (t *Token) InspectValue() string
- func (t *Token) InstanceVariables() *value.InstanceVariables
- func (t *Token) LastByteIndex() pstrings.ByteNumber
- func (t *Token) Location() *position.Location
- func (t *Token) SetLocation(loc *position.Location)
- func (t *Token) SetSpan(span *position.Span)
- func (*Token) SingletonClass() *value.Class
- func (t *Token) Span() *position.Span
- func (t *Token) Splice(loc *position.Location, unquote bool) *Token
- func (t *Token) String() string
- type Type
- func (t Type) IsAssignmentOperator() bool
- func (t Type) IsCollectionLiteralBeg() bool
- func (t Type) IsComparisonOperator() bool
- func (t Type) IsEndOfFile() bool
- func (t Type) IsEqualityOperator() bool
- func (t Type) IsFloatLiteral() bool
- func (t Type) IsIdentifier() bool
- func (t Type) IsIntLiteral() bool
- func (t Type) IsKeyword() bool
- func (t Type) IsLiteral() bool
- func (t Type) IsNonOverridableOperator() bool
- func (t Type) IsOperator() bool
- func (t Type) IsOverridableOperator() bool
- func (t Type) IsRegexFlag() bool
- func (t Type) IsSpecialCollectionLiteral() bool
- func (t Type) IsSpecialCollectionLiteralBeg() bool
- func (t Type) IsStatementSeparator() bool
- func (t Type) IsValidAsArgumentToNoParenFunctionCall() bool
- func (t Type) IsValidAsEndInRangeLiteral() bool
- func (t Type) IsValidAsEndInRangePattern() bool
- func (t Type) IsValidFunctionName() bool
- func (t Type) IsValidMacroName() bool
- func (t Type) IsValidMethodName() bool
- func (t Type) IsValidPublicMethodName() bool
- func (t Type) IsValidRegularMethodName() bool
- func (t Type) IsValidSimpleSymbolContent() bool
- func (t Type) Name() string
- func (i Type) String() string
- func (t Type) TypeName() string
Constants ¶
This section is empty.
Variables ¶
var Keywords = map[string]Type{}/* 103 elements not displayed */
Maps keywords to their Token Type.
Functions ¶
Types ¶
type Token ¶
type Token struct {
Type
Value string // Literal value of the token, will be empty for tokens with non-dynamic lexemes
// contains filtered or unexported fields
}
Represents a single token produced by the lexer.
func NewWithValue ¶
Creates a new token with the specified value.
func (*Token) AnsiStyling ¶
Returns the ANSI font styling for the github.com/fatih/color package.
func (*Token) BackgroundColor ¶
Background color for go-prompt.
func (*Token) DirectClass ¶
func (*Token) DisplayAttributes ¶
func (t *Token) DisplayAttributes() []prompt.DisplayAttribute
Display attributes for go-prompt eg. bold, italic, underline.
func (*Token) FetchValue ¶
When the Value field of the token is empty, the string will be fetched from a global map.
func (*Token) FirstByteIndex ¶
func (t *Token) FirstByteIndex() pstrings.ByteNumber
Index of the first byte of the lexeme. Used by go-prompt.
func (*Token) InspectValue ¶
Returns a shortened version of the value which resembles source code.
func (*Token) InstanceVariables ¶
func (t *Token) InstanceVariables() *value.InstanceVariables
func (*Token) LastByteIndex ¶
func (t *Token) LastByteIndex() pstrings.ByteNumber
Index of the last byte of the lexeme. Used by go-prompt.
func (*Token) SetLocation ¶
func (*Token) SingletonClass ¶
type Type ¶
type Type uint16
Represents the type of token
const ( ZERO_VALUE Type = iota // Zero value for Type ERROR // ERROR Token with a message END_OF_FILE // End Of File has been reached TEXT // Plain text NEWLINE // Newline `\n`, `\r\n` SEMICOLON // SEMICOLON `;` COMMA // Comma `,` DOT // Dot `.` QUESTION_DOT // Safe method call operator `?.` DOT_DOT // Cascade call operator `..` QUESTION_DOT_DOT // Safe cascade call operator `?..` COLON // Colon `:` QUESTION // Question mark `?` // Operators start here LABEL_OP_BEG THIN_ARROW // Thin arrow `->` (closure arrow) WIGGLY_ARROW // Wiggly arrow `~>` (lambda arrow) THICK_ARROW // Thick arrow `=>` // Assignment operators start here LABEL_ASSIGN_OP_BEG EQUAL_OP // Equal (assignment) `=` MINUS_EQUAL // Minus equal `-=` PLUS_EQUAL // Plus equal `+=` STAR_EQUAL // Star equal `*=` SLASH_EQUAL // Slash equal `/=` STAR_STAR_EQUAL // Two stars equal `**=` TILDE_EQUAL // Tilde equal `~=` AND_AND_EQUAL // Logical and equal `&&=` AND_EQUAL // Bitwise and equal `&=` OR_OR_EQUAL // Logical or `||=` OR_EQUAL // Bitwise or equal `|=` XOR_EQUAL // Bitwise xor equal `^=` QUESTION_QUESTION_EQUAL // Nil coalescing equal operator `??=` LBITSHIFT_EQUAL // Left bitwise shift equal `<<=` LTRIPLE_BITSHIFT_EQUAL // Triple left bitwise shift equal `<<<=` RBITSHIFT_EQUAL // Right bitwise shift equal `>>=` RTRIPLE_BITSHIFT_EQUAL // Triple right bitwise shift equal `>>>=` PERCENT_EQUAL // Percent equal `%=` COLON_EQUAL // Colon equal `:=` LABEL_ASSIGN_OP_END // Assignment operators end here SHORT_UNQUOTE_BEG // Short unquote beginning `!{` LPAREN // Left parenthesis `(` RPAREN // Right parenthesis `)` LBRACE // Left brace `{` RBRACE // Right brace `}` LBRACKET // Left bracket `[` QUESTION_LBRACKET // Safe access `?[` RBRACKET // Right bracket `]` SCOPE_RES_OP // Scope resolution operator `::` COLON_COLON_LBRACKET // Colon, colon, left bracket `::[` DOT_COLON // Dot colon `.:` CLOSED_RANGE_OP // Closed range operator `...` OPEN_RANGE_OP // Open range operator `<.<` RIGHT_OPEN_RANGE_OP // Right open range operator `..<` LEFT_OPEN_RANGE_OP // Left open range operator `<..` PIPE_OP // Pipe operator `|>` AND_AND // Logical and `&&` AND_BANG // Logical expression sequencing operator `&!` with the precedence of `&&` OR_OR // Logical or `||` OR_BANG // Logical expression sequencing operator `|!` with the precedence of `||` NOT_EQUAL // Not equal `!=` LAX_NOT_EQUAL // Lax not equal operator `!~` STRICT_EQUAL // Strict equal `===` STRICT_NOT_EQUAL // Strict not equal `!==` QUESTION_QUESTION // Nil coalescing operator `??` BANG // Logical not `!` ISA_OP // "is a" operator `<:` REVERSE_ISA_OP // Reverse "is a" operator `:>` INSTANCE_OF_OP // Instance of operator `<<:` REVERSE_INSTANCE_OF_OP // Reverse instance of operator `:>>` // Overridable operators start here LABEL_OVERRIDABLE_OP_BEG PLUS_PLUS // Increment operator `++` MINUS_MINUS // Decrement operator `--` PLUS_AT // Negate `+@` MINUS_AT // Negate `-@` MINUS // Minus `-` PLUS // Plus `+` STAR // Star `*` SLASH // Slash `/` STAR_STAR // Two stars `**` LESS // Less than `<` LESS_EQUAL // Less than or equal `<=` GREATER // Greater than `>` GREATER_EQUAL // Greater than or equal `>=` SPACESHIP_OP // Spaceship operator `<=>` EQUAL_EQUAL // Equal (comparison) `==` LAX_EQUAL // Lax equality operator `=~` TILDE // Tilde `~` AND // Bitwise and `&` AND_TILDE // Bitwise and not `&~` OR // Bitwise or `|` XOR // Bitwise xor `^` LBITSHIFT // Left bitwise shift `<<` LTRIPLE_BITSHIFT // Triple left bitwise shift `<<<` RBITSHIFT // Right bitwise shift `>>` RTRIPLE_BITSHIFT // Triple right bitwise shift `>>>` PERCENT // Percent `%` LABEL_OP_END // Operators end here // Identifiers start here LABEL_IDENTIFIER_BEG DOLLAR_IDENTIFIER // Dollar Identifier eg. `$foo` PUBLIC_IDENTIFIER // Identifier eg. `foo` PRIVATE_IDENTIFIER // Identifier with a initial underscore eg. `_foo` PUBLIC_CONSTANT // Constant (identifier with an initial capital letter) eg. `Foo` PRIVATE_CONSTANT // Constant with an initial underscore eg. `_Foo` LABEL_IDENTIFIER_END // Identifiers end here INSTANCE_VARIABLE // Instance variable token eg. `@foo` // Literals start here LABEL_LITERAL_BEG // Special collection literals start here LABEL_SPECIAL_COLLECTION_LITERAL_BEG WORD_ARRAY_LIST_BEG // Word array literal beginning `\w[` WORD_ARRAY_LIST_END // Word array literal end `]` SYMBOL_ARRAY_LIST_BEG // Symbol array literal beginning `\s[` SYMBOL_ARRAY_LIST_END // Symbol array literal end `]` HEX_ARRAY_LIST_BEG // Hexadecimal integer array literal beginning `\x[` HEX_ARRAY_LIST_END // Hexadecimal integer array literal end `]` BIN_ARRAY_LIST_BEG // Binary integer array literal beginning `\b[` BIN_ARRAY_LIST_END // Binary integer array literal end `]` WORD_HASH_SET_BEG // Word set literal beginning `^w[` WORD_HASH_SET_END // Word set literal end `]` SYMBOL_HASH_SET_BEG // Symbol set literal beginning `^s[` SYMBOL_HASH_SET_END // Symbol set literal end `]` HEX_HASH_SET_BEG // Hexadecimal integer set literal beginning `^x[` HEX_HASH_SET_END // Hexadecimal integer set literal end `]` BIN_HASH_SET_BEG // Binary integer set literal beginning `^b[` BIN_HASH_SET_END // Binary integer set literal end `]` WORD_ARRAY_TUPLE_BEG // Word arrayTuple literal beginning `%w[` WORD_ARRAY_TUPLE_END // Word arrayTuple literal end `]` SYMBOL_ARRAY_TUPLE_BEG // Symbol arrayTuple literal beginning `%s[` SYMBOL_ARRAY_TUPLE_END // Symbol arrayTuple literal end `]` HEX_ARRAY_TUPLE_BEG // Hexadecimal integer arrayTuple literal beginning `%x[` HEX_ARRAY_TUPLE_END // Hexadecimal integer arrayTuple literal end `]` BIN_ARRAY_TUPLE_BEG // Binary integer arrayTuple literal beginning `%b[` BIN_ARRAY_TUPLE_END // Binary integer arrayTuple literal end `]` LABEL_SPECIAL_COLLECTION_LITERAL_END // Special collection literals end here CLOSURE_TYPE_BEG // Beginning of a closure type `%|` HASH_SET_LITERAL_BEG // HashHashSet literal beginning `^[` TUPLE_LITERAL_BEG // ArrayTuple literal beginning `%[` RECORD_LITERAL_BEG // Record literal beginning `%{` DOC_COMMENT // Documentation comment `##[` ... `]##` RAW_STRING // Raw String literal delimited by single quotes `'` ... `'` CHAR_LITERAL // Character literal delimited by backticks eg. `f` RAW_CHAR_LITERAL // Raw Character literal delimited by r` eg. r`f` REGEX_BEG // Beginning delimiter of Regex literals `%/` REGEX_CONTENT // Regex literal content REGEX_INTERP_BEG // Beginning of regex interpolation `${` REGEX_INTERP_END // End of regex interpolation `}` REGEX_END // Ending delimiter of Regex literals `/` // Regex flags start here LABEL_REGEX_FLAG_BEG REGEX_FLAG_i // Regex flag i REGEX_FLAG_m // Regex flag m REGEX_FLAG_U // Regex flag U REGEX_FLAG_a // Regex flag a REGEX_FLAG_x // Regex flag x REGEX_FLAG_s // Regex flag s LABEL_REGEX_FLAG_END // Regex flags end here STRING_BEG // Beginning delimiter of String literals `"` STRING_CONTENT // String literal content STRING_INTERP_LOCAL // A local embedded in string interpolation eg. `$foo` STRING_INTERP_CONSTANT // A constant embedded in string interpolation eg. `$Foo` STRING_INTERP_BEG // Beginning of string interpolation `${` STRING_INSPECT_INTERP_BEG // Beginning of string inspect interpolation `#{` STRING_INSPECT_INTERP_CONSTANT // A constant embedded in inspect string interpolation eg. `#Foo` STRING_INSPECT_INTERP_LOCAL // A local embedded in inspect string interpolation eg. `#foo` STRING_INTERP_END // End of string interpolation `}` STRING_END // Ending delimiter of String literals `"` // Int literals start here LABEL_INT_LITERAL_BEG INT // Int literal eg. `23` UINT // UInt literal eg. `23u` INT64 // Int64 literal eg. `23i64` UINT64 // UInt64 literal eg. `23u64` INT32 // Int32 literal eg. `23i32` UINT32 // UInt32 literal eg. `23u32` INT16 // Int16 literal eg. `23i16` UINT16 // UInt16 literal eg. `23u16` INT8 // Int8 literal eg. `23i8` UINT8 // UInt8 literal eg. `23u8` LABEL_INT_LITERAL_END // Int literals end here // Float literals start here LABEL_FLOAT_LITERAL_BEG FLOAT // Float literal eg. `2.5` BIG_FLOAT // BigFloat literal eg. `2.5bf` FLOAT64 // Float64 literal eg. `2.5f64` FLOAT32 // Float32 literal eg. `2.5f32` LABEL_FLOAT_LITERAL_END // Float literals end here LABEL_LITERAL_END // Literals end here // Keywords start here LABEL_KEYWORD_BEG NIL // Keyword `nil` FALSE // Keyword `false` TRUE // Keyword `true` IF // Keyword `if` ELSE // Keyword `else` ELSIF // Keyword `elsif` UNLESS // Keyword `unless` WHILE // Keyword `while` UNTIL // Keyword `until` LOOP // Keyword `loop` FOR // Keyword `for` FORNUM // Keyword `fornum` IN // Keyword `in` OF // Keyword `of` BREAK // Keyword `break` CONTINUE // Keyword `continue` RETURN // Keyword `return` YIELD // Keyword `yield` ASYNC // Keyword `async` AWAIT // Keyword `await` AWAIT_SYNC // Keyword `await_sync` GO // Keyword `go` DEF // Keyword `def` SIG // Keyword `sig` END // Keyword `end` THEN // Keyword `then` INIT // Keyword `init` NOINIT // Keyword `noinit` CLASS // Keyword `class` STRUCT // Keyword `struct` MODULE // Keyword `module` MIXIN // Keyword `mixin` INTERFACE // Keyword `interface` INCLUDE // Keyword `include` IMPLEMENT // Keyword `implement` EXTEND // Keyword `extend` ENUM // Keyword `enum` TYPE // Keyword `type` TYPEDEF // Keyword `typedef` TYPEOF // Keyword `typeof` VAR // Keyword `var` VAL // Keyword `val` CONST // Keyword `const` THROW // Keyword `throw` TRY // Keyword `try` CATCH // Keyword `catch` DO // Keyword `do` FINALLY // Keyword `finally` DEFER // Keyword `defer` ALIAS // Keyword `alias` AS // Keyword `as` IS // Keyword `is` SELF // Keyword `self` SUPER // Keyword `super` SWITCH // Keyword `switch` CASE // Keyword `case` MATCH // Keyword `match` WITH // Keyword `with` USING // Keyword `using` BREAKPOINT // Keyword `breakpoint` GETTER // Keyword `getter` SETTER // Keyword `setter` ATTR // Keyword `attr` MUST // Keyword `must` SINGLETON // Keyword `singleton` ABSTRACT // Keyword `abstract` SEALED // Keyword `sealed` VOID // Keyword `void` NEVER // Keyword `never` NOTHING // Keyword `nothing` ANY // Keyword `any` PRIMITIVE // Keyword `primitive` PUBLIC // Keyword `public` PRIVATE // Keyword `private` PROTECTED // Keyword `protected` NATIVE // Keyword `native` DEFAULT // Keyword `default` MACRO // Keyword `macro` BOOL // Keyword `bool` NEW // Keyword `new` EXTERN // Keyword `extern` IMPORT // Keyword `import` EXPORT // Keyword `export` WHERE // Keyword `where` UNTYPED // Keyword `untyped` UNCHECKED // Keyword `unchecked` GOTO // Keyword `goto` QUOTE // Keyword `quote` QUOTE_EXPR // Keyword `quote_expr` QUOTE_TYPE // Keyword `quote_type` QUOTE_PATTERN // Keyword `quote_pattern` UNQUOTE // Keyword `unquote` UNQUOTE_EXPR // Keyword `unquote_expr` UNQUOTE_TYPE // Keyword `unquote_type` UNQUOTE_IDENT // Keyword `unquote_ident` UNQUOTE_CONST // Keyword `unquote_const` UNQUOTE_IVAR // Keyword `unquote_ivar` UNQUOTE_PATTERN // Keyword `unquote_pattern` UNDEFINED // Keyword `undefined` FUNC // Keyword `func` OVERLOAD // Keyword `overload` UNSAFE // Keyword `unsafe` PATTERN // Keyword `pattern` LABEL_KEYWORD_END // Keywords end here )
func (Type) IsAssignmentOperator ¶
Check whether the token is an assignment operator.
func (Type) IsCollectionLiteralBeg ¶
func (Type) IsComparisonOperator ¶
Check whether the token is a comparison operator.
func (Type) IsEndOfFile ¶
Check whether the token marks the end of the file.
func (Type) IsEqualityOperator ¶
Check whether the token is an equality operator.
func (Type) IsFloatLiteral ¶
Check whether the token is a float literal.
func (Type) IsIdentifier ¶
Check whether the token is an identifier.
func (Type) IsIntLiteral ¶
Check whether the token is an int literal.
func (Type) IsNonOverridableOperator ¶
Check whether the token is a non overridable operator.
func (Type) IsOverridableOperator ¶
Check whether the token is an overridable operator. Overridable operators can be used as method names.
func (Type) IsRegexFlag ¶
Check whether the token represents a regex flag
func (Type) IsSpecialCollectionLiteral ¶
Check whether the token represents a special collection literal like `%w[]`
func (Type) IsSpecialCollectionLiteralBeg ¶
return `true` if the token is the beginning of a special collection literal
func (Type) IsStatementSeparator ¶
Check whether the token can separate statements.
func (Type) IsValidAsArgumentToNoParenFunctionCall ¶
Returns `true` if the token can be a beginning of an argument to a function call without parentheses eg. `foo 2`
func (Type) IsValidAsEndInRangeLiteral ¶
Returns `true` if the token can be an end of a range value eg. `...2`
func (Type) IsValidAsEndInRangePattern ¶
Returns `true` if the token can be an end of a range pattern eg. `...2`
func (Type) IsValidFunctionName ¶
Check whether the token is a valid function name.
func (Type) IsValidMacroName ¶
Check whether the token is a valid macro name.
func (Type) IsValidMethodName ¶
Check whether the token is a valid method name (including operators).
func (Type) IsValidPublicMethodName ¶
Check whether the token is a valid method name in method call expressions.
func (Type) IsValidRegularMethodName ¶
Check whether the token is a valid method name (without operators).
func (Type) IsValidSimpleSymbolContent ¶
Check whether the token is a valid simple symbol content.