开发者

Compiler/Bootstrapping - Slower by recompiling off old bootstrapped compilers?

开发者 https://www.devze.com 2023-03-17 18:25 出处:网络
I have been rereading http://cm.bell-labs.com/who/ken/trust.html and I cannot seem to grasp the concept in Stage II with the vertical tab. My question to you guys is: Are characters being checked twic

I have been rereading http://cm.bell-labs.com/who/ken/trust.html and I cannot seem to grasp the concept in Stage II with the vertical tab. My question to you guys is: Are characters being checked twice over now with the inclusion of the \v escape character? Because the way I see it is that with this new compiler installed, when \v is used, it will go through the code in figure 3, and then at the ret开发者_C百科urn('\v') statement, the code in figure 4 will then be called which returns the true ASCII representation of a vertical tab. Wouldn't this slow down the compile time although it makes for a better representation of the current compiler? Please let me know if you need me to rephrase my question. Cheers!


The code is not traversed twice. In the initial state, Fig. 3 cannot be compiled because \v has no defined meaning. (Just think of it as a fancy variable that is defined inside the compiler.)

Once you've compiled Fig. 4's code you have stated that \v stands for 11. The resulting compiler can map \v to a value, thus you can define \v to stand for \v.

A non-compiler example with real variables would be something like this:

x = 11;
/* ... */
x = x;

Once you've defined what x stands for, you can use it and even assign its value to itself. The main difference to the parser is that instead of having the two declarations at different positions in the same file, the definitions of \v are spread across two different versions of the compiler, with the second one compiled by the new compiler (because the old compiler does not include this definition).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号