Skip to content

Instantly share code, notes, and snippets.

@StringEpsilon
Last active June 17, 2025 17:54
Show Gist options
  • Save StringEpsilon/1ee95d8a7ac484928c0cb71c6d356c3e to your computer and use it in GitHub Desktop.
Save StringEpsilon/1ee95d8a7ac484928c0cb71c6d356c3e to your computer and use it in GitHub Desktop.
Pushy

General

  • All statements in pushy end in a semicolon.
  • Calling a function (either built-in or user defined) always requires parentheses.
  • A scope (or block) is indicated by curly brackets.
  • Comments start with # and to until the end of the line.

Data types

  • integer - A 32 bit signed integer.
  • double - A double-precision floating point number
  • string - A string of UTF-16 code points.
  • char - A single UTF-16 code point.

Declarations

To declare a variable, use the following syntax:

declare {datatype} {identifier} [= {defaultValue}];

A valid identifier is any sequence of a-z, A-Z, 0-9 and _. Identifiers can not start with a number. They must contain at least one letter.

Assigning a default value is optional. Please not that all primitive type variables in pushy are assigned a default value according to their type:

  • integer -> 0
  • double -> 0.0
  • string -> ""
  • char -> ''

Examples

declare string name = "Pushy";
declare integer birthYear = 2025;
declare integer bugs;

Assignments

To assign a value to a variable, simply use x = value;:

declare	string name;
name = "Pushy";
print(name);

Expressions

Pushy has the following operators for expressions:

  • Unary:
    • increment (foo++)*
    • decrement (foo--)*
    • negation (not false)
    • casting cast(double)myInteger
  • Binary:
    • addition (x + y)
    • concatenation ("Ex" + "Why")
    • subtraction (x - y)
    • division (x / y)
    • multiplication (x * y)
    • modulo (x mod y)
    • raise to the power of (x ^ y)
    • equality (x = y)
    • inequality (x != y)
    • less than (x < y)
    • greater than (x > y)
    • less than or equal (x <= y)
    • greater than or equal (x >= y)
    • logical and (true and true)
    • logical or (true or false)
    • logical xor (true or false)
    • bitwise and (8 and 8)
    • bitwise or (8 or 8)
    • bitwise xor (8 xor 8)
    • bitshift left (8 << 1)
    • bitshift right (8 >> 1)

The operators are context sensitive. For example and is always logical if the values the operands are boolean. It is always bitwise if the operands are numerical. And + is a concatenation if the operands are a string.

Special attention should be paid to =. Pushy will always treat that as the equality operation in cases where an expression is valid syntax and only treat it as an assignment when stand-alone.

declare integer a = 1;
declare integer b = 2;
if (b = a) { 
	print("this is not executed, because a != b");
}
b = a;
if (b = a) { 
	print("this *is* executed because we assigned a to b.");
}

You can use parentheses to force evaluation order or to clarify order of operations:

print(4 + 4 * 4); # prints 20
print((4 + 4) * 4); # prints 32
print(5 > 4 or 10); # type error, 'or' can not be used on boolean and integer.
print(5 > (4 or 10)); # prints false

* As of writing, unary increment and decrement currently only work as statements: i++; i--;.

Implicit casting

Some operations allow for the implicit casting of the operands if the operand types don't match.

For arithmetic operators (addition, subtraction, division, multiplication, modulo, power), the operands are cast in this order: integer -> long -> double.

Examples:

myInteger * myLong -> cast(long)myInteger * myLong
myLong * myDouble -> cast(double)myLong * myDouble
myInteger * myDouble -> cast(double)myInteger * myDouble

For comparative operations (equal, less than, greater than, ...) of numeric types, the same implicit casting rules apply.

Other operators do not try to cast (left and right shift, bitwise and logical operators).

Control flow

If

An if statement has the following syntax:

if ({condition}) {
	{body}
}

The condition must be a boolean expression. You can also specify an else-branch or else-if-branches. See below.

Example

if (name = "Pushy") {
	print("Hello Pushy, nice to see you!");
} else if (name != "") {
	print("Hello "+ name + "!");
} else {
	print("Hello Stranger!");
}

Loops

While

For

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment