Why Lazarus doesn't share the same parser with FPC? lazarus / 6-IDE-CodeTools ---------------------------------------------------------------------- Leledumbo · 2008-06-03 07:18 Is FPC parser integrated with the compiler? I mean, not modular enough to be used outside of the it? This two parsers will lead to problems when a new language construct is added, such as generics. Check out my bug report: http://bugs.freepascal.org/view.php?id=10860 ---------------------------------------------------------------------- Ñuño_Martínez · 2008-06-03 12:23 AFAIK Lazarus doesn't parse any source except form description. All compilation is done by the FPC. By the way, the syntax hightlighting is done by the SynEdit component. ---------------------------------------------------------------------- Leledumbo · 2008-06-04 08:58 QuoteAFAIK Lazarus doesn't parse any source except form description. All compilation is done by the FPC. If so, then: 1. Whenever Lazarus (codetools, actually) needs to parse source codes, it has to call fpc. It takes time, man! 2. What's the purpose of pascalparsertool.pas and pascalreadertool.pas? From the header of pascalparsertool.pas: Quote This tool parses the pascal code, makes simple syntax checks and provides a lot of useful parsing functions. It can either parse complete sources or parts of it. and pascalreadertool.pas: Quote This tool provides a lot of useful functions to read the output of the TPascalParserTool. 3. Read this wiki pages. QuoteBy the way, the syntax hightlighting is done by the SynEdit component. Yes, I know but I'm not talking about it. ---------------------------------------------------------------------- Vincent Snijders · 2008-06-04 09:46 The parser of the Lazarus code tools are more lenient against syntax errors in the source code, they still work for partial code still under construction. The fpc compiler parser simply reports errors and stops parsing. So their goals and restrictions are different, therefore two parsers are used/needed. ---------------------------------------------------------------------- Leledumbo · 2008-06-04 10:17 QuoteThe parser of the Lazarus code tools are more lenient against syntax errors in the source code, they still work for partial code still under construction. But in my case, it always stops at first error, exactly the same as the compiler. For example, consider this declaration: Code: [Select] var   i: Integer // missing ';' ... type   TSomeClass = class     procedure SomeProc;   end; then I place the cursor around the class (let's say... after the SomeProc;) and press ctrl+alt+c for class completion. Instead of just doing what I want, it stops at the missing ';' in i declaration. What makes it different then? ---------------------------------------------------------------------- Vincent Snijders · 2008-06-04 10:52 If you got an error in another unit, the compilation might fail, but  the code tools still work. ---------------------------------------------------------------------- Leledumbo · 2008-06-04 11:21 Well, that counts (anything else?). But still, the two parsers doesn't share the same language construct (as the bug I reported above). They should, at least that's if you (developers) don't want to write the same thing twice. ---------------------------------------------------------------------- Vincent Snijders · 2008-06-04 11:32 Parsing is not the problem, putting it into a data structure that can be used by both is the problem. Then you need to 'parsers' to interpret the resulting data structure, one suitable for the compiler, one suitable for code tools. BTW: there is third parser in the fpc\packages\fcl-passrc directory, you might wonder why the fpc team wrote yet another parser for reading the pascal files to produce the fpdoc documentation. ---------------------------------------------------------------------- Leledumbo · 2008-06-04 11:55 QuoteParsing is not the problem, putting it into a data structure that can be used by both is the problem. Then you need to 'parsers' to interpret the resulting data structure, one suitable for the compiler, one suitable for code tools. Well, that's the damn solution I'd like to say. Quote...you might wonder why the fpc team wrote yet another parser... Yeah, do you know the answer? I hope it's for the solution of this (this topic) problem. ---------------------------------------------------------------------- Vincent Snijders · 2008-06-04 12:03 Because parsing source is easier than parsing custom data structures tweaked for binary code generation.