CosmoCode is a beginner-friendly, imperative programming language inspired by the mysteries of space. It combines a space-themed syntax with a straightforward approach to programming. Designed for simplicity, CosmoCode encourages learners to explore coding while adhering to core programming principles.
- Variables, keywords, and constructs are named after celestial and space-related terms, making coding imaginative and engaging.
- Example:
Comet stellarCount = 5; // Declare an integer variable transmission("Hello Universe!"); // Print a message
- Comet: The only data type, used to store integers.
- Example:
Comet value = 10;
- Reception: For input operations
- Transmission: For output operations
- Orbit, Navigate, Propel: Conditional constructs (if, else if, else)
- Whirl, Launch Whirl: Looping constructs (while, do-while)
- Arithmetic:
+,-,*,/ - Relational:
==,!=,>=,<=,>,< - Logical:
&&(AND),||(OR)
-
Conditional statements:
Orbit (condition) { // statements } Navigate { // else if statements } Propel { // else statements } -
Loops:
- Whirl (while loop):
Whirl (condition) { // statements } - Launch Whirl (do-while loop):
Launch { // statements } Whirl (condition);
- Whirl (while loop):
- Reception: Accepts user input
- Transmission: Displays output
- Example:
Comet input = reception("Enter a value:"); transmission("You entered: " + input);
- Single-line and multi-line comments:
/* This is a comment */
- Implements lexical, syntactic, and semantic analyzers
- Ensures proper structure and execution of programs
- Flags invalid tokens, out-of-scope variables, and undeclared identifiers during compilation
- Converts source code into tokens
- Validates identifiers, literals, and reserved words
- Employs a shift-reduce parser for syntax checking
- Generates a parse tree for valid programs
- Validates type compatibility, variable declarations, and scope
- Executes the program based on the parse tree
- Only supports integer variables
- Limited to two loop constructs and basic conditionals
- No support for advanced programming paradigms
- Tokens must be space-separated
- Limited scalability for large projects
transmission("Hello Universe!");
Comet count = 0;
Whirl (count < 5) {
transmission(count);
count = count + 1;
};
Comet value = 10;
Orbit (value > 5) {
transmission("Greater than 5");
} Propel {
transmission("5 or less");
};