in reply to Re: I wrote an expression parser for PPI
in thread I wrote an expression parser for PPI
To shake out bugs and semantic differences, the plan is to run existing test suites from CPAN etc. It’ll probably take a few more weeks before the implementation is solid enough to run arbitrary Perl code.
The pcl is intentionally naive. Speed, like XS support, is a problem for version 3. :-( The target is that we can start building Perl compilers now.
In this version, all variables are boxed as small structs, even when no references are taken (or variables that are just numbers). Once the expression parser was done, putting together a proof-of-concept Perl compiler was pretty easy. (that was a weird sentence to write!) But to be sure, I haven't really thought about e.g. threads and string evals will be done when this compiler/transpiler is itself compiled to CL.
I picked Common Lisp as a target because it has good compilers and the semantics should support Perl well. This $x + foo(5) is just translated to (pl-+ $x (pl-foo 5)). All Perl operators and built-ins are just mapped to functions/macros in a runtime. The output is readable to Perl programmers and also works as an intermediate representation for e.g. other compilers (Raku?).
JavaScript would be really useful and has fast compiler, but it would be hard to compile XS to the browser (WebAssembly?). Most of a compiler's frontend should be solved with PPI and this project.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: I wrote an expression parser for PPI
by LanX (Saint) on Jan 08, 2026 at 15:46 UTC | |
by BerntB (Deacon) on Jan 08, 2026 at 20:55 UTC | |
by LanX (Saint) on Jan 08, 2026 at 22:04 UTC | |
by BerntB (Deacon) on Jan 09, 2026 at 07:15 UTC | |
by LanX (Saint) on Jan 09, 2026 at 20:59 UTC | |
|