digitalmars.D - understanding the dmd frontend
- aelmetwaly (8/8) Oct 02 2004 Hi there,
- Deja Augustine (16/27) Oct 02 2004 The lexer takes the source file stored as one long string and splits it
Hi there, I want to understand how the dmd frontend work. from the moment the source file read into memory till its fed into the backend. what is the difference between the lexer and the parser? what are the relevant classes in the dmd source directory? How can one write a program to convert from d source into xml datasource which could be used in, for instance, Intillisence editors and code completions? Is there any sample code for a simple parser? thanks.
Oct 02 2004
aelmetwaly wrote:Hi there, I want to understand how the dmd frontend work. from the moment the source file read into memory till its fed into the backend. what is the difference between the lexer and the parser?The lexer takes the source file stored as one long string and splits it up into tokens. It also attaches information about each token such as what it represents (an identifier, a string, a numeric literal, etc...) The parser then takes those tokens and constructs a syntax tree from them. It converts a series of tokens (such as 'int' 'nVar' ';') and creates a VarDeclaration instance from them.what are the relevant classes in the dmd source directory?I'd study and learn the headers declaration.h, expression.h and statement.h at the VERY least. It's a good starting point. To give you a little hint, *Declaration are used to hold information about lines of code such as: "int var;" or "void func(...) {...}" Expressions hold code such as "var = 5" "3 + 5" Statements are things such as "if(...) {...}" "while(...) {...}" "return ...;"How can one write a program to convert from d source into xml datasource which could be used in, for instance, Intillisence editors and code completions? Is there any sample code for a simple parser? thanks.Figuring that out is 90% of the work. -Deja
Oct 02 2004