token

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 1 Imported by: 3 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package token provides the token types and structures for the VHS Tape language.

Index

Constants

View Source
const (
	AT        = "@"
	EQUAL     = "="
	PLUS      = "+"
	PERCENT   = "%"
	SLASH     = "/"
	BACKSLASH = "\\"
	DOT       = "."
	DASH      = "-"

	MINUS         = "-"
	RIGHT_BRACKET = "]"
	LEFT_BRACKET  = "["
	CARET         = "^"

	EM           = "EM"
	MILLISECONDS = "MILLISECONDS"
	MINUTES      = "MINUTES"
	PX           = "PX"
	SECONDS      = "SECONDS"

	EOF     = "EOF"
	ILLEGAL = "ILLEGAL"

	ALT         = "ALT"
	BACKSPACE   = "BACKSPACE"
	CTRL        = "CTRL"
	DELETE      = "DELETE"
	END         = "END"
	ENTER       = "ENTER"
	ESCAPE      = "ESCAPE"
	HOME        = "HOME"
	INSERT      = "INSERT"
	PAGE_DOWN   = "PAGE_DOWN"
	PAGE_UP     = "PAGE_UP"
	SCROLL_DOWN = "SCROLL_DOWN"
	SCROLL_UP   = "SCROLL_UP"
	SLEEP       = "SLEEP"
	SPACE       = "SPACE"
	TAB         = "TAB"
	SHIFT       = "SHIFT"

	COMMENT = "COMMENT"
	NUMBER  = "NUMBER"
	STRING  = "STRING"
	JSON    = "JSON"
	REGEX   = "REGEX"
	BOOLEAN = "BOOLEAN"

	DOWN  = "DOWN"
	LEFT  = "LEFT"
	RIGHT = "RIGHT"
	UP    = "UP"

	HIDE            = "HIDE"
	OUTPUT          = "OUTPUT"
	REQUIRE         = "REQUIRE"
	SET             = "SET"
	SHOW            = "SHOW"
	SOURCE          = "SOURCE"
	TYPE            = "TYPE"
	SCREENSHOT      = "SCREENSHOT"
	COPY            = "COPY"
	PASTE           = "PASTE"
	SHELL           = "SHELL"
	ENV             = "ENV"
	FONT_FAMILY     = "FONT_FAMILY"
	FONT_SIZE       = "FONT_SIZE"
	FRAMERATE       = "FRAMERATE"
	PLAYBACK_SPEED  = "PLAYBACK_SPEED"
	HEIGHT          = "HEIGHT"
	WIDTH           = "WIDTH"
	ROWS            = "ROWS"
	COLUMNS         = "COLUMNS"
	LETTER_SPACING  = "LETTER_SPACING"
	LINE_HEIGHT     = "LINE_HEIGHT"
	TYPING_SPEED    = "TYPING_SPEED"
	PADDING         = "PADDING"
	THEME           = "THEME"
	LOOP_OFFSET     = "LOOP_OFFSET"
	MARGIN_FILL     = "MARGIN_FILL"
	MARGIN          = "MARGIN"
	WINDOW_BAR      = "WINDOW_BAR"
	WINDOW_BAR_SIZE = "WINDOW_BAR_SIZE"
	BORDER_RADIUS   = "CORNER_RADIUS"
	WAIT            = "WAIT"
	WAIT_TIMEOUT    = "WAIT_TIMEOUT"
	WAIT_PATTERN    = "WAIT_PATTERN"
	CURSOR_BLINK    = "CURSOR_BLINK"
)

Tokens for the VHS language.

Variables

View Source
var Keywords = map[string]Type{
	"em":            EM,
	"px":            PX,
	"ms":            MILLISECONDS,
	"s":             SECONDS,
	"m":             MINUTES,
	"Set":           SET,
	"Sleep":         SLEEP,
	"Type":          TYPE,
	"Enter":         ENTER,
	"Space":         SPACE,
	"Backspace":     BACKSPACE,
	"Delete":        DELETE,
	"Insert":        INSERT,
	"Ctrl":          CTRL,
	"Alt":           ALT,
	"Shift":         SHIFT,
	"Down":          DOWN,
	"Left":          LEFT,
	"Right":         RIGHT,
	"Up":            UP,
	"PageUp":        PAGE_UP,
	"PageDown":      PAGE_DOWN,
	"ScrollUp":      SCROLL_UP,
	"ScrollDown":    SCROLL_DOWN,
	"Tab":           TAB,
	"Escape":        ESCAPE,
	"End":           END,
	"Hide":          HIDE,
	"Require":       REQUIRE,
	"Show":          SHOW,
	"Output":        OUTPUT,
	"Shell":         SHELL,
	"FontFamily":    FONT_FAMILY,
	"MarginFill":    MARGIN_FILL,
	"Margin":        MARGIN,
	"WindowBar":     WINDOW_BAR,
	"WindowBarSize": WINDOW_BAR_SIZE,
	"BorderRadius":  BORDER_RADIUS,
	"FontSize":      FONT_SIZE,
	"Framerate":     FRAMERATE,
	"Height":        HEIGHT,
	"LetterSpacing": LETTER_SPACING,
	"LineHeight":    LINE_HEIGHT,
	"PlaybackSpeed": PLAYBACK_SPEED,
	"TypingSpeed":   TYPING_SPEED,
	"Padding":       PADDING,
	"Theme":         THEME,
	"Width":         WIDTH,
	"Rows":          ROWS,
	"Columns":       COLUMNS,
	"LoopOffset":    LOOP_OFFSET,
	"WaitTimeout":   WAIT_TIMEOUT,
	"WaitPattern":   WAIT_PATTERN,
	"Wait":          WAIT,
	"Source":        SOURCE,
	"CursorBlink":   CURSOR_BLINK,
	"true":          BOOLEAN,
	"false":         BOOLEAN,
	"Screenshot":    SCREENSHOT,
	"Copy":          COPY,
	"Paste":         PASTE,
	"Env":           ENV,
}

Keywords maps keyword strings to tokens.

Functions

func IsCommand

func IsCommand(t Type) bool

IsCommand returns whether the string is a command.

func IsModifier

func IsModifier(t Type) bool

IsModifier returns whether the token is a modifier.

func IsSetting

func IsSetting(t Type) bool

IsSetting returns whether a token is a setting.

func ToCamel added in v0.9.0

func ToCamel(s string) string

ToCamel converts a snake_case string to CamelCase.

Types

type Token

type Token struct {
	Type    Type
	Literal string
	Line    int
	Column  int
}

Token represents a lexer token.

type Type

type Type string

Type represents a token's type.

func LookupIdentifier

func LookupIdentifier(ident string) Type

LookupIdentifier returns whether the identifier is a keyword. In `vhs`, there are no _actual_ identifiers, i.e. there are no variables. Instead, identifiers are simply strings (i.e. bare words).

func (Type) String

func (t Type) String() string

String converts a token to it's human readable string format.

Jump to

Keyboard shortcuts

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