[go: up one dir, main page]

Skip to content

a toy programming language written in c, u can write & run your script by uyghur, uzbek, turkish, kazakh language grammars ...

Notifications You must be signed in to change notification settings

Atypicalim/UyghurScript

Repository files navigation

UyghurScript

0. description

a toy script interpreter written in c, u can write & run your script written in uyghur language grammar with it ...

  • read documents for move informations

  • run ./release/uyghur.exe to get help content

  • cick ./release/yuguresh.exe to run raylib example

example

1. multiple langauge

2. highlight & translating

  • vscode extension for highlighting and autocompleting.

  • language converter for translating different languages.

3. supported features

# a dynamic var
variable m value empty made

# a static var
variable n value num made

# set val
m = "salam dunya!"

# free val
m value empty made

# type error
n = "sinaq..."
variable m value "yezish" made

# convert to func
m value worker made
command m write

# convert to bool
m value logic made
command m write
# arthimetic
x = 1 + 2 # 3
x = 1 + 2 * 3 # 9
x = 1 + (2 * 3) # 7
x = 64 ^ (1 / 3) # 4

# bitwise
x = 3 & 2 # 2
x = 3 | 2 # 3
x = 3 ~ 2 # 1

# boolean
x = right & wrong # wrong
x = right | wrong # right
x = right ~ wrong # right

# logic
x = "2" ? 2 # false
x = 2 < 3 # true
x = "ab" > "ac" # false 

# string
x = "ab" + "cd" # abcd
x = "ab" * 2 # abab

# checking
x = 10 % 7 # 3
x = 10 % num # true
x = 10 % empty # false
# read a val
command a read

# print a val
command a write
if 0 then
    command "if" write
elif right then
    command "elif" write
else
    command "else" write
finish
variable i value 0 made
while i < 9 then
    command "while\n" write
    i = i + 1
finish
speaded "abc..." variable i v become
    command i write
    command "\t" write
    command v write
    command "\n" write
finish
# a func with two args
worker f variable x y content
    variable t value 0 made
    t = x + y
    result t returned
finish

# call func and receive rsp
worker f with 10 20 applied and r received

# print the val received
command r write
# a closure maker func
worker make content

    # a var in env
    variable x value 0 made
    variable r value 0 made

    # a func & env
    worker func variable a content
        command x write # 0
        command y write # 200
        r = r + a
        result r returned
    finish

    # ret the closure func
    result func returned
finish

# some vars in mod
variable x value 100 made
variable y value 200 made

# make closure
worker make applied and f received

# print 11
worker f with 11 applied and r received
command r write

# print 22
worker f with 11 applied and r received
command r write
variable x value empty made

# try block
exception e become
    x = 3 / 0
finish

# catch block
if e then
    command "exception:\n" write
    command e write
    command "\n" write
else
    command "successful!\n" write
finish
#  declare a list
t value list made
#  declare a dict
s value dict made

# generate a list
t = [11, 22, "abc"]
# generate a dict
s = {a: "aa", b: "bb", c: 123}

# put a num key
@t:1 = 456
# put a str key
@s:k = "abc"
# put a var key
@s{v} = val

# alias: this: - bu, module: + bolek, global: * global

# check type
b = t % list
# an assister with one argument
assister X variable x content
    @-:x = x
finish

# assister func
worker @X:test content
    command "X.test...\n" write
finish

# a creator with one arguments
creator Y variable y content
    creator X with "arg xxx ...\n" applied 
    @-:y = y
finish

# creator func
worker @Y:test content
    worker @X:test applied
    command "Y.test...\n" write
finish

# call creator using an assister and receive object
creator Y with "arg yyy ...\n" applied and r received

# print the object val received
command @r:x write # arg xxx ...
command @r:y write # arg yyy ...

# call creator func which calling assister func inside
worker @r:test applied
# X.test...
# Y.test...

# check obj is created by or assisted by
if r % X then
    command "yes\n" write
finish
# yes
# other.xx
variable x value "other..." made

# main.xx
worker ekirish with "../other.xx" applied and m received
command @m:x write

# run the program
`.uyghur.exe ./main.xx`

# get the rsp
other...

4. supported libraries

5. bridge interfaces

u can get the bridge objet and communicate between c and script, just check bridge.c for more information

  • register a box to script (with some keys of different types)
Bridge_startBox(bridge);
Bridge_bindBoolean(bridge, "bol", false);
Bridge_bindNumber(bridge, "num", 123);
Bridge_bindString(bridge, "str", "abc...");
Bridge_register(bridge, "boxName"); // NULL
  • call script function from c (giving one argument and receiving result)
Bridge_startFunc(bridge);
Bridge_pushValue(bridge, Value_newNumber(123));
Bridge_pushValue(bridge, Value_newString(""));
Bridge_call(bridge, "funcName");
char resultType = Bridge_topType(bridge);
void *resultValue = Bridge_receiveValue(bridge);
  • register c function for script (receiving two argument and giving result)
void testFunc(Bridge *bridge)
{
    int a = Bridge_receiveNumber(bridge);
    char *b = Bridge_receiveString(bridge);
    Bridge_returnBoolean(bridge, false);
}
Bridge_startBox(bridge);
Bridge_bindNative(bridge, "testFunc", testFunc);
Bridge_register(bridge, NULL);

6. todo

  • libraries
  • ...

7. others

i am still working on it ...