ez

所属分类:编程语言基础
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2022-08-17 22:28:14
上 传 者sh-1993
说明:  ez编程语言
(ez programming language)

文件列表:
CODE_OF_CONDUCT.md (5226, 2023-10-01)
CONTRIBUTING.md (1004, 2023-10-01)
LICENSE (1061, 2023-10-01)
ast/ (0, 2023-10-01)
ast/ast.go (7589, 2023-10-01)
ast/ast_test.go (604, 2023-10-01)
cmd/ (0, 2023-10-01)
cmd/cmd.go (542, 2023-10-01)
evaluator/ (0, 2023-10-01)
evaluator/builtins.go (2896, 2023-10-01)
evaluator/evaluator.go (9438, 2023-10-01)
evaluator/evaluator_test.go (11398, 2023-10-01)
go.mod (46, 2023-10-01)
lexer/ (0, 2023-10-01)
lexer/lexer.go (3172, 2023-10-01)
lexer/lexer_test.go (2810, 2023-10-01)
main.go (287, 2023-10-01)
object/ (0, 2023-10-01)
object/environment.go (582, 2023-10-01)
object/object.go (3548, 2023-10-01)
object/object_test.go (1513, 2023-10-01)
parser/ (0, 2023-10-01)
parser/parser.go (10527, 2023-10-01)
parser/parser_test.go (23896, 2023-10-01)
repl/ (0, 2023-10-01)
repl/repl.go (1490, 2023-10-01)
test.ez (358, 2023-10-01)
token/ (0, 2023-10-01)
token/token.go (1027, 2023-10-01)

ez

ez

interpreted programming language

> pronounced as it's spelled because it's easy a functional programming language, with first class functions and closures support. ## features - support the usual data types like strings, booleans, integers, hashes, arrays, and nil - support the usual operators like `+`, `-`, `*`, `/`, `==`, `!=`, `<`, `>`, and `!` - `!` is the logical negation operator - `==` is the equality operator - `!=` is the inequality operator - `<` is the less than operator - `>` is the greater than operator - `+` is the addition operator - `-` is the subtraction operator (unary minus) - `*` is the multiplication operator - `/` is the division operator - support the usual flow control operators like `if`, `else`, `let` and `ret` - `if` is the conditional operator - `else` is the else operator - `let` is the let operator - `ret` is the return operator (can be omitted) - semi-colons are optional - for syntax highlighting, use the `ez-language-support` [extension](https://marketplace.visualstudio.com/items?itemName=OmarBelghaouti.ez-language-support) ## syntax - print a value: `print(value)` - print a value and a newline: `println(value) - print a newline: `println()` - `let` is used to declare a variable: `let variable = value` - `if` is used to declare a conditional: `if (condition) { // do something }` - `else` is used to declare an else block: `else { // do something }` - `ret` is used to return a value: `ret value` - `f` is used to declare a function: `f(name) { // do something }` - arrays are declared with `[]`: `[1, 2, 3]` - hashes are declared with `{}`: `{ "key": "value" }` - `nil` is used when a value is not present: `nil` sample code: ``` println("hello world") let x = 1; let y = 2 let z = x + y; print(z); let a = "hello"; let b = "world"; let c = a + b; print(c); if (x == y) { print("x is equal to y"); } else { print("x is not equal to y"); } let d = if (x == y) { "x is equal to y" } else { "x is not equal to y" }; print(d); let add = f(x, y) { ret x + y; }; print(add(x, y)); let mul = f(x, y) { x * y; }; print(mul(x, y)); let subResult = f(x, y) { x - y; }(x, y); print(subResult); let mulByFn = f(x, otherFn) { ret x * otherFn(x) }; let res = mulByFn(2, f(x) { x + 2; }); print(res); let arr = [1, 2, 3, add(x, y), true]; print(arr[0]); let hash = { "key": "value", "key2": "value2" }; print(hash["key"]); ``` - there are some useful bultin functions for arrays: ``` let a = [1, 2, 3, 4, 5]; let b = push(a, 6); // [1, 2, 3, 4, 5, 6] let c = tail(a); // [2, 3, 4, 5] let d = first(a); // 1 let e = last(a); // 5 print(len(a)); // 5 ``` - `len` is used to get the length of an array or a string: `len(a)` ## run the interpreter ```sh go run main.go ``` and start typing in the console - you can run it on a file: `go run main.go -file test.ez`

近期下载者

相关文件


收藏者