qoxe

package module
v0.0.0-...-f982e93 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 4 Imported by: 0

README

qoxe

A free, open-source, cross-platform, cross-language, embeddable, full-stack, fast scripting language. 谢语言是一门免费、开源、跨平台、跨语言、全栈、易嵌入、快速的解释性计算机编程语言。

Documentation

Index

Constants

View Source
const (
	ILLEGAL = "ILLEGAL"
	EOF     = "EOF"

	// Identifiers + Literals
	IDENT = "IDENT"
	INT   = "INT"

	// Operators
	ASSIGN   = "="
	PLUS     = "+"
	MINUS    = "-"
	BANG     = "!"
	ASTERISK = "*"
	SLASH    = "/"

	LT = "<"
	GT = ">"

	EQ     = "=="
	NOT_EQ = "!="

	// Delimiters
	COMMA     = ","
	SEMICOLON = ";"

	LPAREN = "("
	RPAREN = ")"
	LBRACE = "{"
	RBRACE = "}"

	// Keywords
	FUNCTION = "FUNCTION"
	LET      = "LET"
	TRUE     = "TRUE"
	FALSE    = "FALSE"
	IF       = "IF"
	ELSE     = "ELSE"
	RETURN   = "RETURN"
)

token

View Source
const (
	LOWEST      int
	EQUALS      // ==
	LESSGREATER // > or <
	SUM         // +
	PRODUCT     // *
	PREFIX      // -X or !X
	CALL        // myFunction(X)
)

parser

Variables

View Source
var VersionG string = "0.0.1"

Functions

func RunCode

func RunCode(codeA interface{}, ctxA *RunningContext) interface{}

func TokenIsEOF

func TokenIsEOF(tokenA Token) bool

Types

type Expression

type Expression interface {
	Node
	// contains filtered or unexported methods
}

type ExpressionStatement

type ExpressionStatement struct {
	Token      Token
	Expression Expression
}

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

type FuncContext

type FuncContext struct {
	Vars map[string]interface{}

	Tmp interface{}

	DeferStack *tk.SimpleStack
}

func NewFuncContext

func NewFuncContext() *FuncContext

type GlobalContext

type GlobalContext struct {
	SyncMap   tk.SyncMap
	SyncQueue tk.SyncQueue
	SyncStack tk.SyncStack

	SyncSeq tk.Seq

	Vars map[string]interface{}

	VerboseLevel int
}
var GlobalsG *GlobalContext

type Identifier

type Identifier struct {
	Token Token
	Value string
}

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

type IntegerLiteral

type IntegerLiteral struct {
	Token Token
	Value int64
}

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

type LetStatement

type LetStatement struct {
	Token Token
	Name  *Identifier
	Value Expression
}

func (*LetStatement) String

func (ls *LetStatement) String() string

func (*LetStatement) TokenLiteral

func (ls *LetStatement) TokenLiteral() string

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer

func NewLexer

func NewLexer(input string) *Lexer

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

type Node

type Node interface {
	TokenLiteral() string
	String() string
}

ast

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(l *Lexer) *Parser

func (*Parser) Errors

func (p *Parser) Errors() []string

func (*Parser) ParseProgram

func (p *Parser) ParseProgram() *Program

type Program

type Program struct {
	Statements []Statement
}

func (*Program) String

func (p *Program) String() string

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

type QoxeVM

type QoxeVM struct {
	Regs  []interface{}
	Stack *tk.SimpleStack

	RootFunc *FuncContext

	Running *RunningContext
}

type ReturnStatement

type ReturnStatement struct {
	Token       Token
	ReturnValue Expression
}

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

type RunningContext

type RunningContext struct {
	Resv1 string
}

running context

type Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

type Token

type Token struct {
	Type    TokenType
	Literal string
}

type TokenType

type TokenType string

func LookupIdent

func LookupIdent(ident string) TokenType

Jump to

Keyboard shortcuts

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