riser_ is a dynamically-typed programming language that supports basic programming constructs like variables, control structures, functions, and operators.
-
Dynamically Typed: Types are determined at runtime, no need for type declarations.
-
Primitive Data Types:
int
- Integer values (e.g.,1
,-42
)float
- Floating-point numbers (e.g.,3.14
,-0.5
)string
- Sequence of characters (e.g.,"Hello, World"
)bool
- Boolean values (true
,false
)
-
Variables:
- Variables are declared using the
let
keyword. Example:let x = 10; let name = "India";
- Variables are declared using the
-
Operators:
- Arithmetic:
+
,-
,*
,/
,%
- Comparison:
==
,!=
,<
,>
,<=
,>=
- Logical:
&&
(and),||
(or),!
(not)
- Arithmetic:
-
Control Structures:
- Conditional statements:
if (x > 10) { print("Greater than 10"); } else { print("Less than or equal to 10"); }
- Loops (
while
,for
):let i = 0; while (i < 5) { print(i); i = i + 1; } for (let i = 0; i < 5; i = i + 1) { print(i); }
- Conditional statements:
-
Functions:
- Define and call functions:
func greet(name) { print("Hello, " + name); } greet("World");
- Return values from functions:
func add(a, b) { return a + b; } let result = add(5, 10);
- Define and call functions:
-
Built-in Functions:
print()
- Outputs text to the console.input()
- Reads user input (optional for your implementation).
-
Comments:
- Single-line comments using
//
:// This is a comment
- Single-line comments using
-
Error Handling:
- Basic error detection for common issues like division by zero.
// comment
func add(a, b) {
return a + b;
}
let x = 5;
let y = 10;
let result = add(x, y);
if (result > 10) {
print("Result is greater than 10");
} else {
print("Result is 10 or less");
}
- Save the file name.rr
- Run make if the .class files are not present (one time).
- Run java Riser name.rr
Note: This implementation does not purely follow standard compiler/interpreter design principles and the theoretical aspects of formal languages and automata.