Basic Syntax Rules

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 after an instruction

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 brackets ((, [ or <) doesn’t match the number of closed brackets (), ] or >). 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

PPL identifier

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

Examples:

color
last_name
make_delicious_coffee
index_1
URI
XML_file_20

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 can optionally be prefixed to explicitly document which kind of identifier is used. 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.

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 the same way they are used in the English language. For example, acronyms are written with uppercase letters:

HTML_to_PDF_converter

Code Blocks and Indents

PPL code block

In PPL, code embedded within a block is indented (preferably by four spaces), and the block is terminated by a dot (.) on a single line. PPL doesn’t use opening and closing curly brackets ({ and }).

Hence, code like this in a language that uses brackets …​

foo {
    // body
}

... is written like this in PPL:

foo
    // body
.

Example:

repeat for each name in ["Alice", "Bob", "Tim", "Tom"]
    if name.starts_with ( "T" ) then
        write_line ( name )
    .
.

results matching ""

    No results matching ""