Zala

所属分类:编程语言基础
开发工具:Python
文件大小:0KB
下载次数:0
上传日期:2021-08-04 17:47:48
上 传 者sh-1993
说明:  用于编程语言Jam的Zala编程语言
(Zala Programming Language for the Programming Language Jam)

文件列表:
POST.md (1768, 2021-08-04)
example.zl (0, 2021-08-04)
main.py (1015, 2021-08-04)
poetry.lock (8849, 2021-08-04)
pyproject.toml (317, 2021-08-04)
src/ (0, 2021-08-04)
src/__init__.py (51, 2021-08-04)
src/__pycache__/ (0, 2021-08-04)
src/__pycache__/repl.cpython-38.pyc (419, 2021-08-04)
src/baseparse/ (0, 2021-08-04)
src/baseparse/__init__.py (70, 2021-08-04)
src/baseparse/__pycache__/ (0, 2021-08-04)
src/baseparse/__pycache__/__init__.cpython-38.pyc (134, 2021-08-04)
src/baseparse/__pycache__/assigner.cpython-38.pyc (9500, 2021-08-04)
src/baseparse/__pycache__/builtins.cpython-38.pyc (1388, 2021-08-04)
src/baseparse/__pycache__/errors.cpython-38.pyc (4160, 2021-08-04)
src/baseparse/__pycache__/optimizer.cpython-38.pyc (1371, 2021-08-04)
src/baseparse/__pycache__/parser.cpython-38.pyc (1385, 2021-08-04)
src/baseparse/__pycache__/transformer.cpython-38.pyc (13881, 2021-08-04)
src/baseparse/assigner.py (12364, 2021-08-04)
src/baseparse/builtins.py (728, 2021-08-04)
src/baseparse/errors.py (3408, 2021-08-04)
src/baseparse/parser.py (1196, 2021-08-04)
src/baseparse/transformer.py (11442, 2021-08-04)
src/baseparse/zala.lark (4883, 2021-08-04)
src/lib/ (0, 2021-08-04)
src/lib/__init__.py (75, 2021-08-04)
src/lib/__pycache__/ (0, 2021-08-04)
src/lib/__pycache__/__init__.cpython-38.pyc (257, 2021-08-04)
src/lib/__pycache__/dirlib.cpython-38.pyc (1108, 2021-08-04)
src/lib/__pycache__/flasklib.cpython-38.pyc (1842, 2021-08-04)
src/lib/__pycache__/jsonlib.cpython-38.pyc (444, 2021-08-04)
src/lib/__pycache__/pakrat.cpython-38.pyc (815, 2021-08-04)
src/lib/__pycache__/randnum.cpython-38.pyc (528, 2021-08-04)
src/lib/__pycache__/request.cpython-38.pyc (794, 2021-08-04)
src/lib/dirlib.py (546, 2021-08-04)
src/lib/flasklib.py (1643, 2021-08-04)
... ...

# Welcome to Zala's Manual ## Notice: This repository (Zala) is archived, with no future plans. ___ Welcome to Zala! Zala is a general-purpose, fast, and lightweight programming langauge with unique syntax. Start with a basic program: ``` print("Hello World!"); ``` This prints out "Hello World" to the console, similar to python. You can also assign variables. ``` myvar is 7; ``` Notice how we don't use the `=` sign, but use `is` instead. This syntax may look odd but it's a unique alternative for using `==` in `if` statements. Speaking of if statements, here is an example of an if statement being used: ``` if 10 > 5 { print("10 is greater than 5!"); } else { print("10 is not greater than 5!"); } ``` You see, Zala has a unique attribute where an entire program can be on one line. It achieves that by completely ignoring any form of whitespace in your code. This is why `;`s are required in all single statement, but can be ignored in block statements such as `if` This example prints "10 is greater than 5!" if 10 is greater than 5, else it will print "10 is not greater than 5!" While statements have the same attributes as `if` but are also quite different. For one, they do not have an `else` function. ``` while 10 > 5 { if 10 < 5 { break; } } ``` They can also be stopped even though the statement is still true. It is possible to loop indefinitely with `while True`. You can loop for a limited amount with `loop` and `iterate`. ``` loop 5 { print("Hi!"); } ``` ``` iterate range(1, 5) with x { print(x); } ``` Now, these functions may seem similar, but they are not. `loop` does not store any information to a variables and executes much faster than `iterate`. Meanwhile, `iterate` can iterate any iterables such as a list or a dictionary. It also stores variable information. `loop 5` is highly suggested over `iterate range(0, 5)` because it operates much quicker. If you need to get the current loop number, you'll need to use `iterate`. Now let's get into the spicy stuff, Classes and Functions! ``` class myClass { myvar is 2; def myfunc() { return 2; } class myOtherClass { myvar is 2; } } ``` Classes, when created, are a bit similar to objects but are also different. You cannot create objects, but you can edit class attributes by assigning variables which can be accessed in your program. Objects are similar to classes. How they work is that they clone the class without providing refrence to it. This means that all attributes of the class are editable. ``` class customobj { attr is void; def init(obj) { obj.attr is 5; return obj; } def run(obj) { print(obj.attr); } } ``` There are currently no methods to modify how your class works. Things such as initialization must be called directly by the user. (special methods comming soon). ``` myobj is customobj() myobj.init(); myobj.run(); #You could also do this customobj.run(myobj); ``` **Dont do these**: ``` #big nono myobj is customobj().init(); ``` This is not supported for now. You'll need to load a init method after. This is because `customobj` has not been copied properly. You can also import other files and load them as a class. Then you can access attributes. ``` import myClass print(myClass.myfunc()); ``` Some Zala Py-Extenstions allow you to import classes from the web. Zala's built-in package manager lets you import code snippets directly from the web. ``` import pakrat pakrat.import("hello_world"); hello_world.hello ``` While useful, it is not suboptimal and is reliant on a internet connection. Future Pakrat implementations will expand to installing larger and optimized Zala code. That's it for the Manual. There are features I may have missed, and some other things. There are built-in libs written in python, so if you would like refrence to them, please check `src/lib/README.md`

近期下载者

相关文件


收藏者