Skip to content

Commit 58e51e8

Browse files
committed
Added If-Else and Pass!!!!
1 parent 7ab36b1 commit 58e51e8

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

NumberScript/__main__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
help = """
1818
0 <- start
1919
1 <- end
20-
2 <- print
21-
3 <- var
22-
4 <- Compare
20+
2thing <- print
21+
3name:value <- var
22+
4number[=/!/</>] <- Compare
23+
5 <- pass
2324
% <- comment
24-
^ <- Math-Operation-Start
25+
^number[+/-/\//]number <- Math-Operation-Start
26+
?conditon:True:False <- If-Else
2527
"""
2628

2729
space = ""
@@ -35,12 +37,12 @@
3537
with open(args.file, "r") as file:
3638
code = file.read()
3739
code = code.replace("\n", " ")
38-
Interpreter.interpret(code)
40+
Interpreter.interpret(Interpreter, code)
3941
else:
4042
print(f"""
4143
+------------------------------------------+
4244
| NumberScript Shell: Type 'exit' to exit. |
43-
| Version: 1.6.1 Machine: {os.name} {space}|
45+
| Version: 1.7.0 Machine: {os.name} {space}|
4446
| Type 'help' for more information. |
4547
| {current_time} |
4648
+------------------------------------------+

NumberScript/interpreter.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,14 @@ def interpret(self, code: str) -> str:
135135
re_code = code[j].replace("?", "", 1)
136136
statements = re_code.split(":")
137137
if Checker(statements[0], variables):
138-
self.interpret(Interpreter, statements[1])
138+
true_statements = statements[1].replace("\n", " ")
139+
self.interpret(Interpreter, true_statements)
139140
else:
140-
self.interpret(Interpreter, statements[2])
141+
false_statements = statements[2].replace("\n", " ")
142+
self.interpret(Interpreter, false_statements)
141143

142144
if code[j] in variables.keys():
143-
print(variables[code[j]])
145+
print(variables[code[j]])
146+
147+
if code[j].startswith("5"):
148+
pass

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ pip install NumberScript
1818
- Comments
1919
- Only 5 commands
2020
- A shell and a runner
21-
- No loops or If-else (Who needs 'em)
21+
- No loops (Who needs 'em)
2222

2323
## Docs
2424

2525
### commands
2626

2727
```
28-
commands: 0 | 1 | 2 | 3 | 4
28+
commands: 0 | 1 | 2 | 3 | 4 | 5
2929
comments: %
3030
arithmetic: ^
3131
Compare: = | ! | < | >
3232
operations: + | - | * | / |
33+
If-Else: ? :
3334
```
3435

3536
>NOTE: You can't have different arithmetic signs in a single ^
@@ -57,10 +58,21 @@ Addition
5758
^a+b %NoSpacesPlease
5859
1
5960
```
61+
62+
If else
63+
```
64+
%Is-This-lucky
65+
0
66+
3lucky_num:9
67+
?lucky_num=8:28-Is-The-Lucky-Num:28-Is-Not-Lucky
68+
?lucky_num=9:29-Is-The-Lucky-Num:29-Is-Not-Lucky
69+
?lucky_num=10:210-Is-The-Lucky-Num:210-Is-Not-Lucky
70+
1
71+
```
6072
>So, since there aren't any spaces what can we use instead of them?
6173
6274
You can use _ or -.
6375

6476
## To-Do
6577

66-
- [ ] If-Else
78+
- [ ] Add loops

examples/Is-This-Lucky.ns

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
%Is-This-lucky
2+
0
3+
3lucky_num:9
4+
?lucky_num=8:28-Is-The-Lucky-Num:28-Is-Not-Lucky
5+
?lucky_num=9:29-Is-The-Lucky-Num:29-Is-Not-Lucky
6+
?lucky_num=10:210-Is-The-Lucky-Num:210-Is-Not-Lucky
7+
1

grammar.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ example 4:
3333
0
3434
3a:1
3535
3b:1
36-
?a=b(2hello):2bye
36+
?a=b:2hello:2bye

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="NumberScript",
8-
version="1.6.1",
8+
version="1.7.0",
99
description="possibly the world's most simplest and restricted language.",
1010
author="Sasen Perera",
1111
long_description=longest_description,

0 commit comments

Comments
 (0)