token

package
v0.0.0-...-f318d61 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StringToType = map[string]Type{
	"Error": Error,
	"EOF":   EOF,
	"T_0":   T_0,
	"T_1":   T_1,
	"T_2":   T_2,
	"T_3":   T_3,
	"T_4":   T_4,
	"T_5":   T_5,
	"T_6":   T_6,
	"T_7":   T_7,
	"T_8":   T_8,
	"T_9":   T_9,
	"T_10":  T_10,
	"T_11":  T_11,
	"T_12":  T_12,
	"T_13":  T_13,
	"T_14":  T_14,
	"T_15":  T_15,
	"T_16":  T_16,
	"T_17":  T_17,
	"T_18":  T_18,
	"T_19":  T_19,
	"T_20":  T_20,
	"T_21":  T_21,
	"T_22":  T_22,
	"T_23":  T_23,
	"T_24":  T_24,
}
View Source
var TypeToID = []string{
	"Error",
	"$",
	"!",
	"(",
	")",
	".",
	":",
	";",
	"<",
	">",
	"[",
	"]",
	"any",
	"char_lit",
	"empty",
	"letter",
	"lowcase",
	"not",
	"nt",
	"number",
	"package",
	"string_lit",
	"tokid",
	"upcase",
	"{",
	"|",
	"}",
}
View Source
var TypeToString = []string{
	"Error",
	"EOF",
	"T_0",
	"T_1",
	"T_2",
	"T_3",
	"T_4",
	"T_5",
	"T_6",
	"T_7",
	"T_8",
	"T_9",
	"T_10",
	"T_11",
	"T_12",
	"T_13",
	"T_14",
	"T_15",
	"T_16",
	"T_17",
	"T_18",
	"T_19",
	"T_20",
	"T_21",
	"T_22",
	"T_23",
	"T_24",
}

Functions

This section is empty.

Types

type Token

type Token struct {
	// contains filtered or unexported fields
}

func NewToken

func NewToken(typ TokenType, lext, rext int, input []rune) *Token

func (*Token) GetInput

func (t *Token) GetInput() []rune

GetInput returns the input from which t was parsed.

func (*Token) GetLineColumn

func (t *Token) GetLineColumn() (line, col int)

GetLineColumn returns the line and column of the left extent of t

func (*Token) Lext

func (t *Token) Lext() int

Lext returns the left extent of t

func (*Token) Literal

func (t *Token) Literal() []rune

Literal returns the literal runes of t scanned by the lexer

func (*Token) LiteralString

func (t *Token) LiteralString() string

LiteralString returns string(t.Literal())

func (*Token) LiteralStringStripEscape

func (t *Token) LiteralStringStripEscape() string

LiteralStringStripEscape returns string(t.LiteralStripEscape())

func (*Token) LiteralStripEscape

func (t *Token) LiteralStripEscape() []rune

LiteralStripEscape returns the literal runes of t scanned by the lexer

func (*Token) Rext

func (t *Token) Rext() int

Rext returns the right extent of t in the input

func (*Token) String

func (t *Token) String() string

func (*Token) Suppress

func (t *Token) Suppress() bool

Suppress returns true iff t is suppressed by the lexer

func (*Token) Type

func (t *Token) Type() Type

Type returns the token Type of t

func (*Token) TypeID

func (t *Token) TypeID() string

TypeID returns the token Type ID of t. This may be different from the literal of token t.

type TokenType

type TokenType uint32
const (
	STRING TokenType = iota
	NUMBER
	IDENTIFIER
	LEFT_PAREN
	RIGHT_PAREN
	LEFT_BRACE
	RIGHT_BRACE
	COMMA
	DOT
	MINUS
	PLUS
	SEMICOLON
	SLASH
	STAR
	BANG
	BANG_EQUAL
	LESS
	LESS_EQUAL
	GREATER
	GREATER_EQUAL
	AND
	CONTRACT
	ABSTRACT
	INTERFACE
	LIB
	FUNCTION
	TRUE
	FALSE
	ELSE
	FOR
	IF
	NIL
	OR
	PRINT
	RETURN
	SUPER
	THIS
	VAR
	LET
	CONST
	WHILE
	ADDRESS
	PROXY
	UINT256
	UINT512
	BRIDGE
	PRAGMA
	VERSION
	SYNTAX
)

type Type

type Type int
const (
	Error Type = iota
	EOF        //$
	T_0        // !
	T_1        // (
	T_2        // )
	T_3        // .
	T_4        // :
	T_5        // ;
	T_6        // <
	T_7        // >
	T_8        // [
	T_9        // ]
	T_10       // any
	T_11       // char_lit
	T_12       // empty
	T_13       // letter
	T_14       // lowcase
	T_15       // not
	T_16       // nt
	T_17       // number
	T_18       // package
	T_19       // string_lit
	T_20       // tokid
	T_21       // upcase
	T_22       // {
	T_23       // |
	T_24       // }
)

func (Type) ID

func (t Type) ID() string

ID returns the token type ID of token Type t

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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