paxPascal Features


paxPascal implements a subset of Object Pascal. For example, the following script is admissible:

program P;
type
  TMyClass = class;

  TMyArray = array[1..3] of String;

  TMyClass = class(TObject)
  private
    function GetProp: Integer;
  public
    function MyFunc(U: Integer; V: Integer): Integer;
    procedure MyProc;
    property MyProp: Integer read GetProp;
  end;

  TMyRec = record
    X, Y: Integer;
  end;

function GlobalFunc: Integer; forward;

function TMyClass.MyFunc(U: Integer; V: Integer): Integer;
begin
  result := U + V + GlobalFunc;
end;

procedure TMyClass.MyProc;
begin
  writeln('here');
end;

function TMyClass.GetProp: Integer;
begin
  result := 11;
end;

function GlobalFunc: Integer;
begin
  result := 700;
end;

var
  X: TMyClass;
  A: TMyArray;
  R: TMyRec;
begin
  X := TMyClass.Create;
  A[1] := 'abc';
  A[2] := 'pqr';
  A[3] := 'uv';
  R.X := 100; 
  writeln(X.MyFunc(4, 5));
  X.MyProc;
  writeln(X.MyProp);
  writeln(R.X);
end;

From another hand, paxPascal has a few extra features which are absent in the Object Pascal.

Program Structure

A paxPascal program is the list of statements. In this relation, paxPascal is more similar with VBScript or JavaScript.

For example, the following script

program P;
type
  TMyRec = record
    X, Y: Integer;
  end;
var
  R: TMyRec;
begin
  print R;
end.
contains four executable statements:
  1. program P;
    
    Creates namespace P.

  2. type
      TMyRec = record
        X, Y: Integer;
      end;
    
    Creates record type TMyRec.

  3. var
      R: TMyRec;
    
    Creates variable R.

  4.   print R;
    
    Printes variable R.

Declaration of Variables

Class Types

Record Types

Array Types

  • You can allocate your arrays dynamically:
    procedure P(N: Integer);
    var 
      A: array[3..N] of Double;
    begin
    ...............
    end;
    
  • Namespaces

    paxPascal supports namespaces. For example:
    namespace Shapes
      type
        TPoint = class(TObject)
           X, Y: Integer;
           constructor Create(X, Y: Integer);
           begin
             inherited Create;
             Self.X := X;
             Self.Y := Y;
           end;
        end;
    
        TCircle = class(TPoint)
          R: Integer;
          constructor Create(X, Y, R);
        end;
        
      constructor TCircle.Create(X, Y, R);
      begin
        inherited Create(X, Y);
        Self.R := R;
      end;
    
    end;
    
    var
      Point = Shapes.TPoint.Create(3, 5);
      Circle = Shapes.TCircle.Create(3, 5, 7);
    begin
      print Point, Circle;
    end.
    

    Regular Expressions

    paxPascal supports the regular expression literals. For example:
    var r = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+/g;
        s = 'My e-mails are ab@virtlabor.donbass.com and ppusr154@ints.net';
    repeat
     if r.exec(s).length = 0 then
       Break
     else
     begin
       writeln(r[0]);
       writeln(r.MatchPos[0]);
       writeln(r.MatchLen[0]);
       writeln(r.LastIndex);
     end;
    until false;
    
    Output:
    ab@cable.netlux.org
    16
    24
    41
    ppusr154@ints.net
    45
    17
    63
    

    Strings

    Double quoted string constants are allowed.
    const s: String = "My name is 's'  ";
    
    You can use backslasges to represent special characters:
    const z: String = 'Two \n lines';
    
    Long string literals are allowed:
    const s: String = """This 
    is a long
    string literal""";
    
    You can use string literals with parameters. For example:
    print '''
    
    First Name: %s
    Last Name: %s
    
    ''' with ['Ivan', 'Sidorov'];
    
    It is equivalent to:
    print Format ('''
    
    First Name: %s
    Last Name: %s
    
    ''', ['Ivan', 'Sidorov'] );
    

    Forward Declarations

    You need no to use forward declarations in paxPascal. In another words, you can use a function call before declaration of the function. For example:
    Fact(5);
    function Fact(N: Integer): Integer;
    begin
      if N = 1 then
        result := 1
      else
        result := N * Fact(N - 1); 
    end;
    

    Control Structures

    The Break statement permits optional label that causes the flow of control to exit an outer for, while, or repeat statement and continue at the next statement.
    var
      I, J: Integer;
    label
      Outer;
    begin
      print 'Start';
      Outer:
      for I:=1 to 3 do
        for J:=1 to 4 do
        begin
          if (I = 2) and (J = 3) then
            Break Outer;
          print I, J;
        end;
    end;
    
    Output:
    11
    12
    13
    14
    21
    22
    
    The Continue statement permits optional label that causes the flow of control to proceed to the next iteration of the outer for, while, or repeat statement.
    var
      I, J: Integer;
    label
      Outer;
    begin
      print 'Start';
      Outer:
      for I:=1 to 3 do
        for J:=1 to 4 do
        begin
          if (I = 2) and (J = 3) then
            Continue Outer;
          print I, J;
        end;
    end;
    
    Output:
    11
    12
    13
    14
    21
    22
    31
    32
    33
    34
    

    Embedding Scripts into Html Pages

    paxScript is consecutively developing in the direction of the internet programming. You can embed your paxPascal scripts into html pages as easy as PHP scripts. Click
    here to see a demo.

    Operator Overloading

    paxPascal allows you to overload operators "+", "-", "*", "/", "mod", "shl", "shr", "=", "<>", ">", "<", ">=", "<=". Click
    here, to see an example.

    LISPPA

    Like other paxScript languages, paxPascal supports
    LISPPA technology (List Processing based on the Polymorphic Arrays), a new technology of the processing dynamic data structures without using pointers.

    Syntax

    Remember, that paxPascal program is list of statements. Therefore you can disregard Object Pascal synax rules to make your scripts more laconic. For example, the following scripts are admissible:


    Copyright © 1999-2006 VIRT Laboratory. All rights reserved.