Chapter 2. Basic Syntax Rules

Table of Contents
Single line comment
Multi line comment
Line termination
Line continuation
Case sensitivity
Identifiers
Code blocks and indents

Single line comment

Single-line comment in PPL

A single-line comment starts with //, as in C#, Java and many other languages.

Examples:

// This is a single-line comment 

i = 0 // a comment can be appended at the end of a line

Multi line comment

Multi-line comment in PPL

A multi-line comment begins on a line that starts with
///
and ends on a line that starts with
.///

Multi-line comments can be nested. This is useful if you want to comment a block of code that contains already a multi-line comment.

Example:

///
  this is a multi-line comment that contains
  another nested multi-line comment
  /// this is a nested
    multi-line comment
  .///
.///

Line termination

Line termination in PPL

A PPL instruction ends at the end of the source code line (i.e. at the CR or LF character). PPL instructions don't end with a semicolon (;) as in some other languages.

Example:

i = 0
j = 1

Line continuation

Line continuation in PPL

PPL uses a backslash (\) as line continuation character.

Example:

const albert = customer.create ( \
   identifier = 100 \
   name = "Albert" \
   city = "Bern" )

The backslash at the end of line is optional whenever the number of open parentheses (() or open square brackets ([) doesn't match the number of closed parentheses ()), respectively closed square brackets (]). Hence the \ in the above code can be omitted:

const albert = customer.create (
   identifier = 100
   name = "Albert"
   city = "Bern" )

Case sensitivity

Case sensitivity in PPL

PPL is case-sensitive.

The following identifiers are all distinct:
happy
Happy
HAPPY

Identifiers

Identifier in PPL

PPL identifiers start with a letter (lowercase or uppercase), followed by any number of letters, digits and underscores (_).

Examples:

color
last_name
make_delicious_coffee
index_1
URI
XML_file_20
[Note]Note

In idiomatic PPL code, an underscore (_) is used to separate words in identifiers. PPL doesn't use camel-case. Instead of ...

thisIsARatherLongIdentifier

... you will see this in PPL:

this_is_a_rather_long_identifier

An identifier in the source code can optionally be prefixed to explicitly document which kind of identifier you are using. For example, to make it clear that customer is an input argument (and not a constant or variable or anything else) you can write i_customer instead of customer, as shown below:

const name = i_customer.name

Prefixes are optional most of the time. They are required in rare cases where an ambiguity exists. They are sometimes useful to make the code more readable.

[Note]Note

In some languages, identifiers start with an uppercase letter to denote a special kind of identifier. In Java, for example, variable names start with a lowercase letter and class names start with an uppercase letter. There is no such rule in PPL. Uppercase letters are used as in the English language; typically for acronyms. Example: HTML_to_PDF_converter.

Code blocks and indents

Code blocks in PPL

In PPL, code embedded within a block is indented, and the block is terminated by a dot (.) on a single line. PPL doesn't use opening and closing curly brackets ({ and }), such as in languages like C, Java, etc.

Hence, code like this in a language that uses braces ...

foo {
   // body
}

... is written like this in PPL:

foo
   // body
.

Example:

repeat for each continent in ["Africa", "America", "Antarctica", "Asia", "Australia", "Europe" ]
   if continent.starts_with ( "A" ) then
      OS.out.write_line ( continent )
   .
.