Skip to content

Language Syntax

anb2473 edited this page Mar 27, 2025 · 7 revisions

This is all of the syntax information for the language

NOTE: Some legacy languages may not have all of these features. Please read the information in your versions wiki for more details about the specific features your model has.

COMMENTS

  • You can write full line comments as follows:
# My comment
  • You can also write comments after statements:
x = 0 # My comment
  • Or, you can write comments in between multiple statements:
x = 0 # My comment; y = 1; # My second comment

DECLARE VARIABLES

  • You can declare variables as follows:
let x: int = 0
  • However, you do not need to enter all the types and let declaration for the statement:
x = 0
  • The language has several base types:
x = 0                       # int
y = 1.2                     # float
a = 'a'                     # char (NOTE: You must have single line quotes)
word = 'Hello'              # str  (NOTE: You must have double line quotes)
conditional = if a == 'a'   # bool
conditional_2 = true
  • However, the language also provides several higher level types:
let my_list = [1, 2, 3]           # list>int
let my_dict = {1: 'a', 2: 'b'}    # dict>int>char

OBJECT ATTRIBUTES

  • You can access attributes of an object as follows:
my_list = [1, 2, 3]
x = my_list.1        # Returns 2
my_dict = {1: 'a', 2: 'b'}
y = my_list.2        # Returns 'b'

RETURN STATEMENTS

  • You can return a variable with:
return 1
  • You can do the same in functions to allow functions to return values

OPERATIONS

  • You can execute operations on variables as follows:
x = 1
x = x + 1       # Returns 2 (Addition)
x = x - 1       # Returns 1 (Subtraction)
x = x * 4       # Returns 4 (Multiplication)
x = x / 2       # Returns 2 (Division)
x = x ** 3      # Returns 8 (Powers)
x = x // 3      # Returns 2 (Roots)
x = x % 1       # Returns 0 (remainder)
x = x + 0.5 ~   # Returns 0 (floor)
  • You can execute these operations on any object (Some of them may not be supported)

IF / ELSE / ELIF STATEMENTS

  • You can declare if / else / elif statements as follows:
x = 12
if x == 12 {

}
elif x == 13 {

}
else {

}

WHILE STATEMENTS

  • You can declare a while statements as follows:
x = 0
check = if x == 3
while check {
   x = x + 1
   check = if x == 3
}
# Returns 3

FUNCTIONS

  • You can define functions as follows:
def foo -> int (x: int) {
   return 0
}
  • You can also import compiled Stream files (.fsl) or files of other languages as functions with:
prototype my_foo_name "path\to\my\foo.fsl" -> int (word: str)
  • With this you can call functions with:
foo(0)

Clone this wiki locally