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?
Mailing lists / fpc-devel / 2013-01
Where are parser sources?
10 messages · 7 people · –
- AAndrzej Borucki 3
- JJonas Maebe 2
- AAnton Kavalenka 1
- HHans-Peter Diettrich 1
- MMichael Van Canneyt 1
- NNicholas Ring 1
- +1 more
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Andrzej Borucki wrote 6 lines
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
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
Andrzej Borucki wrote 8 lines
No, there is no definition anywhere. The parser was not written starting from a formal grammar either.
Jonas
2013/1/3 Jonas Maebe Thanks. It is possible restore EBNF grammar from this sources? It is
Andrzej Borucki wrote 13 lines
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
The lexer is mostly in scanner.pas The parser is in pbase.pas (base parser routines),…
Jonas Maebe wrote 19 lines
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
Anton Kavalenka wrote 29 lines
While I'm not Jonas I can answer you nevertheless: the file is $fpcdir/compiler/scandir.pas in the procedure "dir_resource".
Regards,
Sven
I have also found the following: http://dgrok.excastle.com/Grammar.html…
Show quoted text 11 lines
Perhaps pparser.pp will be helpful?
It's used by LazDoc (and Lazarus IDE?)
DoDi
Hans-Peter Diettrich wrote 15 lines
It's probably easier to restore the grammar from pparser than from the compiler sources.
Michael.
2013/1/4 Michael Van Canneyt
Show quoted text 5 lines
Now I look "Free Pascal :Reference guide." - ref.pdf and there is grammar
Andrzej Borucki
