Syntax

Mosc follows c-like language syntax

Identifiers #

Identifiers are used to as function, method, variable or class name. They should match [a-zA-Z][a-zA-Z_] patterns

  molo # valid
  _molo # valid
  __molo # valid
  11molo # invalid identifier
  $molo # invalid identifier

Keywords #

ale, atike, dialen, dilan, dunan, faa, foo, inafo, ipan, kabo, kaj, kay, kono, kulu, nani, nii, niin, note, segin, seginka, tii, tumamin, ye

You can declare use those keywords as identifiers

Comment #

Comments are divided in 2 categories: single ling comment and block comments. Single line comment starts with # while block comments starts with #* and ends with *#

# Single line comment, ends at the end of the line
#*
 Block comment,
 Can have multi line
*#

New lines and ; #

New-line are important in Mosc, they are used to end an expression if those are not already ended by a ;.


12 + 34 # new line
test()

You can put new line in arbitrary position in Mosc code as long as its not the end of the expression their will be ignored by Mosc.

Block #

Block is a statement and contains a group of statement, you can use it anywhere a statement is allowed, it starts at a { and ends at }. Things like functions or methods body, control flow body In the block are allowed statements.

 nii a > 3 {
     # statements here
 } note {
    # statements here
 }

Blocks have two similar but not identical forms. Typically, blocks contain a series of statements like:

{
  A.yira("one")
  A.yira("two")
  A.yira("three")
}

Blocks of this form when used for method and function bodies automatically return gansan after the block has completed. If you want to return a different value, you need an explicit segin niin statement.

However, it’s pretty common to have a method or function that just evaluates and returns the result of a single expression. Some other languages use => to define these. Mosc uses:

{ "single expression" }

If there is no newline after the { (or after the parameter list in a function), then the block may only contain a single expression, and it automatically returns the result of it. It’s exactly the same as doing:


{
  segin niin "single expression"
}

Statements are not allowed in this form (since they don’t produce values), which means nothing starting with class, for, import, return, var, or while. If you want a block that contains a single statement, put a newline in there:

{
  nii (happy) {
    A.yira("I'm feelin' it!")
  }
}

Operators #

Mosc supports arithmitic operations like any language, operators are classified per priority as bellow

Prec Operator Description Associates
1 () [] . Grouping, Subscript, Method call Left
2 - ! ~ Negate, Not, Complement Right
3 * / % Multiply, Divide, Modulo Left
4 + - Add, Subtract Left
5 .. ... Inclusive range, Exclusive range Left
6 << >> Left shift, Right shift Left
7 & Bitwise and Left
8 ^ Bitwise xor Left
9 | Bitwise or Left
10 < <= > >= Comparison Left
11 is Type test Left
12 == != Equals, Not equal Left
13 && Logical and Left
14 || Logical or Left
15 = Assignment, Setter Right