Next-GEN Confguration Template Generation Language

Overview

Sap lang

yet another configuration oriented language

name comes from Sapphire which is the birthstone of september

Language Feature

the last expr of the scope is the return value also the last expr of the file is the return value of the file

variable decl

variable is scoped

a = 10
b = 20
c = "string"
d = 'c' # TODO: number in char 

comment

TODO

# single lined comment

###BEGIN
multi
lined 
comment
###END

literals

10 # number
'c' # number in char literal
"string" # string

##RAW
raw string
raw string
##

# TODO
#INCLUDE "path" # also raw string

true # bool
[] # array
{a:10,b:20} # object
(){null} # closure

# fast object
a = 10
{a} # semantic: {a:a}

strong type?

YES!

type definision

type typed = (name){{name}}

tyvar = typed(name)

type enum = 
    | name: (name){{name}}
    | aged: (name,age){{name,age}}
    | full: (name,age,location){{name,age,location}}

tyvar = enum(name,age,location)
# or
tyvar = enum::full(name,age,location)

# change value
tyvar[name] = "string"

# to validate if is a variant of an enum

TODO

function

# auto typed
(a){a}

# typed
(a:String){a}

pre defined function

  • log # more or less println
  • octor
  • actor
  • is # try to match object enntrys with function argument name
  • assert
  • intersect union diff cross
  • innerjoin joinon

branch

if expr:bool {

} else {

}

if
    | expr:bool {}
    | expr:bool {}
    | expr:bool {}
else {}

looping

for a in [] {

}

for a in range(0,10){

}

function call

f = (a:number) => number {a.s}
g = (a:string) => number {a.n?}

f(10) # "10"
g("10") # 10
f.g.f.g.f.g.f(10) # 10 . is bind

id = f.g

error handling

a = null
a # return file end as object
# so calling a.o
# {}

# another file
b = err("an error")
b
# error in line 1 b: an error

b = err("an error")? # cast error to null
b

b = if maybeerr? == null {
    1
}else{
    maybeerr?
}

dot sematic

a.b # a: Object b:Any => index
a.b # a: function b:function => bind
a.b() # a: not function b: function => bind first
a().b() # a: function call with less param b: function call with multiple param but less one => bind first
a.typename() # cast 

function semantic

function is curried by default

Example File

url = ARGS.url.orelse("https://lemonhx.moe")
port = ARGS.url.orelse(8080)

type Request = (post_name,post_id){
    {
        type: "POST"
        url: "{{url}}/{{post_name}}/{{post_id}}",
        port,
    }
};

Request("blogexample",10)

then you can use like

sap example.sap -serializer json url "https://google.com" -o stdout

{
    "type":"POST",
    "url":"https://google.com/blogexample/10",
    "port":8080
}

sap example.sap -serializer yaml url "https://baidu.com" -o stdout

type: POST
url: 'https://google.com/blogexample/10'
port: 8080
Comments
  • Parser should throw panic

    Parser should throw panic

    > a(a(1)(2)(3)
    Expr(Ident(["a"]))
    TypeCheckContext { parent: None, free_var: {"a": Function([Number, Number], Number), "add": Function([Number, Number], Number)}, alias: {} }
    type: Ok(Function([Number, Number], Number))
    value: Ok(Function(["a", "b"], {}, Block([Call(Ident(["add"]), [Ident(["a"]), Ident(["b"])])])))
    
    bug 
    opened by LemonHX 1
  • [BUG] Possible Memory Leakage

    [BUG] Possible Memory Leakage

    When I executing the cargo fuzz, it comes with

    Indirect leak of 2 byte(s) in 1 object(s) allocated from:
        #0 0x559e05eeb94d  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x25394d)
        #1 0x559e06751414  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0xab9414)
        #2 0x559e060db7e1  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x4437e1)
        #3 0x559e062249f1  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x58c9f1)
        #4 0x559e061c8d87  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x530d87)
        #5 0x559e06141399  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x4a9399)
        #6 0x559e06423fe7  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x78bfe7)
        #7 0x559e0613f72e  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x4a772e)
        #8 0x559e05f1e651  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x286651)
        #9 0x559e065d8e45  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x940e45)
        #10 0x559e0661e4a6  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x9864a6)
        #11 0x559e0661e97a  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x98697a)
        #12 0x559e0661e03c  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x98603c)
        #13 0x559e065ddc8b  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x945c8b)
        #14 0x559e065d871c  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x94071c)
        #15 0x559e065e44ff  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x94c4ff)
        #16 0x559e065e543c  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x94d43c)
        #17 0x559e065e5ab7  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x94dab7)
        #18 0x559e06610ade  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x978ade)
        #19 0x559e065de1e3  (/home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1+0x9461e3)
        #20 0x7fdae420f09a  (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    

    and I addr2line the specific line:

    victoryang@epyc:~/sap-lang$ addr2line -e /home/victoryang/sap-lang/fuzz/target/x86_64-unknown-linux-gnu/debug/fuzz_target_1  0x78bfe7
    /home/victoryang/sap-lang/src/state/std/mod.rs:177
    
    bug 
    opened by victoryang00 1
  • [FEATURE] Implement Inheritance for type

    [FEATURE] Implement Inheritance for type

    for example in typescript

    interface XXX {
        xxx: number,
    }
    interface YYY extends XXX {
        yyy: number,
    }
    

    which is very usefull when we try to describe web API such as M$DAP

    type xxx = (yyy : number){ xxx }
    type yyy : xxx = (yyy) { yyy }
    

    then the type of yyy will be object {yyy : number, xxx : number} it is desugared as

    yyy = (xxx : xxx) (yyy : number) -> yyy object_append(xxx, { yyy })
    
    enhancement 
    opened by LemonHX 0
  • [FEATURE] Implement enum and `is` statement for checking the variant

    [FEATURE] Implement enum and `is` statement for checking the variant

    Is your feature request related to a problem? Please describe. enum is not implemented and still need a proper statement for checking which variant is this enum

    Describe the solution you'd like implement it

    enhancement 
    opened by LemonHX 0
  • Implement Polymorphism

    Implement Polymorphism

    draft:

    a:int = 10
    a:string = "string"
    

    it will not throw type fail exception, instead a will be two instance one is typed int the other will be typed string

    f = (a:int) -> int a
    f = (a:string) -> string a
    

    f now also has two instance

    b:int = f(a) # will use the instance int -> int
    b:string = f(a) # will use the instance string -> string
    
    b = f(a)
    

    but what if the type of b is not specified? for simplicity just use the first type it matches.

    enhancement 
    opened by LemonHX 1
Releases(alpha)
Owner
Sap-Lang
Sap-Lang
Your next config manager, written in rust

confy Your next config manager, written in rust Based on uncomfyhalomacro/hmph but written for .ini files instead of json :) Getting started Take a lo

Krishna Ramasimha 2 Nov 3, 2021
Kusion Configuration Language (KCL) is an open source configuration language mainly used in Kusion Stack

Kusion Configuration Language (KCL) is an open source configuration language mainly used in Kusion Stack. KCL is a statically typed language for configuration and policy scenarios, based on concepts such as declarative and Object-Oriented Programming (OOP) paradigms.

KusionStack 264 Dec 30, 2022
[Proof of Concept] Embedded functional scripting language with YAML ¯\_(ツ)_/¯

[YAML, fun] Just an experimental project implementing embedded functional scripting language based on YAML syntax. API docs for the standard library:

Arijit Basu 12 Aug 15, 2022
🌽 A simple and pain-free configuration language.

?? Corn A simple and pain-free configuration language. Corn has been designed using inspiration from JSON and Nix to produce a language that's easy an

Jake Stanger 3 Nov 28, 2022
Next-GEN Confguration Template Generation Language

Sap lang yet another configuration oriented language name comes from Sapphire which is the birthstone of september Language Feature the last expr of t

Sap-Lang 12 Aug 8, 2022
A formal, politely verbose programming language for building next-gen reliable applications

vfpl Pronounced "Veepl", the f is silent A politely verbose programming language for building next-gen reliable applications Syntax please initialize

VFPL 4 Jun 27, 2022
The next gen ls command

LSD (LSDeluxe) Table of Contents Description Screenshot Installation Configuration External Configurations Required Optional F.A.Q. Contributors Credi

Pierre Peltier 9k Jan 2, 2023
LSD (LSDeluxe) - The next gen ls command

LSD (LSDeluxe) Table of Contents Description Screenshot Installation Configuration External Configurations Required Optional F.A.Q. Contributors Credi

Pierre Peltier 8.9k Jan 1, 2023
xrd a next-gen server controller for TrackMania Forever and Nations ESWC

xrd is a next-gen server controller for TrackMania Forever and Nations ESWC that is designed to be hassle-free and easily updatable (with a bus factor of 0).

Autumn Leaf 6 Mar 26, 2022
Quickwit - the next-gen search & analytics engine built for logs

Quickwit is the next-gen search & analytics engine built for logs. It is a highly reliable & cost-efficient alternative to Elasticsearch.

Quickwit OSS 2.9k Dec 30, 2022
The true next-gen L7 minecraft proxy and load balancer. Built in Rust.

Lure The true next-gen L7 minecraft proxy and load balancer. Built in Rust, Tokio and Valence. Why? Rust is a powerful programming language and a grea

Sammwy 67 Apr 16, 2023
Validity is a next-generation, deduction-based language for formally verified, context-aware, autonomous & reactive smart contracts.

Validity Language Validity is a next-generation, deduction-based language for formally verified, context-aware, autonomous & reactive smart contracts.

Tempest Labs 4 Nov 11, 2022
An experimental next-generation Electron-based text editor

Attention: GitHub has decided not to move forward with any aspect of this project. We'll archive the repository in case anybody finds value here, but

Atom Archive 8.5k Dec 26, 2022
MASQ Network 121 Dec 20, 2022
A next-generation music player and manager

ouverture A next-generation music player and manager Very much at Work-In-Planning stage now Planned features GUI (localizable) Backend (something lik

Michael B 9 Nov 17, 2022
Nextest is a next-generation test runner for Rust.

nextest Nextest is a next-generation test runner for Rust. For more, check out the website. This repository contains the source code for: cargo-nextes

null 1.3k Jan 8, 2023
Next-generation, type-safe CLI parser for Rust

Next-generation, type-safe CLI parser for Rust

0918nobita 19 Jul 20, 2022
Next-generation implementation of Ethereum protocol ("client") written in Rust, based on Erigon architecture.

?? Martinez ?? Next-generation implementation of Ethereum protocol ("client") written in Rust, based on Erigon architecture. Why run Martinez? Look at

Arthur·Thomas 23 Jul 3, 2022
Privaxy Next generation tracker and advertisement blocker

Privaxy is a MITM HTTP(s) proxy that sits in between HTTP(s) talking applications, such as a web browser and HTTP servers, such as those serving websites.

Pierre Barre 752 Jan 7, 2023
Next-generation developer-first NoSQL database

Next-generation developer-first NoSQL database. AnnaDB moves familiar programming languages' patterns into the databases world to solve the problem of

Roman Right 40 Dec 28, 2022