SpyLang is a programming language designed with a thrilling blend of espionage and geopolitics. It is tailored for developers who seek a unique thematic experience while coding. This documentation provides an in-depth understanding of SpyLang, its syntax, features, and usage. SpyLang programs can be converted into executable files, making them versatile and deployable.
- Introduction
- Features
- Installation
- Syntax and Structure
- Running a SpyLang Program
- Examples
- Built-in Functions
- Glossary of Keywords
- Contributing
SpyLang is built to simulate the high-stakes world of international espionage while providing a robust and expressive programming environment. With a syntax inspired by clandestine operations and mission planning, it encourages developers to think like spies and strategists.
- Unique Thematic Syntax: Keywords and operations are designed to resemble espionage terminology.
- Dynamic Error Handling: Errors are presented as mission failures with detailed reports.
- Readable Token System: Tokens such as
Agent Status
andMission Log
enhance code clarity. - Control Structures: Includes espionage-themed constructs like
check
(if),followup
(else if), andotherwise
(else). - Loop Mechanics: Use
each
for loops andchase
for while loops. - Functional Programming: Define functions as
missions
with parameters and return values.
To get started with SpyLang, follow these steps:
-
Download the Compiler: Download the SpyLang compiler from github.
-
Set Environment Variables: Add the SpyLang directory to your system's PATH for easy access.
SpyLang provides a unique error reporting mechanism:
-
Illegal Character:
Agent Error: Unauthorized character detected in the operation. Mission compromised!
-
Expected Character:
Agent Error: Expected character not found in the operation. Mission compromised!
-
Runtime Error:
Agent Error: Runtime breach! Unauthorized behavior detected in the system.
SpyLang's token system includes:
- Data Types:
INT
,FLOAT
,STRING
- Operators:
PLUS (+)
,MINUS (-)
,DIV (/)
,MUL (*)
- Control Structures:
KEYWORD
- Special Tokens:
MISSION
,AGENT REPORT
check (condition) {
# Actions if condition is true
}
followup (condition) {
# Actions if followup condition is true
}
otherwise {
# Actions if no conditions are true
}
For Loop:
each var in (1..10) {
# Loop body
}
While Loop:
chase (condition) {
# Loop body
}
-
Write your SpyLang code in a
.spy
file. -
Use the SpyLang interpreter to execute the script (
using SpyLang.exe
):spylang.exe your_file.spy
-
Use the SpyLang interpreter to execute the script (
using Shell.exe
) useforward slash
(/
):Spylang > launch("path/to/your_file.spy")
-
Use the SpyLang python code to execute the script:
python Shell.py Spylang > launch("path/to/your_file.spy")
OR
spylang.exe your_file.spy
Hello, Spy World:
mission main() {
assign message = "Hello, Spy World!"
extract message
}
Fibonacci Sequence:
mission fibonacci(n) {
check (n <= 1) {
extract n
} otherwise {
extract fibonacci(n - 1) + fibonacci(n - 2)
}
}
Prime Checker:
mission is_prime(number) {
each i in (2..number - 1) {
check (number % i == 0) {
extract false;
}
}
extract true
}
SpyLang comes equipped with several built-in functions to assist in various operations:
-
math_pi
: A constant representing the value of π.transmit(math_pi)
-
transmit(value)
: Prints the provided value to the console.transmit("Agent reporting for duty!")
-
transmit_ret(value)
: Prints the value and returns it.assign response = transmit_ret("Mission complete.")
-
intel(prompt)
: Reads input from the user as a string.assign name = intel("Enter your codename: ") transmit("Welcome, " + name)
-
intel_int(prompt)
: Reads input from the user and converts it to an integer.assign age = intel_int("Enter your age: ") transmit("Your age is " + age)
-
erase()
: Clears the console screen.erase()
-
is_code(value)
: Checks if the value is a number.transmit(is_code(42))
-
is_msg(value)
: Checks if the value is a string.transmit(is_msg("Agent"))
-
is_list(value)
: Checks if the value is a list.transmit(is_list([1, 2, 3]))
-
is_mission(value)
: Checks if the value is a function.transmit(is_mission(main))
-
add_agent(list, value)
: Appends a value to a list.assign agents = [] add_agent(agents, "Agent 007")
-
withdraw(list)
: Removes the last element from a list and returns it.assign last_agent = withdraw(agents)
-
expand(list1, list2)
: Extends the first list with elements from the second list.expand(agents, ["Agent 008", "Agent 009"])
-
length(collection)
: Returns the length of a collection.transmit(length(agents))
-
launch(mission)
: Executes a file.launch("test.spy")
assign
: Variable assignment.check
: Start of a conditional block.followup
: An else-if condition.otherwise
: Default else block.each
: Looping construct.chase
: While loop construct.mission
: Function definition.extract
: Return statement.abort
: Break statement.proceed
: Continue statement.
Contributions to SpyLang are welcome. To contribute:
- Fork the repository.
- Create a new branch for your feature or fix.
- Submit a pull request with detailed explanations of your changes.
Enjoy coding with SpyLang! Let your imagination run wild in the thrilling world of espionage and geopolitics!