Production | Semantic Rules |
---|---|
pd → PROC np IS ds BEG ss END ; | ds.offset = 0 |
ds → d ds1 |
d.offset = ds.offset ds1.offset = d.newoffset |
ds.totalSize = ds1.totalSize | |
ds → ε | ds.totalSize = ds.offset |
d → di : ty ; | addType(di.entry, ty.type) addSize(di.entry, ty.size) addOffset(di.entry, d.offset) d.newoffset = d.offset + ty.size |
di → ID | di.entry = ID.entry |
ty → ARRAY [ NUM ] OF ty1 |
ty.type = array(NUM.value, t1.type) ty.size = NUM.value * t1.size |
ty → INT |
ty.type = integer ty.size = 4 |
ty → REAL |
ty.type = real ty.size = 8 |
e → t |
e.addr = t.addr e.code = t.code |
e → e1 ADDOP t |
e.addr = new Temp() e.code = e1.code || t.code || gen(e.addr = e1.addr ADDOP.lexeme t.addr) |
t → f |
t.addr = f.addr t.code = f.code |
t → t1 MULOP f |
t.addr = new Temp() t.code = t1.code || f.code || gen(t.addr = t1.addr MULOP.lexeme f.addr) |
f → ( e ) |
f.addr = e.addr f.code = e.code |
f → NUM |
f.addr = get(NUM.lexeme) f.code = "" |
f → ID ins |
assume indices is ε f.addr = get(ID.lexeme) f.code = "" |