Sign in Join

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

Mailing lists / fpc-devel / 2013-01

Where are parser sources?

10 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

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

Andrzej Borucki

I look to fpc-2.6.0.source.zip, directory fpc-2.6.0\compiler. I see array arraytokeninfo in file tokens.pas where are keywords like 'repeat' and 'until'. But I can't find any parser (and lexer, dfa etc). How FreePascal compiler proceed with grammar?

Reply by email

Jonas Maebe
to Andrzej Borucki
Andrzej Borucki wrote 6 lines
I look to fpc-2.6.0.source.zip, directory fpc-2.6.0\compiler. I see array arraytokeninfo in file tokens.pas where are keywords like 'repeat' and 'until'. But I can't find any parser (and lexer, dfa etc). How FreePascal compiler proceed with grammar?

The lexer is mostly in scanner.pas

The parser is in pbase.pas (base parser routines), pstatmnt.pas (parsing statements), pexpr.pas (parsing expressions), pdecl.pas (generic declaration parsing), pdecvar.pas (parsing variable and property declarations), pdecsub.pas (parsing procedure/method declarations), pdecobj.pas (parsing object/class declarations), ptype.pas (generic type parsing).

The parser is a manually written recursive-descent parser. There is no formal grammar.

Jonas

Reply by email

Jonas Maebe
to Andrzej Borucki
Andrzej Borucki wrote 8 lines
2013/1/3 Jonas Maebe > The parser is a manually written recursive-descent parser. There is no > formal grammar. > Thanks. It is possible restore EBNF grammar from this sources? It is difficult, is anywhere definitions?

No, there is no definition anywhere. The parser was not written starting from a formal grammar either.

Jonas

Reply by email

Nicholas Ring
to Andrzej Borucki: 2013/1/3 Jonas Maebe Thanks. It is possible restore EBNF grammar from this sources? It is
Andrzej Borucki wrote 13 lines
2013/1/3 Jonas Maebe < > The parser is a manually written recursive-descent parser. There is no formal grammar. Thanks. It is possible restore EBNF grammar from this sources? It is difficult, is anywhere definitions? I found: http://www.geocities.ws/robertzierer/Grammar.html http://bernhard.userweb.mwn.de/Pascal-EBNF.html http://www.felix-colibri.com/papers/compilers/pascal_grammar/pascal_grammar.html

I have also found the following:
http://dgrok.excastle.com/Grammar.html
http://goldparser.org/grammars/index.htm

But nothing that does generics.
There is also: https://github.com/jacobthurman/Castalia-Delphi-Parser but I don't know how compatible it is with FreePascal and from I last heard, doesn't handle generics..

Cheers,
Nick

Reply by email

Anton Kavalenka
to Jonas Maebe: The lexer is mostly in scanner.pas The parser is in pbase.pas (base parser routines),…
Jonas Maebe wrote 19 lines
On 03 Jan 2013, at 07:52, Andrzej Borucki wrote: > I look to fpc-2.6.0.source.zip, directory fpc-2.6.0\compiler. I see array > arraytokeninfo in file tokens.pas where are keywords like 'repeat' and > 'until'. But I can't find any parser (and lexer, dfa etc). How FreePascal > compiler proceed with grammar? The lexer is mostly in scanner.pas The parser is in pbase.pas (base parser routines), pstatmnt.pas (parsing statements), pexpr.pas (parsing expressions), pdecl.pas (generic declaration parsing), pdecvar.pas (parsing variable and property declarations), pdecsub.pas (parsing procedure/method declarations), pdecobj.pas (parsing object/class declarations), ptype.pas (generic type parsing). The parser is a manually written recursive-descent parser. There is no formal grammar.

Dear Jonas,

could you point me where is $R directive is handled , I'd like to make patch for
http://bugs.freepascal.org/view.php?id=20652

regards,
Anton

Show quoted text 8 lines
Jonas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Sven Barth
to Anton Kavalenka
Anton Kavalenka wrote 29 lines
On 03.01.2013 12:42, Jonas Maebe wrote: > > On 03 Jan 2013, at 07:52, Andrzej Borucki wrote: > >> I look to fpc-2.6.0.source.zip, directory fpc-2.6.0\compiler. I see >> array >> arraytokeninfo in file tokens.pas where are keywords like 'repeat' and >> 'until'. But I can't find any parser (and lexer, dfa etc). How >> FreePascal >> compiler proceed with grammar? > > The lexer is mostly in scanner.pas > > The parser is in pbase.pas (base parser routines), pstatmnt.pas > (parsing statements), pexpr.pas (parsing expressions), pdecl.pas > (generic declaration parsing), pdecvar.pas (parsing variable and > property declarations), pdecsub.pas (parsing procedure/method > declarations), pdecobj.pas (parsing object/class declarations), > ptype.pas (generic type parsing). > > The parser is a manually written recursive-descent parser. There is > no formal grammar. Dear Jonas, could you point me where is $R directive is handled , I'd like to make patch for http://bugs.freepascal.org/view.php?id=20652

While I'm not Jonas I can answer you nevertheless: the file is $fpcdir/compiler/scandir.pas in the procedure "dir_resource".

Regards,
Sven

Reply by email

Hans-Peter Diettrich
to Nicholas Ring: I have also found the following: http://dgrok.excastle.com/Grammar.html…
Show quoted text 11 lines
On 4/01/2013 7:10 AM, Andrzej Borucki wrote: > 2013/1/3 Jonas Maebe < > > > > The parser is a manually written recursive-descent parser. There > is no formal grammar. > > > Thanks. It is possible restore EBNF grammar from this sources? It is > difficult, is anywhere definitions?

Perhaps pparser.pp will be helpful?
It's used by LazDoc (and Lazarus IDE?)

DoDi

Reply by email

Michael Van Canneyt
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 15 lines
Nicholas Ring schrieb: > > On 4/01/2013 7:10 AM, Andrzej Borucki wrote: >> 2013/1/3 Jonas Maebe < >> > >> >> The parser is a manually written recursive-descent parser. There >> is no formal grammar. >> >> >> Thanks. It is possible restore EBNF grammar from this sources? It is >> difficult, is anywhere definitions? Perhaps pparser.pp will be helpful? It's used by LazDoc (and Lazarus IDE?)

It's probably easier to restore the grammar from pparser than from the compiler sources.

Michael.

Reply by email

Andrzej Borucki
to Michael Van Canneyt

2013/1/4 Michael Van Canneyt

Show quoted text 5 lines
It's probably easier to restore the grammar from pparser than from the compiler sources. Michael.

Now I look "Free Pascal :Reference guide." - ref.pdf and there is grammar

Andrzej Borucki

Reply by email