token

package
v0.0.0-...-3085ebc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Position

type Position struct {
	Filename string
	Offset   int //offset relative to entire file
	Line     int
	Col      int //offset relative to each line
}

Position is the location of a code point in the source

func (Position) Sline

func (p Position) Sline() string

We could not use `Line()` as function name, because `Line` is the struct's field

func (Position) String

func (p Position) String() string

Stringer method for Position

type Token

type Token struct {
	Pos     Position
	Type    TokenType
	Literal string
}

func (Token) String

func (t Token) String() string

Stringer method for Token

type TokenType

type TokenType int

token

const (
	TOKEN_ILLEGAL TokenType = (iota - 1) // Illegal token
	TOKEN_EOF                            //End Of File

	TOKEN_PLUS       // +
	TOKEN_MINUS      // -
	TOKEN_MULTIPLY   // *
	TOKEN_DIVIDE     // '/'
	TOKEN_MOD        // '%'
	TOKEN_POWER      // **
	TOKEN_INCREMENT  // ++
	TOKEN_DECREMENT  // --
	TOKEN_PLUS_A     // +=
	TOKEN_MINUS_A    // -=
	TOKEN_ASTERISK_A // *=
	TOKEN_SLASH_A    // /=
	TOKEN_MOD_A      // %=

	TOKEN_LPAREN    // (
	TOKEN_RPAREN    // )
	TOKEN_ASSIGN    // =
	TOKEN_SEMICOLON //;
	TOKEN_COLON     //:
	TOKEN_COMMA     //,
	TOKEN_DOT       //.
	TOKEN_DOTDOT    //..
	TOKEN_ELLIPSIS  //...
	TOKEN_LBRACE    // {
	TOKEN_RBRACE    // }
	TOKEN_BANG      // !
	TOKEN_LBRACKET  // [
	TOKEN_RBRACKET  // ]
	TOKEN_COMMENT   // #
	TOKEN_AT        // @
	TOKEN_CMD       // `

	TOKEN_LT       // <
	TOKEN_LE       // <=
	TOKEN_GT       // >
	TOKEN_GE       // >=
	TOKEN_EQ       // ==
	TOKEN_NEQ      // !=
	TOKEN_MATCH    // =~
	TOKEN_NOTMATCH // !~
	TOKEN_FATARROW // =>
	TOKEN_PIPE     // |>

	TOKEN_AND // &&
	TOKEN_OR  // ||

	TOKEN_NUMBER     //10 or 10.1
	TOKEN_IDENTIFIER //identifier
	TOKEN_STRING     //""

	//reserved keywords
	TOKEN_TRUE        //true
	TOKEN_FALSE       //false
	TOKEN_NIL         // nil
	TOKEN_LET         //let
	TOKEN_RETURN      //return
	TOKEN_FUNCTION    //fn
	TOKEN_IF          //if
	TOKEN_ELSE        //else
	TOKEN_WHILE       //while
	TOKEN_DO          //do
	TOKEN_FOR         //for
	TOKEN_IN          //in
	TOKEN_BREAK       //break
	TOKEN_CONTINUE    //continue
	TOKEN_IMPORT      //import
	TOKEN_STRUCT      //struct
	TOKEN_SWITCH      //switch
	TOKEN_CASE        //case
	TOKEN_DEFAULT     //default
	TOKEN_FALLTHROUGH //fallthrough
	TOKEN_TRY         //try
	TOKEN_CATCH       //catch
	TOKEN_FINALLY     //finally
	TOKEN_THROW       //throw
	TOKEN_TAIL        //tail call

	TOKEN_REGEX // regular expression
)

func LookupIdent

func LookupIdent(ident string) TokenType

func (TokenType) String

func (tt TokenType) String() string

for debug & testing

Jump to

Keyboard shortcuts

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