我使編譯的C++和我到達代碼生成電平(由MIPS),我想生成組合物如何在C++中編譯編譯器?
在YACC的組合物中的規則是:
variable:
object_access
|.....some rule not important here
;
object_access:
variable '.' name
|.....some rule not important here
;
當輸入爲:
class screw
{
int number;
screw();
}
class wheel
{
int type;
screw scw;// here composition
wheel();
}
class car
{
string model;
wheel whl;// here composition
}
void main()
{
car vec=new car();
cout<<vec.whl.scw.number;
}
當我參觀了object_access節點(生成的代碼),我可以得到(可變& &名)
我的問題是:
當我有像(vec.whl.scw.number)我不知道(vec.whl.scw.number)的長度,因爲它工作遞歸左。我需要的長度,因爲(我知道如果我加載(vec,whl,scw),我會得到的地址,但如果我加載(數字),我會得到一個整數值。 object_access節點遞歸我只需要通過vec的地址加載whl的地址並將其放入($ t1 ..例如),然後我通過whl的地址加載scw的地址並將其放入($ t1 ..例如),但(數量不是對象,我不能將它保存在($ t1))..
我的問題:我如何知道object_access節點中的姓以停止加載地址?需要$ t1保存object_access節點中的最後一個地址,因爲我將需要它到另一個操作。
多數民衆贊成在一個非常長句...你能用一些標點符號來使它可讀嗎? – user463035818
現在清楚了@ tobi303? – sam
你好。如果您使用手機發布信息,而這又會導致您以小寫字母和txtspk書寫,請使用更易於輸入的內容。我們非常感謝這裏的一些問題 - 謝謝! – halfer