-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverNetworkScriptingLanguage.txt
184 lines (137 loc) · 2.72 KB
/
serverNetworkScriptingLanguage.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
SnS - sNs
programming language for deplaying web apps
can bundle apis from multiple programming languages
just in time compiler
easy syntax
works with frameworks
easy debugging
features:
routing
c-compile (fast runtime)
server-settings
modules
typed
dynamic types
use functioncalls from different languages
structure:
main.sns{
IP-config - ip, ssl
User-cap
main route(/)
}
- modules{
route(local)
calculations
can use different languages
retval(json or html)
}
types:
string
int
float
bool
char
user
function
html
json
empty
any
signed
unsigned
typedef
Syntax:
to import modules:
Import Name from "path"
application header:
***
typedef route : html ? json
info
***
c style comments
---------------
declare var:
var_name : float ? char ? bool
var_name = 5
var_name += 2
// type(var_name) = float
var_name += "p" // error
var_name : string
// type(var_name) = float
var_name += "p" // type(var_name) = string
// contains "7p"
----------------------------
declare function:
// if there is only one value then it is the return type and all params are ignored
func : function[input, return] -> {
do something
return something
}
----------------------------
for loop:
// can be functions like function[i:int32, int32] -> {return i+1}
new::for(i: int32 = 0, i<20, i+=1) -> {
do something
break
}
----------------------------
get function from file:
func : function[input, return] -> new::function(lang, path, fname)
----------------------------
route:
Route : function[route] -> new::route(path) -> {
do something
return new::html("ok")
}
----------------------------
f-string:
"{var}, {new_var: string ? int32}"
----------------------------
demo:
***
DEBUG_MODE(True)
FORCE_SSL(True)
USE_SSL(path_to_certificate)
MAX_CONNECTIONS(10)
HTML_PATH("/static/html")
JS_PATH("/static/javascript")
typedef route : html ? json
***
main: function[bool] -> {
Route : function[route] -> new::route("/") -> {
extend HomePage
extend Api
}
}
add: function[input: float, float] -> {
return input + 1
}
Api: function[route] -> new::route("/api/{number: int64 ? float}") -> {
new_number : float = number
new_number *= 2
new_number = add(new_number)
return new::json(new_number)
}
HomePage: function[route] -> new::route("/") -> {
return new::html("./index.html")
}
./static/html/index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="module" src="/main.js">
</body>
</html>
./static/javascript/main.js:
async main = () => {
const val = await fetch("/api/10");
console.log(val);
}
main();
-----------------------------