Syntax and Semantics

1. Core Syntax

The syntax of our language combines elements of Ruby and Java. It's designed to be simple and easy to read, with all keywords and function names written in lowercase, separated by underscores when necessary. For example, to send a message to a player, you would write:

player.send_message("Hello World")

2. Data Types

Our language supports the following basic data types:

  • Numbers: Includes both integers and floating-point numbers.

health = 20
damage = 12.5
  • Strings: Textual data, surrounded by double quotes.

"Hello World"
  • Booleans: Represents true or false values.

true
false
  • Enums: To work with enum values, you need to prefix the enum with a :. For example, setting a player’s gamemode:

player.gamemode = :SURVIVAL

3. Variables

Variables are dynamically typed and can be defined by simply assigning a value. You can access both variables and functions using the dot notation.

Defining Variables:

cool_name = "Steve"
health = 100

Accessing Variables and Functions: You can access variables and call functions using the dot notation. For example:

player.health // Accessing a variable
player.send_message("Hello, {{player.name}}!")  // Calling a variable and accessing a function

Embedding Variables and Function Calls in Strings: You can include both variables and function calls inside strings using {{}} to create dynamic messages:

// You can send a String directly to the send_message function
player.send_message("Am I sneaking? {{player.sneaking?}}")

// Or you can save it on a variable first 
cool_variable = "Am I sneaking? {{player.sneaking?}}"
player.send_message(cool_variable)

4. Operators

Arithmetic Operators: You can use standard operators like +, -, *, /, and % for calculations.

score = 10
score += 5  // Increment by 5
health -= 10  // Decrement by 10

Comparison Operators: These include ==, !=, >, <, >=, and <= for comparing values.

player.health >= 10 // Returns true if health is greater than 10
player.gamemode == :SURVIVAL // Returns true if gamemode is survival

Logical Operators: Use && for AND, || for OR, and ! for NOT operations.

// Same as: Is player sneaking and his health is greather than 10?
player.sneaking? && player.health > 10 

Assignment Operators: For modifying variables, you can use compound assignment operators such as +=, -=, *=, and /=.

player.level += 10 // Will add 10 levels
player.health -= 2 // Will remove 2 units of health

Last updated