You can edit almost every page by Creating an account. Otherwise, see the FAQ.

P*

From EverybodyWiki Bios & Wiki

P*
File:Logo of the P* Web Programming Language project.png
Designed byAtle Solbakken
First appeared2013
Typing disciplineStatic, weak
OSCross-platform (multi-platform)
LicenseGPLv3
Filename extensions.pstar or no extension
Websitewww.p-star.org
Influenced by
C, PHP, Perl, C++

Search P* on Amazon.

P* (pronounced "P-star") is a programming language meant to be useful in web development for creating dynamic HTML documents. The language provides syntax for templates and prepared SQL-statements. P* programs are scripts which are run by the P* interpreter.

Syntax[edit]

The syntax is inspired from other C-family languages. Program Blocks starts with the open curly bracket { and ends with the close curly bracket }.

Scenes and templates[edit]

The code of a P* program is placed into scenes,[1] and the HTML markup is typically placed inside templates. A scene is a special type of function which does not take arguments. All programs must provide exactly one scene called 'main', which is the first to run by the interpreter.

A small P* web page, where the code for the program sits inside the scene called 'main' and the HTML markup is put inside a template, can look like this:

 HTML_TEMPLATE body {
     <!DOCTYPE html>
     <html>
     <head><title>Hello world web page</title></head>
     <body>
     <p>{@text}</p>
     </body>
     </html>
 }
 SCENE main {
     string text = "Hello World!";
     #CONTENT_TYPE text/html;
     #HTML_TEMPLATE body;
 }

When scenes and templates in P* are called, the callee inherits all variables which is available from where the call is made. This is opposed to when functions are called, where only a set of parameters is passed.

Data types[edit]

P* provides eight basic types[2] for storing data in variables. All variables is required to have a type, but P* automatically converts between them.

In the following example program, one variable, int a, is assigned the value 2, and another variable, string b is assigned the text string "3". When the operator + is run, the left associativity of the operator will lead to an implicit conversion of the right argument to the same type as the left side (type int) before the addition is performed.

 SCENE main {
     int a = 2;
     string b = "3";
     echo "The sum is " . (a + b) . "\n";
 }

Implementation[edit]

P* programs are run by the P* interpreter. A typical way to run scripts is to include a shebang on the first line of the scripts (like #!/usr/bin/wpl -f) and execute the scripts from the shell, or placing the scripts inside CGI-configured directories of a webserver. An interpreter module for the Apache web server is also available.

References[edit]


This article "P*" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:P*. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.