Page 6 - FREE_TRIAL6Months
P. 6

PAS2JS – PASCAL TO JAVASCRIPT TRANSPILER PAGE 1/5

BY MATTIAS GAERTNER

INTRODUCTION                                              pas2js command line options
JavaScript has become a lingua franca on web              Pas2JS Compiler version 0.4.0+standard
browsers and powerful enough to run even complex          Copyright (c) 2016 Blaise Pascal Magazine
applications. But it still suffers from its lack of type  written by Mattias Gaertner
safety and good RAD tools.
                                                          Usage: /usr/bin/pas2js <your.pas>
      PJ-Suite tries to solve this gap, by providing
pas2js and Delphi/Lazarus add-ons to use the              Options:
IDE’s form designers to create web
applications without needing a server                     Put + after a boolean switch option to
component.
                                                          enable it, - to disable it
      This article is about the Pascal to JavaScript
transpiler pas2js.                                        @<x> : Read compiler options from file
The term “transpiler” or “transcompiler” describes a
program which translates sources of one                   <x> in
programming language to another of similar
abstraction level.                                        addition to the default pas2js.cfg

      As the resulting JavaScript lacks the Pascal        -B : Rebuild all
strong type safety the result is not fully equivalent
and thus cannot be translated back you might prefer       -d<x> : Defines the symbol <x>
the term “compiler”.
Pas2js is a console program similar to Delphi’s           -i<x> : Write information and halt.
compiler dcc64.exe and Free Pascal’s fpc.exe.
That means when you call it with the project1.dpr         <x> is a combination of the following
or project1.lpr as parameter it recursively
processes all used units and creates one or more          letters:
.js files.
The HTML-file then only needs to load the .js file(s).    V : Write short compiler version

      Pas2js is written completely in Free Pascal and     W : Write full compiler version
runs on Windows, Linux, Mac, BSD, etc.
It’s command line options are almost the same as          -F...     Set file names and paths:
fpc’s, with only a few JavaScript specific ones:
                                                          -Fe<x> : Redirect output to <x>
PAS2 JS
                                                          -Fi<x> : Add <x> to include paths
     PAS2JS / PJ SUITE: ROADMAP
                                                          -Fu<x> : Add <x> to unit paths
       2016 - November
                                                          -FU<x> : Set unit output path to <x>
      Finalization of the compiler
      Start testing of the compiler                       -I<x> : Add <x> to include paths,
      Implementation into DELPHI and LAZARUS
      Start building the PJ SUITE in collaboration                  same as -Fi
      with TMS Software and their principle FNC
                                                          -J...     Extra options of pas2js
       2017- January
                                                          -Jc : Write all JavaScript
      Beginning of testing PJ Suite.
      Testers are needed: please respond to                         concatenated into the
      office@Blaisepascal.eu
      2017 - March:                                                 output file
      planned first presentation
      2017 - May:                                         -Jl : lower case identifiers
      planned definitive version 1.0 of PJ Suite
                                                          -Ju<x> : Add <x> to foreign unit paths.

                                                                    Foreign units are not compiled.

                                                          -l : Write logo

                                                          -MDelphi: Delphi 7 compatibility mode

                                                          -MObjFPC: FPC's Object Pascal

                                                                  compatibility mode (default)

                                                          -n : Do not read the default

                                                                    config files

                                                          -o<x> : Change main JavaScript file to

                                                                    <x>, "." means stdout

                                                          -S<x> : Syntax options.

                                                                    <x> is a combination

                                                                    of the following letters:

                                                          c : Support operators like

                                                                    C (*=,+=,/= and -=)

                                                          d : Same as -Mdelphi

                                                          2 : Same as -Mobjfpc (default)

                                                          -u<x> : Undefines the symbol <x>

                                                          -v<x> : Be verbose.

                                                                    <x> is a combination of the

                                                                    following letters:

                                                          e : show errors (default)

                                                          w : show warnings

                                                          n : show notes

                                                          h : show hints

                                                          i : show info

                                                          l : show line numbers

                                                          a : show everything

                                                          0 : show nothing (except errors)

                                                          b : show file names with full path

                                                          c : show conditionals

                                                          t : show tried/used files

                                                          d : show debug notes and info,

                                                                    enables -vni

                                                          q : show message numbers

                                                          x : show used tools

                                                          -vm<x>,<y>: Do not show messages

                                                                    numbered

                                                                    <x> and <y>.

                                                          -? : Show this help

                                                          -h : Show this help

                                                          end of pas2js command line options

Issue Nr 8 2016 BLAISE PASCAL MAGAZINE                              PAS2 JS                          5
   1   2   3   4   5   6   7   8   9   10   11