Ysharp is a small interpreted scripting language with a friendly, C-like syntax, dynamic typing, and a standard library of native utilities. It is implemented as a classic three-stage interpreter (lexer -> parser -> evaluator) in Java.
println "Hello Ysharp!";
⚠️ Warning
Ysharp is still a WIP (work in progress) language. Expect breaking changes!
Prerequisites: Java Development Kit (JDK) 21 or later must be installed and available on your system PATH.
For setup instructions and full API documentation, please refer to the official documentation:
https://yagizerdem.github.io/Ysharp/
println "Rock Paper Scissors in Ysharp!";
var moves = ["rock", "paper", "scissors"];
var beats = {
"rock": "scissors",
"paper": "rock",
"scissors": "paper"
};
while(true) do
print("\nMake your move: ");
var user = __input();
if user == "q" then do break; end
if !moves.contains(user) then do
print("Invalid move! Valid moves are: ");
println moves.toString();
continue;
end
var computer = moves.get(Random.nextInt(0, moves.size()));
println "\nYour move: " + user ;
println "Computer's move: " + computer;
if beats.get(computer) == user then do println "\nComputer wins!"; end
if beats.get(user) == computer then do println "\nYou win!"; end
if user == computer then do println "\nIt's a draw!"; end
end
See the official documentation for a complete reference and detailed explanations of Ysharp features.
-
Values & Types
type()on any value; conversions via helpers likedouble(),str(). -
Strings
Indexing and slicing;length(),repeat(n)and related string utilities. -
Arrays
Dynamic arrays withsize(),add(),pop(),insert(i, v),remove(i),get(),contains(v). -
HashMaps
Key-value maps;size(),containsKey(k),put(k, v),remove(k),get(k),keys(),values(). -
Control Flow
if / else,while,for .. in, ternarycond ? a : b, ranges. -
Errors
try / catchandthrow; runtime error handling. -
Objects & Functions
First-class functions; prototype-based objects withconstructor(), static methods, and bound methods usingthis.
- examples - example Ysharp scripts
- src/lexer - tokenizer
- src/parser - recursive descent parser producing AST
- src/evaluator - tree-walk interpreter and stdlib natives
- webdoc - full language reference
Yagiz Erdem
Computer Engineering Student
yagizerdem819@gmail.com
Released under MIT License
