请输入您要查询的百科知识:

 

词条 P*
释义

  1. Syntax

      Scenes and templates    Data types  

  2. Implementation

{{Orphan|date=December 2015}}{{Infobox programming language
| logo =
| name = P*
| year = 2013
| designer = Atle Solbakken
| latest release date = November 2013
| typing = Static, weak
| influenced_by = C, PHP, Perl, C++
| operating_system = Cross-platform (multi-platform)
| file_ext = .pstar or no extension
| license = GPLv3
| website = {{URL|http://www.p-star.org}}
}}

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

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

The code of a P* program is placed into scenes  , 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:

Hello world web page

{@text}

 } SCENE main {     string text = "Hello World!";     #CONTENT_TYPE text/html;     #HTML_TEMPLATE body; }

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

Data types

P* provides eight basic types   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) . "\"; }

Implementation

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.

1 : C programming language family

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/20 13:45:41