[spec] Phases of translation

Walter Bright newshound2 at digitalmars.com
Mon May 20 16:13:39 UTC 2019


On 5/20/2019 4:51 AM, Dibyendu Majumdar wrote:
> On Monday, 20 May 2019 at 07:34:43 UTC, Walter Bright wrote:
>> The Translation Phases are conceptual, the compiler may not actually do them 
>> that way, it's just supposed to be "as if" they were done that way.
>>
> 
> Okay thank you. From the spec point of view I guess the important thing is to 
> clarify any constraints this places on D. One constraint obviously is that the 
> parsing into syntax tree requires arbitrary lookahead of tokens. Are there other 
> constraints that need to be highlighted?

The spec isn't a tutorial in that the consequences don't necessarily need to be 
spelled out. The crucial thing to know is that the tokenizing is independent of 
parsing, and parsing is independent of semantic analysis.

I.e. the definition of a token does not change depending on what construct is 
being parsed, and the AST generated by the parser can be created without doing 
any semantic analysis (unlike C++).

These consequences fall out of the rest of the spec, hence they should be more 
of a clarification in the introduction. The idea is to head off attempts to add 
changes to D that introduce dependencies. Such proposals do crop up from time to 
time, for example, user-defined operator tokens.



More information about the Digitalmars-d mailing list