P-Lingua format

From The P-Lingua Website

(Difference between revisions)
Jump to: navigation, search
(Numeric expressions)
(Numeric expressions)
Line 57: Line 57:
* <m>$3*10^{-5}$</m> is written '''3e-5'''.
* <m>$3*10^{-5}$</m> is written '''3e-5'''.
* <m>\frac{3^{4-x}+17}{23}</m> is written '''(3^(4-x)+17)/23'''.
* <m>\frac{3^{4-x}+17}{23}</m> is written '''(3^(4-x)+17)/23'''.
-
* <m>7*\lceil log_2 x \rceil</m> is written '''7* (@ceil @log x)'''.
+
* <m>7\lceil log_2 x \rceil</m> is written '''7* (@ceil @log x)'''.

Revision as of 10:05, 4 April 2010

Contents

Valid identifiers

We say that a sequence of characters forms a valid identifier if it does not begin with a numeric character and it is composed by characters from the following:

a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 _

Valid identifiers are widely used in the language: to define module names, parameters, indexes, membrane labels, alphabet objects and strings.

The following text strings are reserved words in the language: def, call, @mu, @ms, @model, @lambda, @d, let, @inf, @debug, main, -->, # and they cannot be used as valid identifiers.

Variables

Four kind of variables are permitted in P-Lingua:

Variables are used to store numeric values and their names are valid identifiers. We use 64 bits (signed) in double precision.

Global variables definition

Global variables must be declared out of any program module and they can be accessed from all of the program modules (see modules definition). The name of a global variable global_variable_name must be a valid identifier. The syntax to define a global variable is the following:

global_variable_name = numeric_expression;

Local variables definition

Local variables can only be accessed from the module in which they were declared and they must only be defined inside module definitions. The name of a local variable local_variable_name must be a valid identifier. The syntax to define a local variable is the following:

let local_variable_name = numeric_expression;

Indexes and parameters

Indexes and parameters can be consider local variables used in parametric sentences and modules definition respectively.

Identifiers for electrical charges

In P-Lingua, we can consider electrical charges by using the + and - symbols for positive and negative charges respectively, and no one for neutral charge. It is worth mentioning that polarizationless P systems are included.

Membrane labels

There are three ways of writing membrane labels in P-Lingua: the first one is just a natural number; the second one is to denote the label as a valid identifier and the third one is by numeric expressions that represent natural numbers between brackets.

Environment identifiers

For multienvironment P systems, there are three ways of writing environment identifiers in P-Lingua: the first one is just a natural number; the second one is to denote the label as a valid identifier and the third one is by numeric expressions that represent natural numbers between brackets.

Numeric expressions

Numeric expressions can be written by using * (multiplication), / (division), % (module), + (addition), - (subtraction), ^ (potence), @floor (the next smaller integer), @ceil (the next largest integer) and @log (base 2 logarithm) operators with integer or real numbers and/or variables, along with the use of parentheses. It is possible to write numbers by using exponential notation.

Examples of numeric expressions:

  • is written 3e-5.
  • is written (3^(4-x)+17)/23.
  • is written 7* (@ceil @log x).
Personal tools