nas-lang 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nas_lang-1.0.0/PKG-INFO +12 -0
- nas_lang-1.0.0/nas_lang/__init__.py +216 -0
- nas_lang-1.0.0/nas_lang/__main__.py +4 -0
- nas_lang-1.0.0/nas_lang/cli.py +221 -0
- nas_lang-1.0.0/nas_lang.egg-info/PKG-INFO +12 -0
- nas_lang-1.0.0/nas_lang.egg-info/SOURCES.txt +9 -0
- nas_lang-1.0.0/nas_lang.egg-info/dependency_links.txt +1 -0
- nas_lang-1.0.0/nas_lang.egg-info/entry_points.txt +2 -0
- nas_lang-1.0.0/nas_lang.egg-info/top_level.txt +1 -0
- nas_lang-1.0.0/setup.cfg +4 -0
- nas_lang-1.0.0/setup.py +19 -0
nas_lang-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nas-lang
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: NAS Language - Java power with Python easy yarn printing, by Kelly
|
|
5
|
+
Author: Edward Kelly
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: classifier
|
|
11
|
+
Dynamic: requires-python
|
|
12
|
+
Dynamic: summary
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import sys, math, random
|
|
3
|
+
variables = {}; functions = {}; BUILTINS = {}
|
|
4
|
+
|
|
5
|
+
def get_val(raw):
|
|
6
|
+
if raw is None: return ""
|
|
7
|
+
raw = str(raw).strip()
|
|
8
|
+
if raw == "": return ""
|
|
9
|
+
try:
|
|
10
|
+
if "." in raw and raw.replace(".","",1).lstrip("-").isdigit(): return float(raw)
|
|
11
|
+
if raw.lstrip("-").isdigit(): return int(raw)
|
|
12
|
+
except: pass
|
|
13
|
+
if raw in variables: return variables[raw]
|
|
14
|
+
try:
|
|
15
|
+
expr = raw
|
|
16
|
+
for k,v in sorted(variables.items(), key=lambda x: -len(x[0])):
|
|
17
|
+
if isinstance(v, (int,float)): expr = expr.replace(k, str(v))
|
|
18
|
+
if any(op in expr for op in ["+","-","*","/","%"]): return eval(expr)
|
|
19
|
+
except: pass
|
|
20
|
+
return raw
|
|
21
|
+
|
|
22
|
+
def builtin(name):
|
|
23
|
+
def wrap(fn):
|
|
24
|
+
BUILTINS[name]=fn; return fn
|
|
25
|
+
return wrap
|
|
26
|
+
|
|
27
|
+
@builtin("abs")
|
|
28
|
+
def b_abs(a): return abs(float(a))
|
|
29
|
+
@builtin("max")
|
|
30
|
+
def b_max(a,b): return max(float(a),float(b))
|
|
31
|
+
@builtin("min")
|
|
32
|
+
def b_min(a,b): return min(float(a),float(b))
|
|
33
|
+
@builtin("pow")
|
|
34
|
+
def b_pow(a,b): return math.pow(float(a),float(b))
|
|
35
|
+
@builtin("sqrt")
|
|
36
|
+
def b_sqrt(a): return math.sqrt(float(a))
|
|
37
|
+
@builtin("ceil")
|
|
38
|
+
def b_ceil(a): return math.ceil(float(a))
|
|
39
|
+
@builtin("floor")
|
|
40
|
+
def b_floor(a): return math.floor(float(a))
|
|
41
|
+
@builtin("round")
|
|
42
|
+
def b_round(a): return round(float(a))
|
|
43
|
+
@builtin("random")
|
|
44
|
+
def b_random(a=0,b=1): return random.uniform(float(a),float(b))
|
|
45
|
+
@builtin("len")
|
|
46
|
+
def b_len(a): return len(str(a))
|
|
47
|
+
@builtin("upper")
|
|
48
|
+
def b_upper(a): return str(a).upper()
|
|
49
|
+
@builtin("lower")
|
|
50
|
+
def b_lower(a): return str(a).lower()
|
|
51
|
+
@builtin("trim")
|
|
52
|
+
def b_trim(a): return str(a).strip()
|
|
53
|
+
@builtin("contains")
|
|
54
|
+
def b_contains(a,b): return str(b) in str(a)
|
|
55
|
+
@builtin("starts")
|
|
56
|
+
def b_starts(a,b): return str(a).startswith(str(b))
|
|
57
|
+
@builtin("ends")
|
|
58
|
+
def b_ends(a,b): return str(a).endswith(str(b))
|
|
59
|
+
@builtin("replace")
|
|
60
|
+
def b_replace(a,b,c): return str(a).replace(str(b),str(c))
|
|
61
|
+
@builtin("slice")
|
|
62
|
+
def b_slice(a,b,c=None):
|
|
63
|
+
s=str(a); start=int(float(b))
|
|
64
|
+
if c is None: return s[start:]
|
|
65
|
+
return s[start:int(float(c))]
|
|
66
|
+
|
|
67
|
+
def eval_condition(cond):
|
|
68
|
+
cond = cond.strip()
|
|
69
|
+
# replace vars with python literal
|
|
70
|
+
for k,v in sorted(variables.items(), key=lambda x: -len(x[0])):
|
|
71
|
+
if isinstance(v, str):
|
|
72
|
+
cond = cond.replace(k, f'"{v}"')
|
|
73
|
+
else:
|
|
74
|
+
cond = cond.replace(k, str(v))
|
|
75
|
+
# now bare words like Edward that remain and are not true/false/and/or/numbers -> make them string
|
|
76
|
+
import re
|
|
77
|
+
def repl_word(m):
|
|
78
|
+
w=m.group(0)
|
|
79
|
+
if w in ["and","or","True","False","==","!=","<",">","<=",">="]: return w
|
|
80
|
+
if w.replace(".","",1).isdigit(): return w
|
|
81
|
+
if w.startswith('"') and w.endswith('"'): return w
|
|
82
|
+
# if already quoted inside, skip
|
|
83
|
+
return f'"{w}"'
|
|
84
|
+
# find bare words not in quotes
|
|
85
|
+
cond = re.sub(r'\b[A-Za-z_][A-Za-z0-9_]*\b', repl_word, cond)
|
|
86
|
+
cond = cond.replace('""','"')
|
|
87
|
+
cond = cond.replace('""""','"')
|
|
88
|
+
# fix double quoted
|
|
89
|
+
cond = cond.replace('""Edward""','"Edward"')
|
|
90
|
+
try:
|
|
91
|
+
return bool(eval(cond))
|
|
92
|
+
except Exception as e:
|
|
93
|
+
# print(f"cond debug: {cond} -> {e}")
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
def call_func(tokens):
|
|
97
|
+
name=tokens[0]; raw_args=tokens[1:]; args=[]
|
|
98
|
+
for a in raw_args:
|
|
99
|
+
a=a.replace(",","").strip()
|
|
100
|
+
if a=="": continue
|
|
101
|
+
args.append(get_val(a))
|
|
102
|
+
if name in BUILTINS:
|
|
103
|
+
try: return BUILTINS[name](*args)
|
|
104
|
+
except Exception as e: return f"Error {name}: {e}"
|
|
105
|
+
if name in functions:
|
|
106
|
+
f=functions[name]; old=variables.copy()
|
|
107
|
+
for p,v in zip(f["params"], args): variables[p]=v
|
|
108
|
+
run_block(f["body"])
|
|
109
|
+
ret=None
|
|
110
|
+
for l in f["body"]:
|
|
111
|
+
if l.strip().startswith("return "): ret=get_val(l.strip()[7:]); break
|
|
112
|
+
variables.clear(); variables.update(old)
|
|
113
|
+
return ret
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
def run_block(block):
|
|
117
|
+
i=0
|
|
118
|
+
while i < len(block):
|
|
119
|
+
line=block[i].strip(); i+=1
|
|
120
|
+
if not line or line.startswith("//") or line.startswith("#"): continue
|
|
121
|
+
if line.startswith("if "):
|
|
122
|
+
cond=line[3:].split(" be")[0].strip()
|
|
123
|
+
truth=eval_condition(cond)
|
|
124
|
+
inner=[]; else_inner=[]; in_else=False; depth=1
|
|
125
|
+
while i < len(block):
|
|
126
|
+
l=block[i].strip(); i+=1
|
|
127
|
+
if l.startswith("if "): depth+=1
|
|
128
|
+
if l=="end":
|
|
129
|
+
depth-=1
|
|
130
|
+
if depth==0: break
|
|
131
|
+
if l=="else" and depth==1:
|
|
132
|
+
in_else=True; continue
|
|
133
|
+
if not in_else: inner.append(l)
|
|
134
|
+
else: else_inner.append(l)
|
|
135
|
+
if truth: run_block(inner)
|
|
136
|
+
else: run_block(else_inner)
|
|
137
|
+
continue
|
|
138
|
+
if line.startswith("for "):
|
|
139
|
+
header=line[4:].split(" be")[0].strip()
|
|
140
|
+
var_name=None; start=0; end=0
|
|
141
|
+
if " to " in header:
|
|
142
|
+
left,right=header.split(" to ")
|
|
143
|
+
left=left.strip()
|
|
144
|
+
if "=" in left:
|
|
145
|
+
var_name,start=[s.strip() for s in left.split("=")]
|
|
146
|
+
end=right.strip()
|
|
147
|
+
start=int(float(get_val(start))); end=int(float(get_val(end)))
|
|
148
|
+
body=[]; depth=1
|
|
149
|
+
while i < len(block):
|
|
150
|
+
l=block[i].strip(); i+=1
|
|
151
|
+
if l.startswith("for "): depth+=1
|
|
152
|
+
if l=="end":
|
|
153
|
+
depth-=1
|
|
154
|
+
if depth==0: break
|
|
155
|
+
body.append(l)
|
|
156
|
+
for v in range(start, end+1):
|
|
157
|
+
variables[var_name]=v
|
|
158
|
+
run_block(body)
|
|
159
|
+
continue
|
|
160
|
+
if line.startswith("ask "):
|
|
161
|
+
rest=line[4:].strip()
|
|
162
|
+
if "=" in rest:
|
|
163
|
+
var,prompt=rest.split("=",1)
|
|
164
|
+
var=var.strip(); prompt=prompt.strip()
|
|
165
|
+
ans=input(prompt+" ")
|
|
166
|
+
try:
|
|
167
|
+
if "." in ans: ans=float(ans)
|
|
168
|
+
else: ans=int(ans)
|
|
169
|
+
except: pass
|
|
170
|
+
variables[var]=ans
|
|
171
|
+
continue
|
|
172
|
+
if line.startswith("yarn "):
|
|
173
|
+
content=line[5:].strip()
|
|
174
|
+
tok=content.split()
|
|
175
|
+
if tok and (tok[0] in functions or tok[0] in BUILTINS):
|
|
176
|
+
val=call_func(tok)
|
|
177
|
+
if val is not None: print(val)
|
|
178
|
+
else:
|
|
179
|
+
print(get_val(content))
|
|
180
|
+
continue
|
|
181
|
+
if line.startswith("return "):
|
|
182
|
+
return get_val(line[7:])
|
|
183
|
+
if "=" in line:
|
|
184
|
+
n,v=line.split("=",1)
|
|
185
|
+
v=v.strip(); parts=v.split()
|
|
186
|
+
if parts and (parts[0] in BUILTINS or parts[0] in functions):
|
|
187
|
+
variables[n.strip()]=call_func(parts)
|
|
188
|
+
else:
|
|
189
|
+
variables[n.strip()]=get_val(v)
|
|
190
|
+
|
|
191
|
+
def run_file(path):
|
|
192
|
+
with open(path) as f:
|
|
193
|
+
lines=[l.rstrip("\n") for l in f]
|
|
194
|
+
i=0; cleaned=[]
|
|
195
|
+
while i < len(lines):
|
|
196
|
+
line=lines[i].strip(); i+=1
|
|
197
|
+
if line.startswith("func "):
|
|
198
|
+
header=line[5:].strip()
|
|
199
|
+
if " be" in header: header=header.split(" be")[0]
|
|
200
|
+
header=header.replace("(", " ").replace(")", " ").replace(",", " ")
|
|
201
|
+
parts=header.split()
|
|
202
|
+
fname=parts[0]; params=parts[1:]
|
|
203
|
+
body=[]
|
|
204
|
+
while i < len(lines):
|
|
205
|
+
l=lines[i].strip(); i+=1
|
|
206
|
+
if l=="end": break
|
|
207
|
+
body.append(l)
|
|
208
|
+
functions[fname]={"params":params,"body":body}
|
|
209
|
+
else:
|
|
210
|
+
cleaned.append(line)
|
|
211
|
+
run_block(cleaned)
|
|
212
|
+
|
|
213
|
+
if len(sys.argv)<2:
|
|
214
|
+
print("Usage: nas file.yarn")
|
|
215
|
+
else:
|
|
216
|
+
run_file(sys.argv[1])
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import sys, math, random
|
|
3
|
+
variables = {}; functions = {}; BUILTINS = {}
|
|
4
|
+
|
|
5
|
+
def get_val(raw):
|
|
6
|
+
if raw is None: return ""
|
|
7
|
+
raw = str(raw).strip()
|
|
8
|
+
if raw == "": return ""
|
|
9
|
+
try:
|
|
10
|
+
if "." in raw and raw.replace(".","",1).lstrip("-").isdigit(): return float(raw)
|
|
11
|
+
if raw.lstrip("-").isdigit(): return int(raw)
|
|
12
|
+
except: pass
|
|
13
|
+
if raw in variables: return variables[raw]
|
|
14
|
+
try:
|
|
15
|
+
expr = raw
|
|
16
|
+
for k,v in sorted(variables.items(), key=lambda x: -len(x[0])):
|
|
17
|
+
if isinstance(v, (int,float)): expr = expr.replace(k, str(v))
|
|
18
|
+
if any(op in expr for op in ["+","-","*","/","%"]): return eval(expr)
|
|
19
|
+
except: pass
|
|
20
|
+
return raw
|
|
21
|
+
|
|
22
|
+
def builtin(name):
|
|
23
|
+
def wrap(fn):
|
|
24
|
+
BUILTINS[name]=fn; return fn
|
|
25
|
+
return wrap
|
|
26
|
+
|
|
27
|
+
@builtin("abs")
|
|
28
|
+
def b_abs(a): return abs(float(a))
|
|
29
|
+
@builtin("max")
|
|
30
|
+
def b_max(a,b): return max(float(a),float(b))
|
|
31
|
+
@builtin("min")
|
|
32
|
+
def b_min(a,b): return min(float(a),float(b))
|
|
33
|
+
@builtin("pow")
|
|
34
|
+
def b_pow(a,b): return math.pow(float(a),float(b))
|
|
35
|
+
@builtin("sqrt")
|
|
36
|
+
def b_sqrt(a): return math.sqrt(float(a))
|
|
37
|
+
@builtin("ceil")
|
|
38
|
+
def b_ceil(a): return math.ceil(float(a))
|
|
39
|
+
@builtin("floor")
|
|
40
|
+
def b_floor(a): return math.floor(float(a))
|
|
41
|
+
@builtin("round")
|
|
42
|
+
def b_round(a): return round(float(a))
|
|
43
|
+
@builtin("random")
|
|
44
|
+
def b_random(a=0,b=1): return random.uniform(float(a),float(b))
|
|
45
|
+
@builtin("len")
|
|
46
|
+
def b_len(a): return len(str(a))
|
|
47
|
+
@builtin("upper")
|
|
48
|
+
def b_upper(a): return str(a).upper()
|
|
49
|
+
@builtin("lower")
|
|
50
|
+
def b_lower(a): return str(a).lower()
|
|
51
|
+
@builtin("trim")
|
|
52
|
+
def b_trim(a): return str(a).strip()
|
|
53
|
+
@builtin("contains")
|
|
54
|
+
def b_contains(a,b): return str(b) in str(a)
|
|
55
|
+
@builtin("starts")
|
|
56
|
+
def b_starts(a,b): return str(a).startswith(str(b))
|
|
57
|
+
@builtin("ends")
|
|
58
|
+
def b_ends(a,b): return str(a).endswith(str(b))
|
|
59
|
+
@builtin("replace")
|
|
60
|
+
def b_replace(a,b,c): return str(a).replace(str(b),str(c))
|
|
61
|
+
@builtin("slice")
|
|
62
|
+
def b_slice(a,b,c=None):
|
|
63
|
+
s=str(a); start=int(float(b))
|
|
64
|
+
if c is None: return s[start:]
|
|
65
|
+
return s[start:int(float(c))]
|
|
66
|
+
|
|
67
|
+
def eval_condition(cond):
|
|
68
|
+
cond = cond.strip()
|
|
69
|
+
# replace vars with python literal
|
|
70
|
+
for k,v in sorted(variables.items(), key=lambda x: -len(x[0])):
|
|
71
|
+
if isinstance(v, str):
|
|
72
|
+
cond = cond.replace(k, f'"{v}"')
|
|
73
|
+
else:
|
|
74
|
+
cond = cond.replace(k, str(v))
|
|
75
|
+
# now bare words like Edward that remain and are not true/false/and/or/numbers -> make them string
|
|
76
|
+
import re
|
|
77
|
+
def repl_word(m):
|
|
78
|
+
w=m.group(0)
|
|
79
|
+
if w in ["and","or","True","False","==","!=","<",">","<=",">="]: return w
|
|
80
|
+
if w.replace(".","",1).isdigit(): return w
|
|
81
|
+
if w.startswith('"') and w.endswith('"'): return w
|
|
82
|
+
# if already quoted inside, skip
|
|
83
|
+
return f'"{w}"'
|
|
84
|
+
# find bare words not in quotes
|
|
85
|
+
cond = re.sub(r'\b[A-Za-z_][A-Za-z0-9_]*\b', repl_word, cond)
|
|
86
|
+
cond = cond.replace('""','"')
|
|
87
|
+
cond = cond.replace('""""','"')
|
|
88
|
+
# fix double quoted
|
|
89
|
+
cond = cond.replace('""Edward""','"Edward"')
|
|
90
|
+
try:
|
|
91
|
+
return bool(eval(cond))
|
|
92
|
+
except Exception as e:
|
|
93
|
+
# print(f"cond debug: {cond} -> {e}")
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
def call_func(tokens):
|
|
97
|
+
name=tokens[0]; raw_args=tokens[1:]; args=[]
|
|
98
|
+
for a in raw_args:
|
|
99
|
+
a=a.replace(",","").strip()
|
|
100
|
+
if a=="": continue
|
|
101
|
+
args.append(get_val(a))
|
|
102
|
+
if name in BUILTINS:
|
|
103
|
+
try: return BUILTINS[name](*args)
|
|
104
|
+
except Exception as e: return f"Error {name}: {e}"
|
|
105
|
+
if name in functions:
|
|
106
|
+
f=functions[name]; old=variables.copy()
|
|
107
|
+
for p,v in zip(f["params"], args): variables[p]=v
|
|
108
|
+
run_block(f["body"])
|
|
109
|
+
ret=None
|
|
110
|
+
for l in f["body"]:
|
|
111
|
+
if l.strip().startswith("return "): ret=get_val(l.strip()[7:]); break
|
|
112
|
+
variables.clear(); variables.update(old)
|
|
113
|
+
return ret
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
def run_block(block):
|
|
117
|
+
i=0
|
|
118
|
+
while i < len(block):
|
|
119
|
+
line=block[i].strip(); i+=1
|
|
120
|
+
if not line or line.startswith("//") or line.startswith("#"): continue
|
|
121
|
+
if line.startswith("if "):
|
|
122
|
+
cond=line[3:].split(" be")[0].strip()
|
|
123
|
+
truth=eval_condition(cond)
|
|
124
|
+
inner=[]; else_inner=[]; in_else=False; depth=1
|
|
125
|
+
while i < len(block):
|
|
126
|
+
l=block[i].strip(); i+=1
|
|
127
|
+
if l.startswith("if "): depth+=1
|
|
128
|
+
if l=="end":
|
|
129
|
+
depth-=1
|
|
130
|
+
if depth==0: break
|
|
131
|
+
if l=="else" and depth==1:
|
|
132
|
+
in_else=True; continue
|
|
133
|
+
if not in_else: inner.append(l)
|
|
134
|
+
else: else_inner.append(l)
|
|
135
|
+
if truth: run_block(inner)
|
|
136
|
+
else: run_block(else_inner)
|
|
137
|
+
continue
|
|
138
|
+
if line.startswith("for "):
|
|
139
|
+
header=line[4:].split(" be")[0].strip()
|
|
140
|
+
var_name=None; start=0; end=0
|
|
141
|
+
if " to " in header:
|
|
142
|
+
left,right=header.split(" to ")
|
|
143
|
+
left=left.strip()
|
|
144
|
+
if "=" in left:
|
|
145
|
+
var_name,start=[s.strip() for s in left.split("=")]
|
|
146
|
+
end=right.strip()
|
|
147
|
+
start=int(float(get_val(start))); end=int(float(get_val(end)))
|
|
148
|
+
body=[]; depth=1
|
|
149
|
+
while i < len(block):
|
|
150
|
+
l=block[i].strip(); i+=1
|
|
151
|
+
if l.startswith("for "): depth+=1
|
|
152
|
+
if l=="end":
|
|
153
|
+
depth-=1
|
|
154
|
+
if depth==0: break
|
|
155
|
+
body.append(l)
|
|
156
|
+
for v in range(start, end+1):
|
|
157
|
+
variables[var_name]=v
|
|
158
|
+
run_block(body)
|
|
159
|
+
continue
|
|
160
|
+
if line.startswith("ask "):
|
|
161
|
+
rest=line[4:].strip()
|
|
162
|
+
if "=" in rest:
|
|
163
|
+
var,prompt=rest.split("=",1)
|
|
164
|
+
var=var.strip(); prompt=prompt.strip()
|
|
165
|
+
ans=input(prompt+" ")
|
|
166
|
+
try:
|
|
167
|
+
if "." in ans: ans=float(ans)
|
|
168
|
+
else: ans=int(ans)
|
|
169
|
+
except: pass
|
|
170
|
+
variables[var]=ans
|
|
171
|
+
continue
|
|
172
|
+
if line.startswith("yarn "):
|
|
173
|
+
content=line[5:].strip()
|
|
174
|
+
tok=content.split()
|
|
175
|
+
if tok and (tok[0] in functions or tok[0] in BUILTINS):
|
|
176
|
+
val=call_func(tok)
|
|
177
|
+
if val is not None: print(val)
|
|
178
|
+
else:
|
|
179
|
+
print(get_val(content))
|
|
180
|
+
continue
|
|
181
|
+
if line.startswith("return "):
|
|
182
|
+
return get_val(line[7:])
|
|
183
|
+
if "=" in line:
|
|
184
|
+
n,v=line.split("=",1)
|
|
185
|
+
v=v.strip(); parts=v.split()
|
|
186
|
+
if parts and (parts[0] in BUILTINS or parts[0] in functions):
|
|
187
|
+
variables[n.strip()]=call_func(parts)
|
|
188
|
+
else:
|
|
189
|
+
variables[n.strip()]=get_val(v)
|
|
190
|
+
|
|
191
|
+
def run_file(path):
|
|
192
|
+
with open(path) as f:
|
|
193
|
+
lines=[l.rstrip("\n") for l in f]
|
|
194
|
+
i=0; cleaned=[]
|
|
195
|
+
while i < len(lines):
|
|
196
|
+
line=lines[i].strip(); i+=1
|
|
197
|
+
if line.startswith("func "):
|
|
198
|
+
header=line[5:].strip()
|
|
199
|
+
if " be" in header: header=header.split(" be")[0]
|
|
200
|
+
header=header.replace("(", " ").replace(")", " ").replace(",", " ")
|
|
201
|
+
parts=header.split()
|
|
202
|
+
fname=parts[0]; params=parts[1:]
|
|
203
|
+
body=[]
|
|
204
|
+
while i < len(lines):
|
|
205
|
+
l=lines[i].strip(); i+=1
|
|
206
|
+
if l=="end": break
|
|
207
|
+
body.append(l)
|
|
208
|
+
functions[fname]={"params":params,"body":body}
|
|
209
|
+
else:
|
|
210
|
+
cleaned.append(line)
|
|
211
|
+
run_block(cleaned)
|
|
212
|
+
|
|
213
|
+
if len(sys.argv)<2:
|
|
214
|
+
print("Usage: nas file.yarn")
|
|
215
|
+
else:
|
|
216
|
+
run_file(sys.argv[1])
|
|
217
|
+
def main():
|
|
218
|
+
import sys
|
|
219
|
+
from nas_lang import run_file
|
|
220
|
+
run_file(sys.argv[1] if len(sys.argv)>1 else "")
|
|
221
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nas-lang
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: NAS Language - Java power with Python easy yarn printing, by Kelly
|
|
5
|
+
Author: Edward Kelly
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: classifier
|
|
11
|
+
Dynamic: requires-python
|
|
12
|
+
Dynamic: summary
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nas_lang
|
nas_lang-1.0.0/setup.cfg
ADDED
nas_lang-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="nas-lang",
|
|
5
|
+
version="1.0.0",
|
|
6
|
+
description="NAS Language - Java power with Python easy yarn printing, by Kelly",
|
|
7
|
+
author="Edward Kelly",
|
|
8
|
+
packages=find_packages(),
|
|
9
|
+
entry_points={
|
|
10
|
+
"console_scripts": [
|
|
11
|
+
"nas=nas_lang.cli:main",
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
python_requires=">=3.8",
|
|
15
|
+
classifiers=[
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
],
|
|
19
|
+
)
|