[fpc-pascal] fcl-passrc method/function invocations
Michael Van Canneyt
michael at freepascal.org
Tue Oct 15 23:40:50 CEST 2019
On Tue, 15 Oct 2019, Ryan Joseph wrote:
>
>
>> On Oct 15, 2019, at 5:02 PM, Mattias Gaertner via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>>
>> When parsing a program the module is a TPasProgram, which has a
>> ProgramSection.
>
> Of course, thanks.
>
> A couple other questions if you don’t mind:
>
> 1) Are there any examples of the resolver? I’m looking through the unit and it looks pretty dense.
Only pas2js.
But there are a lot of test cases, though. Probably they are more suitable
to understand the structure.
>
> 2) Can the parser take strings as input or just files? I ask because I
> have a string without a file and currently I’m saving it into a temporary
> file and giving that to the parser.
The parser can take streams as input. You can create a TStringStream.
But then you must create the parser manually, and not use ParseSource.
The testsuite contains many examples of how to do that. see the tcpars*
units.
>
> 3) Can the parser handle code fragments? If not is that something I can possible extend it to accommodate?
That's going to be difficult. The parser expects there to be a module.
It's probably easier to encapsulate the code fragment in a minimal module.
Again, see the testsuite for how to do this.
Michael.
More information about the fpc-pascal
mailing list