FPC Compiler source needed lazarus / 64-FPC development ---------------------------------------------------------------------- Researching · 2019-12-19 02:55 Hi, everyone! Need to build an XML tree of code. So want to use FPC source in the project. Actually the parcer and lexer (? if words are correct ). How to find them in sourcecode? Any suggestions of interfaces, entry / output points? ANSWERS: 1. parcer and scanner are spread over whole compiler code 2. use CodeTools [for xml tree of code] 3. use fcl-passrc [used in Pascal-to-JavaScrip] ---------------------------------------------------------------------- PascalDragon · 2019-12-19 08:30 FPC's parser and scanner are spread through the whole compiler source and are not separately usable in a library. I suggest you to take a look at fcl-passrc instead which is part of Free Pascal and is also used by the pas2js Pascal-to-JavaScript transpiler as well as the documentation tool fpdoc. ---------------------------------------------------------------------- valdir.marcos · 2019-12-19 09:17 Quote from: Researching on December 19, 2019, 03:55:46 amNeed to build an XML tree of code. So want to use FPC source in the project. Actually the parcer and lexer (? if words are correct ). How to find them in sourcecode? Any suggestions of interfaces, entry / output points?Quote from: PascalDragon on December 19, 2019, 09:30:53 amFPC's parser and scanner are spread through the whole compiler source and are not separately usable in a library.Never knew. I always thought all those processes were didactic separated. QuoteI suggest you to take a look at fcl-passrc instead which is part of Free Pascal and is also used by the pas2js Pascal-to-JavaScript transpiler as well as the documentation tool fpdoc. ---------------------------------------------------------------------- soerensen3 · 2019-12-19 15:48 Maybe you can use Code Tools from Lazarus. In the examples or components folder there are also basic examples. ---------------------------------------------------------------------- sash · 2019-12-19 17:28 Quote from: Researching on December 19, 2019, 03:55:46 amNeed to build an XML tree of code. https://wiki.lazarus.freepascal.org/Codetools ---------------------------------------------------------------------- Researching · 2019-12-19 19:50 Very useful answers. Will try to check. Quote from: PascalDragon on December 19, 2019, 09:30:53 amFPC's parser and scanner are spread through the whole compiler source and are not separately usable in a library. is it right, that to extract the parser and scanner is either difficult, or impossible?? ---------------------------------------------------------------------- PascalDragon · 2019-12-20 08:27 Quote from: valdir.marcos on December 19, 2019, 10:17:33 amQuote from: PascalDragon on December 19, 2019, 09:30:53 amFPC's parser and scanner are spread through the whole compiler source and are not separately usable in a library.Never knew. I always thought all those processes were didactic separated. To be fair the scanner is rather self contained, but the parser is essentially in all units having a p prefix (12 units) and they directly generate the node tree, thus they depend on all the node units (prefix n, 18 units). Some other units are required as well. So yes, the parser is deeply integrated with other parts of the compiler. Quote from: Researching on December 19, 2019, 08:50:47 pmQuote from: PascalDragon on December 19, 2019, 09:30:53 amFPC's parser and scanner are spread through the whole compiler source and are not separately usable in a library. is it right, that to extract the parser and scanner is either difficult, or impossible?? Correct. The compiler's parser and scanner are geared towards compiling Pascal code not providing potential users with information about the source. I'd go with fcl-passrc if I were you. ---------------------------------------------------------------------- Researching · 2019-12-21 03:43 Which of theese to use? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fcl-passrc     C : Lazarus 202\fpc\3.0.4\units \386-win 32\fcl-passrc       C : Lazarus 202\fpc\3.0.4\source \packages\passrcutil.ppu   C : Lazarus 202\fpc\3.0.4\units\386-win 32\fd -passrc\passrcutil.о     C : Lazarus 202\fpc\3.0.4\units \386-win 32\fd -passrc\testpassrc.lpr   C : Lazarus 202\fpc\3.0.4\source \packages\fd -passrc\tests \testpassrc.lpi   C : Lazarus 202\fpc\3.0.4\source \packages\fd -passrc\tests \tcpassrcutil.pas C : Lazarus 202\fpc\3.0.4\source \packages\fd -passrc\tests \passrcutil.pp    C : Lazarus 202\fpc\3.0.4\source \packages\fd -passrc\src\fd -passrc.fpm   C : Lazarus 202\fpc\3.0.4\fpmkinst\386-win 32\ ---------------------------------------------------------------------- PascalDragon · 2019-12-21 10:19 Here is an example. Alternatively you can look at the examples in $fpcdir/packages/fcl-passrc/examples. ---------------------------------------------------------------------- avra · 2019-12-23 00:42 Quote from: Researching on December 19, 2019, 03:55:46 amAny suggestions of interfaces, entry / output points? Some nice info can be found here: https://wiki.freepascal.org/Make_your_own_compiler,_interpreter,_parse r,_or_expression_analyzer ---------------------------------------------------------------------- Tenaja · 2020-03-01 16:06 I found Crenshaw's "Let's build a compiler" article very helpful. With that as a guide, I wrote a compiler for a specific target, and also two simple parsers that are not too different from json.  It's even in Pascal... https://www.compilers.iecc.com/crenshaw/