[Pas2js] Using the Pas2JS transpiler to transpile itself
Michael Van Canneyt
michael at freepascal.org
Thu Jul 19 13:21:10 CEST 2018
On Thu, 19 Jul 2018, Stephen Wright via Pas2js wrote:
> Hi Guys
>
> I have taken a look at what is involved in getting Pas2JS to transpile itself so it can run in the browser.
> The issue seems to be the parser units shared with Free Pascal which make extensive use of PChars, Array of Const etc.
> This is beyond my skill level to work on personally, but I am happy to help sponsor some work by others if there are
> enough people interested to make this practical.
Consider it practical :)
> Is anyone else interested in sharing the cost ?
I am. This is actually one of the goals of pas2js, to be self-compiling.
[ It would allow - this is my end goal - to run lazarus in the browser :) ]
> Regards Steve
> P.S. As a short term solution we have modified the Castalia/Delphi parser to be transpilable by Pas2JS
> and linked it to a very cut down JavaScript backend in order to allow simplified Pascal scripts
> to run in the browser. Could this Castalia work help with getting the full Pas2JS running in the browser?
I doubt it will help. Eventually the parser must be made portable.
I have talked about this more than once with Mattias Gaertner.
We considered the cost not so prohibitively.
The pas2js parser is actually not so difficult to change.
The use of pchar is limited to the scanner.
fpJSON would also need to be ported and the JS AST tree.
This is again not so difficult as it may seem.
The parser/scanner unit are separated out from the data structures:
in the browser, it is better to use the built in browser parser/scanner,
and build the JSON document from that.
What we would need from Mattias is an estimate on how much work this is
going to be, and then we can see how much money needs to be collected.
I will discuss this, and will post results here, if that is OK with you ?
Michael.
More information about the Pas2js
mailing list