Recent

Author Topic: Why Lazarus doesn't share the same parser with FPC?  (Read 9478 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Why Lazarus doesn't share the same parser with FPC?
« on: June 03, 2008, 09:18:19 am »
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

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
RE: Why Lazarus doesn
« Reply #1 on: June 03, 2008, 02:23:01 pm »
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.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
RE: Why Lazarus doesn
« Reply #2 on: June 04, 2008, 10:58:16 am »
Quote
AFAIK 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.

Quote
By the way, the syntax hightlighting is done by the SynEdit component.

Yes, I know but I'm not talking about it.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Why Lazarus doesn
« Reply #3 on: June 04, 2008, 11:46:42 am »
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

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
RE: Why Lazarus doesn
« Reply #4 on: June 04, 2008, 12:17:54 pm »
Quote
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.

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

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Why Lazarus doesn
« Reply #5 on: June 04, 2008, 12:52:34 pm »
If you got an error in another unit, the compilation might fail, but  the code tools still work.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
RE: Why Lazarus doesn
« Reply #6 on: June 04, 2008, 01:21:45 pm »
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

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Why Lazarus doesn
« Reply #7 on: June 04, 2008, 01:32:05 pm »
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

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
RE: Why Lazarus doesn
« Reply #8 on: June 04, 2008, 01:55:50 pm »
Quote
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.

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

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Why Lazarus doesn
« Reply #9 on: June 04, 2008, 02:03:44 pm »
Because parsing source is easier than parsing custom data structures tweaked for binary code generation.

 

TinyPortal © 2005-2018