Python Syntax, compiles to branchless, highly optimized Java Usage: python main.py file.jpp
Java++ Language Syntax Specification
- Version: 4.x
- Scope: Surface syntax only (no backend semantics)
- BASIC STRUCTURE
A Java++ program consists of statements separated by:
- newline
- semicolon (;)
Example:
x = 5
y = 10;
print(x + y)
- VARIABLES AND ASSIGNMENT
Assignment uses "=".
name = "Alice"
age = 25
pi = 3.14
Reassignment:
age = age + 1
- EXPRESSIONS
Supported literal types:
Integers:
x = 5
Floats:
y = 3.14
Strings:
msg = "hello"
Parentheses:
z = (x + y) * 2
- OPERATORS
Arithmetic:
a + b
a - b
a * b
a / b
Comparison:
a > b
a < b
a >= b
a <= b
a == b
a != b
Examples:
if x > 10:
print("big")
- IF STATEMENTS
Syntax:
if condition:
block
Optional else:
if condition:
block
else:
block
Examples:
if x > 3:
print("hello")
if x > 0:
print("positive")
else:
print("non-positive")
- WHILE LOOPS
Syntax:
while condition:
block
Example:
i = 0
while i < 5:
print(i)
i = i + 1
- FOR LOOPS (RANGE)
Syntax:
for variable: range(start, end):
block
Example:
for i: range(0, 5):
print(i)
- FUNCTIONS
Definition:
def name(param1, param2):
block
Return value:
def add(a, b):
return a + b
Typed parameters (optional syntax form):
def add(a: int, b: int):
return a + b
Examples:
def greet(name):
print("Hello " + name)
greet("Bob")
- RETURN STATEMENT
return expression
return # no value
Example:
def square(x):
return x * x
- FUNCTION CALLS
name(arg1, arg2)
Example:
print("hello")
result = add(2, 3)
- ARRAYS AND INDEXING
Index access:
arr[i]
Assignment:
arr[i] = value
Example:
numbers[0] = 10
x = numbers[0]
- SELECT EXPRESSIONS (TERNARY)
Syntax:
value_if_true if condition else value_if_false
Example:
maxVal = x if x > y else y
- SAFE NAVIGATION
Syntax:
object?.field
Example:
name = user?.name
- F-STRINGS
Syntax:
f"text {expression} more text"
Examples:
msg = f"Hello {name}"
info = f"x={x}, y={y}"
- CLASSES (BASIC FORM)
Definition:
class Name:
block
Methods inside:
class Person:
def greet(self):
print("hi")
- COMMENTS
Single line:
# this is a comment
Example:
x = 5 # inline comment
- STATEMENT BLOCKS
Blocks follow a colon (:) and are written on the next lines.
Example:
if x > 0:
print("positive")
print("still inside block")
- COMPLETE EXAMPLE
# simple program
x = 5
def check(v):
if v > 3:
print("hello world")
else:
print("small")
check(x)
#compiler #transpiler #java #python #javapp #java++