constants

package
Version: v0.0.0-...-0e32bd2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BYTE_T        byte = 9
	BYTE_EOL      byte = 10
	BYTE_R        byte = 13
	BYTE_SPACE    byte = 32
	BYTE_NOT      byte = 33
	BYTE_DQ       byte = 34
	BYTE_HASH     byte = 35
	BYTE_DOLAR    byte = 36
	BYTE_MODULO   byte = 37
	BYTE_AND      byte = 38
	BYTE_SQ       byte = 39
	BYTE_LPAREN   byte = 40
	BYTE_RPAREN   byte = 41
	BYTE_MULTIPLY byte = 42
	BYTE_PLUS     byte = 43
	BYTE_COMMA    byte = 44
	BYTE_MINUS    byte = 45
	BYTE_DOT      byte = 46
	BYTE_DIVIDE   byte = 47
	BYTE_FNUM     byte = 48
	BYTE_LNUM     byte = 57
	BYTE_COLON    byte = 58
	BYTE_LT       byte = 60
	BYTE_EQ       byte = 61
	BYTE_GT       byte = 62
	BYTE_QM       byte = 63
	BYTE_FBC      byte = 65
	BYTE_LBC      byte = 90
	BYTE_LBRACKET byte = 91
	BYTE_B        byte = 92
	BYTE_RBRACKET byte = 93
	BYTE_XOR      byte = 94
	BYTE_U        byte = 95
	BYTE_G        byte = 96
	BYTE_FSC      byte = 97
	BYTE_LSC      byte = 122
	BYTE_LBRACE   byte = 123
	BYTE_OR       byte = 124
	BYTE_RBRACE   byte = 125
	BYTE_BNOT     byte = 126
)

not included: 0-8, 11, 12, 14-31, 59, 64, 127

View Source
const (
	MAJOR_VERSION string = "0"
	MINOR_VERSION string = "0.0"
	PATCH_VERSION string = "0.0.0"

	I5_FILE_EXT        string = ".i5"
	MAIN_FUNCTION_NAME string = "main"
	I5_DIR             string = "i5"
	I5_PACKAGES_DIR    string = "packages"
)
View Source
const (
	ERROR_FATAL  byte = 0
	ERROR_RETURN byte = 1
	ERROR_BREAK  byte = 2
)
View Source
const (
	EXCEPTION_NULL     string = "null"
	EXCEPTION_TYPE     string = "type"
	EXCEPTION_RANGE    string = "range"
	EXCEPTION_INTERNAL string = "internal"
)
View Source
const (
	TEST_GOT_WANT string = "error: got: %v, want: %v"

	ARGS_UNKNOWN     string = "unknown option: %v"
	ARGS_UNKNOWN_CLR string = "unknown output format: %v"
	ARGS_NO_FILE     string = "no file specified"

	SYNTAX_UNEXPECTED_TOKEN_C string = "unexpected token '%v' with ascii code '%v'"
	SYNTAX_UNEXPECTED_TOKEN   string = "unexpected token '%v'"
	SYNTAX_ERROR              string = "syntax error: %v\nin: %v\n"
	SYNTAX_EXPECTED_FOUND     string = "expected '%v', found '%v'"
	SYNTAX_UNEXPECTED         string = "unexpected '%v'"
	SYNTAX_EXPECTED           string = "expected '%v'"

	PARSER_NOT_INT      string = "could not parse %v as integer"
	PARSER_NOT_FLOAT    string = "could not parse %v as float"
	PARSER_EXPECTED_ARG string = "expected ',' or ')', found '%v'"

	FILE_NOT_FOUND        string = "%v: no such file or directory"
	FILE_FOUND_FILE       string = "%v: expected directory, found file"
	FILE_FOUND_DIR        string = "%v: expected file, found directory"
	FILE_CANNOT_READ_FILE string = "%v: can not read file"
	FILE_CANNOT_READ_DIR  string = "%v: can not read directory"
	FILE_FILE_EXISTS      string = "%v: file already exists"
	FILE_DIR_EXISTS       string = "%v: directory already exists"
	FILE_CANNOT_WRITE     string = "%v: can not write file"

	IR_NIL                 string = "nil"
	IR_MAIN_FN_NOT_FOUND   string = "main function not found"
	IR_INVALID_EVAL        string = "invalid expression: '%v'"
	IR_INVALID_INFIX       string = "invalid expression: '%v%v%v'"
	IR_INVALID_PREFIX      string = "invalid expression: '%v%v'"
	IR_INVALID_POSTFIX     string = "invalid expression: '%v%v'"
	IR_IS_NOT_A_FUNCTION   string = "%v is not a function"
	IR_IS_NOT_A_BOOL       string = "%v is not a boolean"
	IR_IS_NOT_A_STRING     string = "%v is not a string"
	IR_IS_NOT_AN_EXCEPTION string = "%v is not an exception"
	IR_IS_NOT_AN_ARRAY     string = "%v is not an array"
	IR_IS_NOT_A_MAP        string = "%v is not a map"
	IR_IDENT_NOT_FOUND     string = "identifier not found: '%v'"
	IR_BUILTIN_NOT_FOUND   string = "builtin not found: '$%v'"
	IR_CANNOT_ASSIGN       string = "cannot assign to %v"
	IR_CANNOT_BE_KEY       string = "%v cannot be map key"
	IR_NOT_ENOUGH_ARGS     string = "not enough arguments to call function"
)
View Source
const (
	PRECEDENCE_LOWEST   int
	PRECEDENCE_ASSIGN   // = := += -= *= /= %=
	PRECEDENCE_IF       // ?? ::
	PRECEDENCE_OR       // or
	PRECEDENCE_AND      // and
	PRECEDENCE_EQ       // == != < > <= >=
	PRECEDENCE_CONCAT   // :
	PRECEDENCE_QM       // ?
	PRECEDENCE_BTWOR    // |
	PRECEDENCE_BTWXOR   // ^
	PRECEDENCE_BTWAND   // &
	PRECEDENCE_BTWSHIFT // << >>
	PRECEDENCE_SUM      // + -
	PRECEDENCE_PRODUCT  // * / %
	PRECEDENCE_PREFIX   // prefix
	PRECEDENCE_POSTFIX  // postfix
	PRECEDENCE_CALL     // (
	PRECEDENCE_DOT      // .
)
View Source
const (
	// end of line
	TOKEN_EOL string = "EOL"
	// end of file
	TOKEN_EOF string = "EOF"

	// types
	TOKEN_INTEGER    string = "integer"
	TOKEN_FLOAT      string = "float"
	TOKEN_STRING     string = "string"
	TOKEN_BUILTIN    string = "builtin"
	TOKEN_IDENTIFIER string = "identifier"

	// keywords
	TOKEN_ANDAND string = "and"
	TOKEN_OROR   string = "or"
	TOKEN_FN     string = "fn"
	TOKEN_RETURN string = "return"
	TOKEN_IMPORT string = "import"
	TOKEN_AS     string = "as"
	TOKEN_IF     string = "if"
	TOKEN_ELIF   string = "elif"
	TOKEN_ELSE   string = "else"
	TOKEN_SWITCH string = "switch"
	TOKEN_CASE   string = "case"
	TOKEN_LOOP   string = "loop"
	TOKEN_BREAK  string = "break"
	TOKEN_THROW  string = "throw"

	// assignment operators
	TOKEN_EQ         string = "="
	TOKEN_COLONEQ    string = ":="
	TOKEN_PLUSEQ     string = "+="
	TOKEN_MINUSEQ    string = "-="
	TOKEN_MULTIPLYEQ string = "*="
	TOKEN_DIVIDEEQ   string = "/="
	TOKEN_MODULOEQ   string = "%="
	TOKEN_QM         string = "?"

	// comparison operators
	TOKEN_EQEQ  string = "=="
	TOKEN_NOTEQ string = "!="
	TOKEN_LT    string = "<"
	TOKEN_GT    string = ">"
	TOKEN_LTEQ  string = "<="
	TOKEN_GTEQ  string = ">="

	// arithmetic operators
	TOKEN_PLUS     string = "+"
	TOKEN_MINUS    string = "-"
	TOKEN_MULTIPLY string = "*"
	TOKEN_DIVIDE   string = "/"
	TOKEN_MODULO   string = "%"

	// bitwise operators
	TOKEN_AND  string = "&"
	TOKEN_OR   string = "|"
	TOKEN_XOR  string = "^"
	TOKEN_BNOT string = "~"
	TOKEN_LTLT string = "<<"
	TOKEN_GTGT string = ">>"

	// other operators
	TOKEN_NOT        string = "!"
	TOKEN_COLON      string = ":"
	TOKEN_EQGT       string = "=>"
	TOKEN_QMQM       string = "??"
	TOKEN_COLONCOLON string = "::"
	TOKEN_DOT        string = "."
	TOKEN_COMMA      string = ","

	// brackets
	TOKEN_LPAREN string = "("
	TOKEN_RPAREN string = ")"
	TOKEN_LBRACE string = "{"
	TOKEN_RBRACE string = "}"
)
View Source
const (
	TYPE_ARRAY     string = "array"
	TYPE_BOOLEAN   string = "boolean"
	TYPE_BUILTIN   string = "builtin"
	TYPE_EXCEPTION string = "exception"
	TYPE_FLOAT     string = "float"
	TYPE_FUNCTION  string = "function"
	TYPE_INTEGER   string = "integer"
	TYPE_MAP       string = "map"
	TYPE_MODULE    string = "module"
	TYPE_STRING    string = "string"
)

Variables

View Source
var PRECEDENCES = map[string]int{
	TOKEN_EQ:         PRECEDENCE_ASSIGN,
	TOKEN_COLONEQ:    PRECEDENCE_ASSIGN,
	TOKEN_PLUSEQ:     PRECEDENCE_ASSIGN,
	TOKEN_MINUSEQ:    PRECEDENCE_ASSIGN,
	TOKEN_MULTIPLYEQ: PRECEDENCE_ASSIGN,
	TOKEN_DIVIDEEQ:   PRECEDENCE_ASSIGN,
	TOKEN_MODULOEQ:   PRECEDENCE_ASSIGN,
	TOKEN_QMQM:       PRECEDENCE_IF,
	TOKEN_OROR:       PRECEDENCE_OR,
	TOKEN_ANDAND:     PRECEDENCE_AND,
	TOKEN_EQEQ:       PRECEDENCE_EQ,
	TOKEN_NOTEQ:      PRECEDENCE_EQ,
	TOKEN_LT:         PRECEDENCE_EQ,
	TOKEN_GT:         PRECEDENCE_EQ,
	TOKEN_LTEQ:       PRECEDENCE_EQ,
	TOKEN_GTEQ:       PRECEDENCE_EQ,
	TOKEN_COLON:      PRECEDENCE_CONCAT,
	TOKEN_QM:         PRECEDENCE_QM,
	TOKEN_OR:         PRECEDENCE_BTWOR,
	TOKEN_XOR:        PRECEDENCE_BTWXOR,
	TOKEN_AND:        PRECEDENCE_BTWAND,
	TOKEN_LTLT:       PRECEDENCE_BTWSHIFT,
	TOKEN_GTGT:       PRECEDENCE_BTWSHIFT,
	TOKEN_PLUS:       PRECEDENCE_SUM,
	TOKEN_MINUS:      PRECEDENCE_SUM,
	TOKEN_MULTIPLY:   PRECEDENCE_PRODUCT,
	TOKEN_DIVIDE:     PRECEDENCE_PRODUCT,
	TOKEN_MODULO:     PRECEDENCE_PRODUCT,
	TOKEN_LPAREN:     PRECEDENCE_CALL,
	TOKEN_DOT:        PRECEDENCE_DOT,
}

Functions

This section is empty.

Types

type Error

type Error struct {
	Line    uint32
	Message string
	Type    byte
	Value   interface{}
}

func (Error) Error

func (this Error) Error() string

type SyntaxError

type SyntaxError struct {
	Message string
	In      string
}

func (SyntaxError) Error

func (this SyntaxError) Error() string

type Token

type Token struct {
	Type  string
	Value string
	Line  uint32
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL