Skip to content

Commit f8179f6

Browse files
committed
python, run
.ㅇ
1 parent 1895877 commit f8179f6

15 files changed

+759
-20
lines changed

cpp.json

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
"true": "true",
1010
"false": "false",
1111

12+
"then": [],
13+
"run": [
14+
"g++ {{file}}.cpp -std=c++17 -o repp_{{file}}",
15+
"repp_{{file}}",
16+
"del repp_{{file}}"
17+
],
18+
1219
"bracket": {
1320
"block_open": "{",
1421
"block_close": "}",

cpp/language.json

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"name": "C++",
3+
"ext": "cpp",
4+
"h_ext": "hpp",
5+
6+
"line_end": ";",
7+
8+
"ident": "{{name}}",
9+
"true": "true",
10+
"false": "false",
11+
12+
"bracket": {
13+
"block_open": "{",
14+
"block_close": "}",
15+
16+
"value_open": "(",
17+
"value_close": ")",
18+
19+
"dotarray_open": "std::vector<int>({",
20+
"dotarray_close": "})",
21+
22+
"list_open": "{",
23+
"list_close": "}"
24+
},
25+
"operator": {
26+
"commas" : ",",
27+
28+
"pointer" : "(&({{exp}}))",
29+
"de_pointer" : "(*({{exp}}))",
30+
31+
"await" : "(({{exp}}).get())",
32+
"async" : "async({{exp}})",
33+
34+
"tenary": "(({{condition}})?({{l}}):({{r}}))",
35+
"assign" : "({{l}} = {{r}})",
36+
37+
"plus" : "({{l}} + {{r}})",
38+
"minus" : "({{l}} - {{r}})",
39+
40+
"bitor" : "({{l}} | {{r}})",
41+
"or" : "({{l}} || {{r}})",
42+
"bitand" : "({{l}} & {{r}})",
43+
"and" : "({{l}} && {{r}})",
44+
45+
"eq" : "({{l}} == {{r}})",
46+
"neq" : "({{l}} != {{r}})",
47+
48+
"pair" : "std::pair<std::string, std::string>({{l}}, {{r}})",
49+
50+
"property" : "{{object}}.{{name}}",
51+
"context" : "{{context}}::{{member}}",
52+
"index" : "{{exp}}[{{at}}]",
53+
54+
"else" : "({{l}} {{operator}} {{r}})"
55+
},
56+
"blocks": {
57+
"if": "if ({{exp}}) { {{block}} }",
58+
"else_if": "else if ({{exp}}) { {{block}} }",
59+
"else": "else { {{block}} }",
60+
61+
"while": "while ({{exp}}) { {{block}} }",
62+
"repeat": "for (int {{var}} = 0; {{var}}<{{time}}; {{var}}++) { {{block}} }",
63+
"foreach": "for ({{var}} : {{collection}}) { {{block}} }"
64+
},
65+
"calls": {
66+
"call": "{{method}}({{args}})",
67+
"call_wrapped": "{{method}}{{args}}",
68+
"method_call" : "{{object}}.{{call}}"
69+
},
70+
"types": {
71+
"deduce_type": "auto",
72+
"constant": "const",
73+
"void_type": "void",
74+
"integer": "int"
75+
},
76+
77+
"lambda_blocks": "[&]({{args}}){ {{block}} }",
78+
"to_lambdas": "[&](auto...pp){return ({{function}}({{args}}pp...));}",
79+
"lambdas": "[&]({{args}}){ return( {{exp}} ); }",
80+
81+
"returns": "return ({{exp}});",
82+
83+
"namespaces": "namespace {{name}} { {{block}} }",
84+
85+
"iter_vars": "{{type}} {{name}}",
86+
"arg_vars": "{{type}} {{name}}",
87+
88+
"header_guards": "#ifndef __{{token}}_H__\n#define __{{token}}_H__\n{{contents}}\n#endif",
89+
90+
"funcs": {
91+
"functions": "{{type}} {{name}}({{args}}) { {{block}} }",
92+
"constructor": "{{class}}({{args}}){ {{block}} }",
93+
"entry": "int main(){ {{block}} }"
94+
},
95+
"assigns": {
96+
"reference": {
97+
"const": "const {{type}}& {{name}} = {{ref}}",
98+
"make": "{{type}}& {{name}} = {{ref}}",
99+
"let": "{{type}}& {{name}} = {{ref}}",
100+
"instance": "{{type}}& {{name}} = {{ref}}"
101+
},
102+
"copy": {
103+
"const": "const {{type}} {{name}} = {{copy}}",
104+
"make": "{{type}}* {{name}} = new {{type}}({{copy}})",
105+
"let": "{{type}} {{name}} = {{copy}}",
106+
"instance": "{{type}} {{name}} = {{copy}}"
107+
},
108+
"construct": {
109+
"const": "const {{type}} {{name}}({{args}})",
110+
"make": "{{type}}* {{name}} = new {{type}}({{args}})",
111+
"let": "{{type}} {{name}}({{args}})",
112+
"instance": "{{type}} {{name}}({{args}})"
113+
}
114+
},
115+
"imports": {
116+
"import": "#include \"{{path}}.hpp\"\n",
117+
"stdlib": "#include \"worldlib.hpp\"\n",
118+
"library": "#include <{{path}}>\n",
119+
120+
"targetstdlibpath": "worldlib.hpp",
121+
"stdlibpath": "../libs/worldlib.hpp"
122+
},
123+
"classes": {
124+
"inherit": "class {{name}} : {{super}} { {{block}} };",
125+
"class": "class {{name}}{ {{block}} };"
126+
},
127+
"access": {
128+
"protected": "protected:",
129+
"private": "private:",
130+
"public": "public:"
131+
}
132+
}

libs/worldlib.py

+61-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,66 @@
1+
import time
2+
import sys
3+
14
def print(*a):
25
__builtins__["print"](*a, sep='', end='')
36
def println(*a):
47
__builtins__["print"](*a, sep='')
5-
8+
def input_line(q=''):
9+
return __builtins__["input"](q)
10+
def input(q=''):
11+
__builtins__["print"](q)
12+
ret = ''
13+
buf = ''
14+
while True:
15+
buf = sys.stdin.read(1)
16+
if buf != '\n' and buf != '\r' and buf != ' ' and buf != '\t':
17+
ret += buf
18+
break
19+
while True:
20+
buf = sys.stdin.read(1)
21+
if buf == '\n' or buf == '\r' or buf == ' ' or buf == '\t':
22+
break
23+
else :
24+
ret += buf
25+
return ret
26+
def tup(*a):
27+
return (*a,)
28+
def vec(*a):
29+
return [*a,]
30+
def until(st, ed):
31+
return range(st, ed+1)
32+
# sum
33+
# max
34+
def cat(c1, c2):
35+
return c1+c2
36+
def map(c, fn):
37+
return __builtins__["map"](fn, c)
38+
def each(c, fn):
39+
__builtins__["map"](fn, c)
40+
def fold(c, fn):
41+
ret = c[0]
42+
for e in c[1:]:
43+
ret = fn(ret, e)
44+
return ret
45+
def bfold(i, c, fn):
46+
ret = i
47+
for e in c:
48+
ret = fn(ret, e)
49+
return ret
50+
def filter(c, fn):
51+
return filter(fn, c)
52+
def integrate(c, fn):
53+
f = c[0]
54+
ret = [f]
55+
for e in c[1:]:
56+
f = fn(f, e)
57+
ret.insert(f)
58+
return ret
59+
def wait(times):
60+
time.sleep(times/1000)
61+
return times
62+
def get_time(fn):
63+
start = time.time();
64+
fn()
65+
println("{:.6} second(s) spent.".format(time.time()-start))
666
# Todo

nodejs.json

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"true": "true",
1010
"false": "false",
1111

12+
"then": [],
13+
"run": [
14+
"node {{file}}.js"
15+
],
16+
1217
"bracket": {
1318
"block_open": "{",
1419
"block_close": "}",

nodejs/language.json

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"name": "Node.Js",
3+
"ext": "js",
4+
"h_ext": "js",
5+
6+
"line_end": ";",
7+
8+
"ident": "{{name}}",
9+
"true": "true",
10+
"false": "false",
11+
12+
"bracket": {
13+
"block_open": "{",
14+
"block_close": "}",
15+
16+
"value_open": "(",
17+
"value_close": ")",
18+
19+
"dotarray_open": "[",
20+
"dotarray_close": "]",
21+
22+
"list_open": "[",
23+
"list_close": "]"
24+
},
25+
"operator": {
26+
"commas" : ",",
27+
28+
"pointer" : "[{{exp}}]",
29+
"de_pointer" : "{{exp}}[0]",
30+
31+
"await" : "(await {{exp}})",
32+
"async" : "(async {{exp}})",
33+
34+
"tenary": "(({{condition}})?({{l}}):({{r}}))",
35+
"assign" : "({{l}} = {{r}})",
36+
37+
"plus" : "({{l}} + {{r}})",
38+
"minus" : "({{l}} - {{r}})",
39+
40+
"bitor" : "({{l}} | {{r}})",
41+
"or" : "({{l}} || {{r}})",
42+
"bitand" : "({{l}} & {{r}})",
43+
"and" : "({{l}} && {{r}})",
44+
45+
"eq" : "({{l}} == {{r}})",
46+
"neq" : "({{l}} != {{r}})",
47+
48+
"pair" : "{ {{l}} : {{r}} }",
49+
50+
"property" : "{{object}}.{{name}}",
51+
"context" : "{{context}}.{{member}}",
52+
"index" : "{{exp}}[{{at}}]",
53+
54+
"else" : "({{l}} {{operator}} {{r}})"
55+
},
56+
"blocks": {
57+
"if": "if ({{exp}}) { {{block}} }",
58+
"else_if": "else if ({{exp}}) { {{block}} }",
59+
"else": "else { {{block}} }",
60+
61+
"while": "while ({{exp}}) { {{block}} }",
62+
"repeat": "for (let {{var}} = 0; {{var}}<{{time}}; {{var}}++) { {{block}} }",
63+
"foreach": "for ({{var}} of {{collection}}) { {{block}} }"
64+
},
65+
"calls": {
66+
"call": "{{method}}({{args}})",
67+
"call_wrapped": "{{method}}{{args}}",
68+
"method_call" : "{{object}}.{{call}}"
69+
},
70+
"types": {
71+
"deduce_type": "let",
72+
"constant": "",
73+
"void_type": "",
74+
"integer": "",
75+
76+
"_constant": "const",
77+
"_void_type": "void",
78+
"_integer": "Number"
79+
},
80+
81+
"lambda_blocks": "({{args}})=>{{ {block} }}",
82+
"to_lambdas": "(...pp)=>({{function}}({{args}}pp...))",
83+
"lambdas": "({{args}}) => ( {{exp}} )",
84+
85+
"returns": "return ({{exp}});",
86+
87+
"_namespaces": "namespace {{name}} { {{block}} }",
88+
89+
"iter_vars": "let {{name}}",
90+
"arg_vars": "{{name}}",
91+
92+
"header_guards": "{{contents}}",
93+
94+
"funcs": {
95+
"functions": "function {{name}}({{args}}) { {{block}} }",
96+
"constructor": "constructor({{args}}){ {{block}} }",
97+
"entry": "(async ()=>{ {{block}} })();"
98+
},
99+
"assigns": {
100+
"reference": {
101+
"const": "const {{name}} = {{ref}}",
102+
"make": "let {{name}} = {{ref}}",
103+
"let": "let {{name}} = {{ref}}",
104+
"instance": ""
105+
},
106+
"copy": {
107+
"const": "const {{name}} = {{copy}}",
108+
"make": "let {{name}} = new {{type}}({{copy}})",
109+
"let": "let {{name}} = {{copy}}",
110+
"instance": ""
111+
},
112+
"construct": {
113+
"const": "const {{type}} {{name}}({{args}})",
114+
"make": "let {{name}} = new {{type}}({{args}})",
115+
"let": "let {{name}} = new {{type}}({{args}})",
116+
"instance": ""
117+
}
118+
},
119+
"imports": {
120+
"import": "const {{path}} = require('{{path}}');\n",
121+
"stdlib": "const{print,println,input,input_line,static_input,static_input_line,tup,vec,until,sum,max,map,cat,each,fold,bfold,integrate,filter,wait,get_time,make_string,stoi,string,vector,i1,i2,i4,i8,u1,u2,u4,u8,f4,f8,ci1,ci2,ci4,ci8,cu1,cu2,cu4,cu8,cf4,cf8}=require('./worldlib');\n",
122+
"library": "const {{path}} = require('{{path}}');\n",
123+
124+
"targetstdlibpath": "worldlib.js",
125+
"stdlibpath": "../libs/worldlib.js"
126+
},
127+
"classes": {
128+
"inherit": "class {{name}} extends {{super}} { {{block}} }",
129+
"class": "class {{name}}{ {{block}} }"
130+
},
131+
"access": {
132+
"protected": "",
133+
"private": "",
134+
"public": "",
135+
136+
"_protected": "protected",
137+
"_private": "private",
138+
"_public": "public"
139+
}
140+
}

php.json

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"true": "true",
1010
"false": "false",
1111

12+
"then": [],
13+
"run": [
14+
"php {{file}}.php"
15+
],
16+
1217
"bracket": {
1318
"block_open": "{",
1419
"block_close": "}",

0 commit comments

Comments
 (0)