SHE is a beginner-friendly programming language with a simple syntax for arithmetic, variables, conditionals, loops, functions, strings, lists, and more. This manual provides clear examples for every feature.
-
Install Python (if not already installed).
-
Install the Kaalka encryption package (required for encryption features):
pip install kaalka
-
Open a terminal and navigate to the SHE directory.
-
Run SHE with:
python shell.py
SHE supports all basic arithmetic operations and power:
5 + 5 # 10
5 - 2 # 3
5 * 3 # 15
5 / 2 # 2.5
5 % 2 # 1
2 ^ 3 # 8 (power)
(1 + 2) * 3 # 9
Store values using the VAR keyword:
VAR a = 5
VAR b = 10
VAR sum = a + b
PRINT(sum) # 15
Evaluate expressions and get boolean results (1 for True, 0 for False):
PRINT(5 == 5) # 1
PRINT(5 != 4) # 1
PRINT(5 > 3) # 1
PRINT(5 < 3) # 0
PRINT(5 >= 5) # 1
PRINT(5 <= 4) # 0
PRINT(5 == 5 AND 5 == 4) # 0
PRINT(5 == 5 OR 5 == 4) # 1
Control flow with IF, ELIF, ELSE:
VAR age = 19
VAR price = IF age >= 18 THEN 40 ELSE 20
PRINT(price) # 40
VAR x = 5
VAR result = IF x > 10 THEN "big" ELIF x == 5 THEN "five" ELSE "small"
PRINT(result) # five
VAR result = 1
FOR i = 1 TO 5 THEN VAR result = result * i
PRINT(result) # 120 (factorial of 5)
With step:
FOR i = 10 TO 0 STEP -2 THEN PRINT(i)
# 10 8 6 4 2 0
VAR i = 0
WHILE i < 5 THEN
PRINT(i)
VAR i = i + 1
END
# 0 1 2 3 4
Define and use functions:
FUN add(a, b) -> a + b
PRINT(add(6, 6)) # 12
VAR any = add
PRINT(any(5, 4)) # 9
VAR inc = FUN(a) -> a + 6
PRINT(inc(12)) # 18
Work with strings:
PRINT("This is a String")
PRINT("Hello " + "World") # Hello World
PRINT("Hi! " * 3) # Hi! Hi! Hi!
FUN greet(person, times) -> "Hello, " * times + person
PRINT(greet("Piyush", 3)) # Hello, Hello, Hello, Piyush
Create and manipulate lists:
VAR list = [1, 2, 3]
PRINT(list)
VAR list2 = list + 4
PRINT(list2) # [1, 2, 3, 4]
VAR concat = [1, 2, 3] * [4, 5]
PRINT(concat) # [1, 2, 3, 4, 5]
PRINT(list / 0) # 1 (element at index 0)
Loop with lists:
FOR i = 1 TO 5 THEN PRINT(i ^ 2)
# 1 4 9 16 25
PRINT(value)โ Print a value (prints the value directly, no extra zero or newline)PRINT_RET(value)โ Return value as stringINPUT()โ Get user inputINPUT_INT()โ Get integer inputCLEAR()orCLS()โ Clear the screenIS_NUM(value)โ Check if value is a numberIS_STRING(value)โ Check if value is a stringIS_FUN(value)โ Check if value is a functionIS_LIST(value)โ Check if value is a listAPPEND(list, value)โ Add value to listPOP(list, index)โ Remove and return value at indexEXTEND(list, other_list)โ Extend listLEN(list)โ Length of listRUN(filename)โ Run a SHE file (output of PRINT statements in the file will be shown)KAALKA_ENCRYPT(message, timestamp)โ Encrypt messageKAALKA_DECRYPT(encrypted_message, timestamp)โ Decrypt message
- The SHE shell suppresses printing the return value of the
RUNandPRINTcommands to avoid extra zeros or duplicate output. - The output you see from
PRINTcommands is the actual value printed by the script. - There is no extra zero printed by the interpreter or shell beyond what the script outputs.
Save your SHE code in a file (e.g., example.she) and run:
RUN("example.she")
SHE supports encryption and decryption using the Kaalka Encryption Algorithm as built-in functions.
KAALKA_ENCRYPT(message, timestamp)- Encrypts the given message using the provided time (e.g., "14:35:22") as the key.
- If the
timestampargument is omitted, the current system time is used automatically.
KAALKA_DECRYPT(encrypted_message, timestamp)- Decrypts the given encrypted message using the provided time as the key.
- If the
timestampargument is omitted, the current system time is used automatically.
Encrypt and decrypt with an explicit timestamp:
VAR msg = "Hello, SHE!"
VAR ts = "14:35:22" # Use a time string (HH:MM:SS) as key
VAR encrypted = KAALKA_ENCRYPT(msg, ts)
PRINT(encrypted)
VAR decrypted = KAALKA_DECRYPT(encrypted, ts)
PRINT(decrypted)
Encrypt and decrypt using the current system time (no timestamp argument):
VAR msg = "Secret at system time!"
VAR encrypted = KAALKA_ENCRYPT(msg)
PRINT(encrypted)
VAR decrypted = KAALKA_DECRYPT(encrypted)
PRINT(decrypted)
Note:
- When using the system time, encryption and decryption must occur at the same second for the result to be correct.
- For most use cases, providing an explicit timestamp is recommended for reproducibility.
Contributions are welcome! If you have suggestions, bug reports, or feature requests, please create an issue or submit a pull request.
See the LICENSE file for details.
Two test files are included for thorough testing of SHE language features:
test_multiline.she: Tests multiline statements, loops, functions, and basic operations.test_remaining_features.she: Tests built-in functions, encryption, lists, and edge cases.
Run these test files using:
RUN("test_multiline.she")
RUN("test_remaining_features.she")
These tests demonstrate the language capabilities and verify correct behavior.
- The SHE shell suppresses printing the return value of
RUNandPRINTcommands to avoid extra zeros. - The output you see from
PRINTcommands is the actual output of the script. - If you want to avoid output, remove or comment out
PRINTstatements in your SHE scripts.