Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2019-09

Code explorer implementation

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ryan Joseph

I want to make a tool that can analyze source files for functions/classes etc... that can be used for auto complete in 3rd party editors. I see Lazarus already has such a “Code Explorer” feature and I wonder how it gets this information and if I could scavenge it from the project. Does anyone have any ideas on this, where to look in the Lazarus sources, etc...? I think it may be possible to use .ppu files also but I’m not sure if the information is as complete as what Lazarus has.

Regards,
Ryan Joseph

Reply by email

Michael Van Canneyt
to Ryan Joseph
Ryan Joseph wrote 7 lines
I want to make a tool that can analyze source files for functions/classes etc... that can be used for auto complete in 3rd party editors. I see Lazarus already has such a “Code Explorer” feature and I wonder how it gets this information and if I could scavenge it from the project. Does anyone have any ideas on this, where to look in the Lazarus sources, etc...? I think it may be possible to use .ppu files also but I’m not sure if the information is as complete as what Lazarus has.

No the ppu will not be as complete.

You can also try the fcl-passrc sources. It is standalone by design, and can give you all info that lazarus gives you.

It's used for the pas2js compiler, so you can be sure the info is very complete.

Michael.

Reply by email

Ryan Joseph
to Michael Van Canneyt
On Sep 13, 2019, at 12:19 PM, Michael Van Canneyt via lazarus wrote: You can also try the fcl-passrc sources. It is standalone by design, and can give you all info that lazarus gives you.

Thanks Michael this looks like exactly what I want. How well do they keep up with new syntax etc…? I was thinking of making my own parser before but I didn’t want to keep up with changing syntax and things breaking.

Regards,
Ryan Joseph

Reply by email

Ryan Joseph
to Michael Van Canneyt: No the ppu will not be as complete. You can also try the fcl-passrc sources. It is…

A follow up. I built the parsepp.pp program and used it to parse a file. Everything seems to work except it tries to follow include macros (that would be nice to turn off since it requires compiler flags to work properly) and += operators are causing errors. Why doesn’t it know c style operators?

EParserError: Identifier expected at token "=" in file /Users/ryanjoseph/Desktop/parser_test.pas at line 5 column 6

program test;
begin
  i += 1;
end.

Regards,
Ryan Joseph

Reply by email

Michael Van Canneyt
to Ryan Joseph
Ryan Joseph wrote 5 lines
A follow up. I built the parsepp.pp program and used it to parse a file. Everything seems to work except it tries to follow include macros (that would be nice to turn off since it requires compiler flags to work properly) and += operators are causing errors. Why doesn’t it know c style operators?

It mimics FPC in behaviour.

By default, FPC also does not allow C style operators.

You need to provide the -Sc command-line flag to the parser or set the appropriate flag manually on the parser object.

Normally this should do it:

parsepp -Sc yourfile.

the parser understands all directives and compiler flags that FPC itself understands. So you can just do
parsepp -Sc yourfile. -Fi../your/include/dir

Michael.

Reply by email

Michael Van Canneyt
to Ryan Joseph: Thanks Michael this looks like exactly what I want. How well do they keep up with new…
Ryan Joseph wrote 7 lines
> On Sep 13, 2019, at 12:19 PM, Michael Van Canneyt via lazarus wrote: > > You can also try the fcl-passrc sources. It is standalone by design, and can give you all info that lazarus gives you. Thanks Michael this looks like exactly what I want. How well do they keep up with new syntax etc…?

It is fully equivalent to FPC, it currently allows even more: anonymous functions are supported.

Michael.

Reply by email

Ryan Joseph
to Michael Van Canneyt: It mimics FPC in behaviour. By default, FPC also does not allow C style operators. You…
Show quoted text 5 lines
On Sep 14, 2019, at 2:07 PM, Michael Van Canneyt via lazarus wrote: By default, FPC also does not allow C style operators. You need to provide the -Sc command-line flag to the parser or set the appropriate flag manually on the parser object.

I tried using -Mobjfpc because I know c style operators are a mode switch but that didn’t work. I guess modes are not supported in the parser and we need to use all the various -S flags?

Regards,
Ryan Joseph

Reply by email

Michael Van Canneyt
to Ryan Joseph
Ryan Joseph wrote 10 lines
> On Sep 14, 2019, at 2:07 PM, Michael Van Canneyt via lazarus wrote: > > By default, FPC also does not allow C style operators. > > You need to provide the -Sc command-line flag to the parser or set the appropriate flag manually on the parser object. I tried using -Mobjfpc because I know c style operators are a mode switch but that didn’t work. I guess modes are not supported in the parser and we need to use all the various -S flags?

Modes & modeswitches are supported, but -Mobjfpc does not switch on C style operators.

You need -Sc, just as in FPC, the -M command-line switch is not supported by the ParseSource() routine, it has only a limited set of options implemented.

if you need/want more control, you can just create the scanner and parser, and set any flag you want: the ParseSource is a simple routine that will set up the parser/scanner with some very basic options.

Michael.

Reply by email

Sven Barth
to Ryan Joseph: I tried using -Mobjfpc because I know c style operators are a mode switch but that…

Ryan Joseph via lazarus schrieb am Sa., 14.
Sep. 2019, 20:18:

Show quoted text 14 lines
> On Sep 14, 2019, at 2:07 PM, Michael Van Canneyt via lazarus < > wrote: > > By default, FPC also does not allow C style operators. > > You need to provide the -Sc command-line flag to the parser or set the appropriate flag manually on the parser object. I tried using -Mobjfpc because I know c style operators are a mode switch but that didn’t work. I guess modes are not supported in the parser and we need to use all the various -S flags?

As I already wrote some time ago C-style operators are *not* enabled by default in any of the modes. Also they aren't a modeswitch either. They are simply switched on inside the default fpc.cfg using the -Sc option. Thus, as Michael wrote, you need to pass that parameter as well or explicitly set the corresponding flag of the parser object.

Regards,
Sven

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20190915/ab0e708d/attachment-0001.html>

Reply by email