token

package
v0.0.0-...-e1ef514 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2018 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) IsValid

func (p Position) IsValid() bool

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
}

type TokenType

type TokenType int
const (
	ILLEGAL TokenType = (iota - 1) // Illegal token
	EOF

	IDENT //identifier
	INT   //int literal
	UINT  //unsigned int
	FLOAT //float literal

	EQ         // ==
	NEQ        // !=
	MATCH      // =~
	NOTMATCH   // !~
	ASSIGN     // =
	PLUS       // +
	PLUS_A     // += (PLUS ASSIGN)
	MINUS      // -
	MINUS_A    // -= (MINUS ASSIGN)
	BANG       // !
	ASTERISK   // *
	ASTERISK_A // *= (ASTERISK ASSIGN)
	SLASH      // /  divide
	SLASH_A    // /= (SLASH ASSIGN)
	MOD        // %
	MOD_A      // %= //MOD ASSIGN
	POWER      // ** (POWER)
	QUESTIONM  // ? (QUESTION MARK)

	LT        // <
	LE        // <=
	SHIFT_L   // << (SHIFT LEFT)
	GT        // >
	GE        // >=
	SHIFT_R   // >> (SHIFT RIGHT)
	COMMA     // ,
	SEMICOLON // ;

	LPAREN    // (
	RPAREN    // )
	LBRACE    // {
	RBRACE    // }
	LBRACKET  // [
	RBRACKET  // ]
	COLON     // :
	DOT       // .
	DOTDOT    // ..  (PARTIAL IMPLEMENTED, ONLY SUPPORT INTEGER/SingleString RANGE, AND ONLY USED IN 'FOR X IN A..B {}' )
	ELLIPSIS  //... Function Variadic parameters
	PIPE      // |>
	THINARROW // ->
	FATARROW  // =>

	INCREMENT // ++
	DECREMENT // --

	BITAND   // &
	BITOR    // |
	BITXOR   // ^
	BITAND_A // &=
	BITOR_A  // |=
	BITXOR_A // ^=

	CONDAND // &&
	CONDOR  // ||

	AT //@

	FUNCTION
	LET
	TRUE
	FALSE
	IF
	ELIF
	ELSIF
	ELSEIF
	ELSE
	RETURN
	INCLUDE
	STRING
	ISTRING
	BYTES
	AND
	OR
	STRUCT
	DO
	WHILE
	BREAK
	CONTINUE

	COMMENT // '#' or '//' (single-line comment), '/* */' multiline comment
	REGEX   // REGEX
	FOR
	IN
	WHERE
	GREP
	MAP
	CASE
	IS
	TRY
	CATCH
	FINALLY
	THROW
	DEFER
	SPAWN
	NIL
	ENUM
	QW
	UNLESS

	//class related
	INTERFACE //NOT IMPLEMENTED
	CLASS
	NEW
	PROPERTY
	GET
	SET
	PUBLIC    //NOT IMPLEMENTED
	PRIVATE   //NOT IMPLEMENTED
	PROTECTED //NOT IMPLEMENTED
	STATIC
	DEFAULT

	// User Defined Operator
	UDO
	UNDERSCORE // _(PlaceHolder)

	//Meta-Operators(for working with array)
	TILDEPLUS     // ~+
	TILDEMINUS    // ~-
	TILDEASTERISK // ~*
	TILDESLASH    // ~/
	TILDEMOD      // ~%
	TILDECARET    // ~^

	USING
	QUESTIONMM // ?? (Null Coalescing Operator)

)

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