Very basic syntax

This document covers the basic syntax of Nougaro.

Comments

There are two types of comments in Nougaro: single-line comments and multi-line comments.

Single-line comments

Single-line comments start with # and end with a new line. They can start at the beginning of a line or after some code.

Example:

# this is a single-line comment
foo(bar)  # this calls the function foo with the argument bar

Multi-line comments

Multi-line comments start with /* and end with */. They can start and stop at any point in the code.

Example:

/* this is
a multi
line comment */

print("hello")  /* this is also a multi
line comment*/

Multi-line comments can also be only on one line:

print("hello")  /* this is a multi-line comment that is only on one line */

Multi-line comments are simply ignored, which mean you can do things such as:

print( /* this is a comment */ "hello" /* this is another comment */)
print(/*

this
is 
actually
a
comment*/ "hello")

Multi-line comments can be nested:

/* comment 
    /* comment-inside comment*/
    /*
       /* comment-ception */
    */
    comment
*/

NOUGAROIGNORE comments

Added in 0.22.0-beta

These comments start and end with ..NOUGAROIGNORE or .. NOUGAROIGNORE, where . is any character among #@/%!$;. There should be nothing else on the NOUGAROIGNORE line.

Example: file examples/fizzbuzz.cpp.c.py.noug (polyglott file using C/C++ comments, Python docstrings and Nougaro NOUGAROIGNORE comments).

Lines

Line are separated by a newline or a semicolon (;).

a
b

is equivalent to a ; b.

Line joining

If you don’t have enough space on your line, you can join two “real lines” to form a Nougaro line, using a backspace.

Example:

var fruits = [\
    "banana", \
    "apple", \
    "raspberry", \
    "pineapple" \
]

Blank lines

Blank lines are ignored.

Indentation

Indentation is optional, as (mostly) every statement ends with end.

Whitespaces

Whitespaces are ignored everywhere (except in string literals and to differentiate things such as foobar and foo bar, or += and + =).