token

package
v0.0.0-...-0be312a Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2017 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// Return is used to return from a function.
	Return = "return"
)

Variables

This section is empty.

Functions

func IsInteger

func IsInteger(s string) bool

IsInteger returns true if the given string contains only digits

func IsKeyword

func IsKeyword(s string) bool

IsKeyword returns true if the given string is a reserved keyword of the language

func IsLetter

func IsLetter(s string) bool

IsLetter returns true if the given string contains only letters

Types

type Position

type Position struct {
	Line   int
	Column int
	Len    int
}

Position defines the position in the source code.

type Token

type Token struct {
	Pos  Position
	Type Type
	Raw  string
}

Token defines one token in the source code.

type Type

type Type int

Type defines the type of a token.

const (
	Identifier Type = iota

	Keyword

	Integer

	ParenthesisOpen
	ParenthesisClose

	CurlyBracketOpen
	CurlyBracketClose

	SquareBracketOpen
	SquareBracketClose

	Arrow
	Comma

	Assign
	Plus
	Minus
	Slash
	Multiply
	Percent

	Equal
	NotEqual
	Greater
	Less
	GreaterEqual
	LessEqual

	Illegal
)

All possible token types.

func FromRaw

func FromRaw(raw string) Type

FromRaw returns the token.Type for the given raw value.

func (Type) String

func (i Type) String() string

Jump to

Keyboard shortcuts

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