token

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AND      = "and"
	OR       = "or"
	NOT      = "not"
	IF       = "if"
	THEN     = "then"
	ELIF     = "elif"
	ELSE     = "else"
	FOR      = "for"
	TO       = "to"
	STEP     = "step"
	WHILE    = "while"
	FUN      = "fun"
	END      = "end"
	RETURN   = "return"
	BREAK    = "break"
	CONTINUE = "continue"
)

Variables

View Source
var KEYWORDS = set.NewSet(
	AND,
	OR,
	NOT,
	IF,
	THEN,
	ELIF,
	ELSE,
	FOR,
	TO,
	STEP,
	WHILE,
	FUN,
	END,
	RETURN,
	BREAK,
	CONTINUE,
)

Functions

func IsKeyword

func IsKeyword(identifier string) bool

Types

type JToken

type JToken struct {
	Type     JTokenType
	Value    interface{}
	StartPos *common.JPosition
	EndPos   *common.JPosition
}

func NewJToken

func NewJToken(tokenType JTokenType, value interface{}, startPos, endPos *common.JPosition) *JToken

func (*JToken) IsKeyWord

func (t *JToken) IsKeyWord() bool

func (*JToken) Match

func (t *JToken) Match(typ JTokenType, value interface{}) bool

func (*JToken) String

func (t *JToken) String() string

func (*JToken) ValueToString

func (t *JToken) ValueToString() string

type JTokenType

type JTokenType string
const (
	INT        JTokenType = "INT"
	FLOAT      JTokenType = "FLOAT"
	STRING     JTokenType = "STRING"
	IDENTIFIER JTokenType = "IDENTIFIER"
	KEYWORD    JTokenType = "KEYWORD"
	PLUS       JTokenType = "PLUS"    // +
	MINUS      JTokenType = "MINUS"   // -
	MUL        JTokenType = "MUL"     // *
	DIV        JTokenType = "DIV"     // /
	POW        JTokenType = "POW"     // ^
	EQ         JTokenType = "EQ"      // =
	LPAREN     JTokenType = "LPAREN"  // (
	RPAREN     JTokenType = "RPAREN"  // )
	LSQUARE    JTokenType = "LSQUARE" // [
	RSQUARE    JTokenType = "RSQUARE" // ]
	LBRACE     JTokenType = "LBRACE"  // {
	RBRACE     JTokenType = "RBRACE"  // }
	COLON      JTokenType = "COLON"   // :
	EE         JTokenType = "EE"      // ==
	NE         JTokenType = "NE"      // !=
	LT         JTokenType = "LT"      // <
	GT         JTokenType = "GT"      // >
	LTE        JTokenType = "LTE"     // <=
	GTE        JTokenType = "GTE"     // >=
	COMMA      JTokenType = "COMMA"   // ,
	ARROW      JTokenType = "ARROW"   // ->
	NEWLINE    JTokenType = "NEWLINE"
	EOF        JTokenType = "EOF"
)

Jump to

Keyboard shortcuts

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