id
stringlengths
36
36
text
stringlengths
1
1.25M
0218c71e-c164-42a0-9fff-8d19d0cbe950
public void setCustomText14(java.lang.String customText14) { this.customText14 = customText14; }
6d111ecb-7a2c-405c-b105-85c9c66415df
public void setCustomPhone2(crmondemand.xml.customobject3.query.QueryType customPhone2) { this.customPhone2 = customPhone2; }
0b70a693-17b5-4aa6-acae-e3b4209922f7
public void setCustomDate3(java.util.Calendar customDate3) { this.customDate3 = customDate3; }
6461c05e-eaa1-4ebd-af75-65d3dea54d99
public void setCustomBoolean19(crmondemand.xml.customobject3.query.QueryType customBoolean19) { this.customBoolean19 = customBoolean19; }
69b9d3f3-4201-424b-a261-469a93ec928b
public java.lang.String getCustomObject14IntegrationId() { return this.customObject14IntegrationId; }
eb510272-ac6f-4714-9464-5980fcd8b850
private void RegresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RegresarActionPerformed // TODO add your handling code here: Pedido p = new Pedido(); p.setVisible(true); p.pack(); }//GEN-LAST:event_RegresarActionPerformed
2c23e957-f2fc-4b8f-ab00-fa1e5e797867
public java.lang.String getCustomText33() { return this.customText33; }
3543f89b-af21-4c46-959d-6942e7166470
public void setDrink(String drink){ this.drink = drink; }
02e08bae-d0ea-4f02-bb44-67816b6d1689
opcode cb_45 = new opcode() { public void handler(){ BIT(0,Z80.HL.L); }}
196902b8-837d-413c-9806-01449d9adc3c
public void setCustomBoolean16(java.lang.Boolean customBoolean16) { this.customBoolean16 = customBoolean16; }
5df72594-4ba7-4df6-af35-cad0a4fed43c
@Override public void add(int index, E element) { Link<E> add, next = head, prev; for (int i = 1; i <= index; i++) { next = next.getNext(); } prev = next.getPrev(); add = new Link<E>(element, prev); add.setNext(next); prev.setNext(add); next.setPrev(add); size++; }
9abbcaaa-d83c-491b-97b4-e2680eb5ac1b
public void setCustomCurrency2(java.math.BigDecimal customCurrency2) { this.customCurrency2 = customCurrency2; }
a67e6b37-d4fd-49d0-b0e1-5c9240b2308f
@Override public void writeRegister() { }
b2157eab-af28-450a-8fce-6eaa9eb3aaa6
public boolean hasArmor() { return ((bitField0_ & 0x00000800) == 0x00000800); }
9d534b95-aec5-4874-b6af-5314d95ab9ed
public void handler() { //long *d_dst = & DY; set_DY(get_DY() ^ (get_DY() >>> 16) & 0x0000ffffL); set_DY(get_DY() ^ (get_DY() << 16) & 0xffff0000L); set_DY(get_DY() ^ (get_DY() >>> 16) & 0x0000ffffL); m68k_cpu.n_flag = GET_MSB_32(get_DY()); m68k_cpu.not_z_flag = get_DY(); m68k_cpu.c_flag = 0; m68k_cpu.v_flag = 0; USE_CLKS(4); if (m68klog != null) { fprintf(m68klog, "swap :PC:%d,PPC:%d,mode:%d,dr0:%d,dr1:%d,dr2:%d,dr3:%d,dr4:%d,dr5:%d,dr6:%d,dr7:%d,ar0:%d,ar1:%d,ar2:%d,ar3:%d,ar4:%d,ar5:%d,ar6:%d,ar7:%d,sp0:%d,sp1:%d,sp2:%d,sp3:%d,vbr:%d,sfc:%d,dfc:%d,cacr:%d,caar:%d,ir:%d,t1:%d,t0:%d,s:%d,m:%d,x:%d,n:%d,nz:%d,v:%d,c:%d,intm:%d,ints:%d,stop:%d,halt:%d,intc:%d,prefa:%d,prefd:%d\n", m68k_cpu.pc, m68k_cpu.ppc, m68k_cpu.mode, m68k_cpu.dr[0], m68k_cpu.dr[1], m68k_cpu.dr[2], m68k_cpu.dr[3], m68k_cpu.dr[4], m68k_cpu.dr[5], m68k_cpu.dr[6], m68k_cpu.dr[7], m68k_cpu.ar[0], m68k_cpu.ar[1], m68k_cpu.ar[2], m68k_cpu.ar[3], m68k_cpu.ar[4], m68k_cpu.ar[5], m68k_cpu.ar[6], m68k_cpu.ar[7], m68k_cpu.sp[0], m68k_cpu.sp[1], m68k_cpu.sp[2], m68k_cpu.sp[3], m68k_cpu.vbr, m68k_cpu.sfc, m68k_cpu.dfc, m68k_cpu.cacr, m68k_cpu.caar, m68k_cpu.ir, m68k_cpu.t1_flag, m68k_cpu.t0_flag, m68k_cpu.s_flag, m68k_cpu.m_flag, m68k_cpu.x_flag, m68k_cpu.n_flag, m68k_cpu.not_z_flag, m68k_cpu.v_flag, m68k_cpu.c_flag, m68k_cpu.int_mask, m68k_cpu.int_state, m68k_cpu.stopped, m68k_cpu.halted, m68k_cpu.int_cycles, m68k_cpu.pref_addr, m68k_cpu.pref_data); } }
04e9346c-96a7-41cd-9427-309ce48dd98d
public Vector<StockEntry> readFile(InputStream inputStream) throws Exception { Vector<StockEntry> result = new Vector<StockEntry>(); new WorkbookFactory(); Workbook myWorkBook = WorkbookFactory.create(inputStream); Sheet mySheet = myWorkBook.getSheetAt(0); Iterator<Row> rowIter = mySheet.rowIterator(); rowIter.next(); while(rowIter.hasNext()){ Row myRow = rowIter.next(); // End of file can contain rows without the required if (myRow.getPhysicalNumberOfCells() != 7) { break; } Cell vaccineCell = myRow.getCell(UNICEF_VACCINE_INDEX); Cell activityCell = myRow.getCell(UNICEF_ACTIVITY); Cell countryCell = myRow.getCell(UNICEF_COUNTRY_INDEX); Cell totalStockCell = myRow.getCell(UNICEF_TOTAL_STOCK_INDEX); Cell stockCell = myRow.getCell(UNICEF_STOCK_INDEX); Cell dateCell = myRow.getCell(UNICEF_DATE_INDEX); String vaccineValue = vaccineCell.getStringCellValue(); String activityValue = activityCell.getStringCellValue(); String countryValue = countryCell.getStringCellValue(); double totalStockValue = totalStockCell.getNumericCellValue(); double stockValue = stockCell.getNumericCellValue(); String dateStringValue = dateCell.getStringCellValue(); Date dateValue = INPUT_DATE_FORMAT.parse(dateStringValue); if (activityValue.equals("Routine")) { StockEntry stockEntry = new StockEntry(countryValue, vaccineValue, StockEntry.ENTRY_TYPE_UNICEF_COUNTRY, dateValue, stockValue); StockEntry totalStockEntry = new StockEntry(countryValue, vaccineValue, StockEntry.ENTRY_TYPE_UNICEF_TOTALDOSAGE, dateValue, totalStockValue); result.add(stockEntry); result.add(totalStockEntry); } } return result; }
41e76ee7-c7b0-4904-80de-4b654401f129
opcode m6502_62 = new opcode() { public void handler(){ m6502_ICount[0] -= 2; ILL(); }}
2f2fd648-3913-4c11-943a-1a070840113b
public crmondemand.xml.customobject6.query.QueryType getCustomInteger9() { return this.customInteger9; }
ae6c8815-618e-4654-a352-2ea0ac5067ce
public crmondemand.xml.customobject6.query.QueryType getCustomText31() { return this.customText31; }
48440f03-ca1f-4040-b118-a8282ff417e7
public java.math.BigDecimal getCustomNumber60() { return this.customNumber60; }
88acb6ac-760f-4fa2-bbfe-f9329919c852
public crmondemand.xml.customobject3.query.QueryType getDealRegistrationId() { return this.dealRegistrationId; }
1b90ec10-547c-40e0-9608-5d7b2ca5a67f
public void setCustomPhone13(crmondemand.xml.opportunity.query.QueryType customPhone13) { this.customPhone13 = customPhone13; }
c091558c-ae39-4d14-9dad-57bc8b0812f9
public void setAccountType(java.lang.String accountType) { this.accountType = accountType; }
1aaed160-4e8a-424c-9b75-10cda84cfcab
public crmondemand.xml.customobject6.query.QueryType getCustomText69() { return this.customText69; }
bafcff3c-d4a0-4d31-96f5-71e56f2f5112
public crmondemand.xml.contact.query.QueryType getCustomText3() { return this.customText3; }
6724ebf8-d59b-4673-9b68-5215a358eceb
public void setCustomInteger20(java.lang.Integer customInteger20) { this.customInteger20 = customInteger20; }
79b2bc1f-f10f-496f-adc3-865e3c5462a8
public boolean bindsName() { return true; }
aa333a82-03ac-4fcd-a3f7-8fb86d89bf38
public crmondemand.xml.customobject3.query.QueryType getCustomPhone3() { return this.customPhone3; }
18dad71d-258a-4215-b1c3-89e057f44d1b
public void setCustomPickList34(crmondemand.xml.customobject3.query.QueryType customPickList34) { this.customPickList34 = customPickList34; }
ee241460-8496-462c-a375-81f3fbd6ac42
public void setCustomText22(crmondemand.xml.customobject6.query.QueryType customText22) { this.customText22 = customText22; }
adcaaf0b-8b70-4a7a-bef6-5d8504274191
public void setFinancialAccountPrimaryAccount(java.lang.Boolean financialAccountPrimaryAccount) { this.financialAccountPrimaryAccount = financialAccountPrimaryAccount; }
4dbdf1a1-2dd1-43d3-8614-4cde8dd3f507
public java.lang.String getBlockedReasonCode() { return this.blockedReasonCode; }
954d696f-cfa2-4649-b3d3-d52679443f99
public java.lang.String getOwnerFullName() { return this.ownerFullName; }
50347b1c-1745-4da3-818e-425227bd99ec
public void setCustomPhone17(crmondemand.xml.contact.query.QueryType customPhone17) { this.customPhone17 = customPhone17; }
3dac208d-3e5e-4ef3-9563-861a039c78ad
public java.lang.String getCustomPickList53() { return this.customPickList53; }
d03e407c-efb0-40e7-b2b4-c75502b60cba
public void setCustomPhone17(crmondemand.xml.contact.query.QueryType customPhone17) { this.customPhone17 = customPhone17; }
156b0675-189c-4479-868f-7533eb3ad4fd
@Override public void deposit(double amount) { balance += amount; stateChangeCheck(); }
db360e3e-9e97-4d32-abac-3c342c6ea798
public int size() { return tails.size(); }
5c5aa190-a9cc-4b27-a46e-78d6512e6098
public com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange buildPartial() { com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange result = new com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.start_ = start_; if (((from_bitField0_ & 0x00000002) == 0x00000002)) { to_bitField0_ |= 0x00000002; } result.end_ = end_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
82db734f-4d6a-4693-9c74-0148e871cc17
public java.util.Calendar getCustomDate52() { return this.customDate52; }
66b906d7-ba74-466c-8940-9f22438424e4
public void setCustomPickList66(java.lang.String customPickList66) { this.customPickList66 = customPickList66; }
33f61282-717f-413f-8b0d-47461e28f782
public void setCustomDate22(java.util.Calendar customDate22) { this.customDate22 = customDate22; }
2b2915bb-0f5e-4f1a-80db-1ca2589de6f0
public java.lang.String getCustomText28() { return this.customText28; }
3bc3ae45-7961-428e-9ac4-23dc2f16eb72
public java.lang.String getCustomPickList97() { return this.customPickList97; }
52e77c97-16a8-46c6-8a61-1ca79730ccd0
public void setContract(java.lang.String contract) { this.contract = contract; }
5990ae33-95aa-485f-9372-79c94b4ad2c5
public java.lang.String getCustomText0() { return this.customText0; }
d1e19d61-74e4-4c54-b511-bfc2fba8ccff
public void setCustomDate33(java.util.Calendar customDate33) { this.customDate33 = customDate33; }
8f3e929b-2cc3-4423-9427-fcdb9458a9f8
public void setPolicyCurrencyCode(crmondemand.xml.customobject6.query.QueryType policyCurrencyCode) { this.policyCurrencyCode = policyCurrencyCode; }
06568df4-ed75-42ff-8e59-5dbe5b40537f
public crmondemand.xml.contact.query.QueryType getUpdatedByUserSignInId() { return this.updatedByUserSignInId; }
6413de40-6385-4e4a-94ac-15c809b320be
public void setPortfolioIntegrationId(crmondemand.xml.customobject3.query.QueryType portfolioIntegrationId) { this.portfolioIntegrationId = portfolioIntegrationId; }
c7ceb637-29d8-4cea-a9af-fb5c6243f322
public void setMDFRequestRequestName(java.lang.String mDFRequestRequestName) { this.mDFRequestRequestName = mDFRequestRequestName; }
8db0dd6e-9dd9-40af-9738-200286bc9e12
public crmondemand.xml.opportunity.query.QueryType getClaimLossCode() { return this.claimLossCode; }
b6c4e988-d499-4dba-b407-8a9014e6e9a7
public Long getId() { return id; }
b0d82189-d0f9-408a-8da6-d63ed997940b
public crmondemand.xml.opportunity.query.QueryType getCustomCurrency5() { return this.customCurrency5; }
a91125d6-7135-4df2-85e0-2ddf5f71b624
public crmondemand.xml.contact.query.QueryType getCustomCurrency18() { return this.customCurrency18; }
1a61ebb5-49e2-47f4-82bf-1d01603d7025
public void setSampleLotExpirationDate(crmondemand.xml.customobject3.query.QueryType sampleLotExpirationDate) { this.sampleLotExpirationDate = sampleLotExpirationDate; }
0e2e1456-7a11-4925-9a71-6f357a4d65f7
@Override public void addQuest(Quest Q) { if(!quests.contains(Q)) { quests.addElement(Q); Q.autostartup(); } }
83843f78-fe75-4e50-a071-fbb8fea85116
@Override public String listFactions() { final StringBuffer msg=new StringBuffer(); msg.append("\n\r^.^N"); msg.append("+--------------------------------+-----------------------------------------+\n\r"); msg.append(L("| ^HFaction Name^N | ^HFaction INI Source File (Faction ID)^N |\n\r")); msg.append("+--------------------------------+-----------------------------------------+\n\r"); final XVector<Faction> sorted = new XVector<Faction>(factionSet.elements()); Collections.sort(sorted,new Comparator<Faction>(){ @Override public int compare(Faction o1, Faction o2) { return o1.name().compareTo(o2.name()); } }); for(final Enumeration<Faction> e=sorted.elements();e.hasMoreElements();) { final Faction f=e.nextElement(); msg.append("| "); msg.append(CMStrings.padRight(f.name(),30)); msg.append(" | "); msg.append(CMStrings.padRight(f.factionID(),39)); msg.append(" |\n\r"); } msg.append("+--------------------------------+-----------------------------------------+\n\r"); msg.append("\n\r"); return msg.toString(); }
fe44656a-a33d-4c07-994a-82f22aca97d9
public java.lang.String getCustomText40() { return this.customText40; }
8819b662-9c5c-4724-9899-4316074f9117
public void setSolutionTitle(crmondemand.xml.contact.query.QueryType solutionTitle) { this.solutionTitle = solutionTitle; }
58db2b3b-a4fd-40d0-a241-f9bf22105f1b
@Override public final void setNode(SceneNode node) { this.node = node; }
0e9384bc-17a8-4af0-bda3-f5ac868ee5e9
public java.lang.Integer getCustomInteger6() { return this.customInteger6; }
a9df17f7-33b2-4f10-9acf-74dc0a4cea07
public void setCustomDate50(crmondemand.xml.customobject3.query.QueryType customDate50) { this.customDate50 = customDate50; }
174e7d9d-872d-4670-9cab-4f89cfa072cf
public static void main(String[] args) throws FileNotFoundException { File in = new File("dataInput.txt"); Scanner scan = new Scanner(in); File out = new File("dataOutput.txt"); PrintWriter pw = new PrintWriter(out); for (int i = 1; scan.hasNext(); i ++) { pw.println(i + " " + scan.nextLine()); } scan.close(); pw.close(); }
7d93bae7-4bca-4613-8e11-30d6ab4b3ad6
public void setCustomText45(java.lang.String customText45) { this.customText45 = customText45; }
9def28f8-85f7-45fb-8a1c-e4027e0b2361
public void setName(String name) { this.name = name; }
90266c6f-7f79-4f68-8f84-86bd8c999462
public crmondemand.xml.customobject3.query.QueryType getCustomObject8Id() { return this.customObject8Id; }
b6e8b355-d3db-49c8-89e3-a97c4945a440
public crmondemand.xml.customobject6.query.QueryType getCustomNumber22() { return this.customNumber22; }
b7ba2d9d-3dcc-4463-b88b-1c8d6dec0496
public void setCustomObject6Name(crmondemand.xml.contact.query.QueryType customObject6Name) { this.customObject6Name = customObject6Name; }
fe64a81d-7fb3-4537-a7ca-87cacd3076a1
public void setCustomDate27(crmondemand.xml.customobject3.query.QueryType customDate27) { this.customDate27 = customDate27; }
e77bf6ba-655a-478e-a8a4-3ea663bdbd0f
public void setCustomObject5IntegrationId(crmondemand.xml.opportunity.query.QueryType customObject5IntegrationId) { this.customObject5IntegrationId = customObject5IntegrationId; }
678c5903-f1f8-48b0-8f8c-96ec2aa6725d
public boolean isHasPrevious() { return this.hasPrevious; }
134ca1bc-00a1-422f-bbab-48b0f4dede87
public void setCustomObject11Name(crmondemand.xml.customobject6.query.QueryType customObject11Name) { this.customObject11Name = customObject11Name; }
8f39fb80-e460-4727-b58f-0b6fcaeb5c67
public crmondemand.xml.opportunity.query.QueryType getCustomBoolean13() { return this.customBoolean13; }
d9679164-fb4f-430b-80ad-00b5fac86625
public java.util.Calendar getCustomDate59() { return this.customDate59; }
eabafbab-48a1-43fc-827b-e214696bbe70
public crmondemand.xml.customobject6.query.QueryType getCustomText14() { return this.customText14; }
ec673579-c670-41d3-9172-5fde705666c2
public java.lang.String getCustomPickList83() { return this.customPickList83; }
b6d2af36-438d-4990-b531-d50adea4bd1b
@Override public void actionPerformed(ActionEvent e) { if(cg.getText().equalsIgnoreCase(cgs)) { cg.setForeground(cc); cg.setBorder(null); cg.setEditable(false); } else { cg.setForeground(wc); } }
cdc8d405-dd8e-41cf-983c-79e7d427e8c3
public void setRanking(java.math.BigDecimal ranking) { this.ranking = ranking; }
06198603-5b17-4de1-842f-eb64d9fdefa5
public java.lang.String getCustomPickList16() { return this.customPickList16; }
e6a3fad7-4afa-42f2-9814-093868389023
public crmondemand.xml.opportunity.query.QueryType getPortfolioId() { return this.portfolioId; }
40c2fe42-f12a-4784-b409-d1c4261333f4
public crmondemand.xml.contact.query.QueryType getCustomerIntegrationId() { return this.customerIntegrationId; }
c05fb718-df45-4409-95e8-29da6c61e692
public Cons cppTranslateAtomicTree() { { Stella_Object tree = this; return (Cons.list$(Cons.cons(Stella.SYM_STELLA_CPP_LITERAL, Cons.cons(tree, Cons.cons(Stella.NIL, Stella.NIL))))); } }
9d5264f1-1467-450e-8627-28234b7fec29
public void setCustomPickList11(java.lang.String customPickList11) { this.customPickList11 = customPickList11; }
2931ebc6-34ff-44c0-9172-743901df0156
public void setSubmittedDate(crmondemand.xml.customobject6.query.QueryType submittedDate) { this.submittedDate = submittedDate; }
5661fabe-f83e-4f71-9e20-649c0e8c68e1
public abstract void error(String s);
7f52e52e-781b-4142-8c30-0aac7bb9b64a
public java.lang.String getProductExternalSystemId() { return this.productExternalSystemId; }
3ed73128-a598-4c7c-afc9-09a8329e6936
public crmondemand.xml.contact.query.QueryType getCustomDate53() { return this.customDate53; }
26f16d0c-406d-4fe9-b888-3898ec1c9fdd
@Override public List<SpaceObject> getSpaceObjectsWithin(final SpaceObject ofObj, long minDistance, long maxDistance) { final List<SpaceObject> within=new ArrayList<SpaceObject>(1); if(ofObj==null) return within; synchronized(space) { space.query(within, new BoundedObject.BoundedCube(ofObj.coordinates(), maxDistance)); } for (final Iterator<SpaceObject> o=within.iterator();o.hasNext();) { SpaceObject O=o.next(); if(O!=ofObj) { final long dist=Math.round(Math.abs(getDistanceFrom(O,ofObj) - O.radius() - ofObj.radius())); if((dist<minDistance)||(dist>maxDistance)) o.remove(); } } if(within.size()<=1) return within; Collections.sort(within, new Comparator<SpaceObject>() { @Override public int compare(SpaceObject o1, SpaceObject o2) { final long distTo1=getDistanceFrom(o1,ofObj); final long distTo2=getDistanceFrom(o2,ofObj); if(distTo1==distTo2) return 0; return distTo1>distTo2?1:-1; } }); return within; }
d2813fbd-1c2a-48e8-bfc6-5878a9d7b208
public void setCustomText70(crmondemand.xml.opportunity.query.QueryType customText70) { this.customText70 = customText70; }
b1c4d83f-7335-4f5e-bba3-fa9cb08ac62d
public void setCustomPickList99(java.lang.String customPickList99) { this.customPickList99 = customPickList99; }
1dca35a9-5ff2-4e56-8c39-5b9ba3e7cc12
public void setCustomObject3ExternalSystemId(java.lang.String customObject3ExternalSystemId) { this.customObject3ExternalSystemId = customObject3ExternalSystemId; }
d4fe88e3-9531-4685-aab4-e4120a17b119
public java.lang.String getCustomObject5IntegrationId() { return this.customObject5IntegrationId; }
6510ae78-305e-4a3d-805a-355b78081337
public crmondemand.xml.customobject6.query.QueryType getExamType() { return this.examType; }
48869c39-b7a5-4824-b877-280507be0eb9
void printStatus() { System.out.println("Money: "+money); for(int i = 1; i < 6; i++){ System.out.println("--Level "+i+"--"); System.out.println("Highscore:"+highscore[i-1]); System.out.println("Best Combo:"+bestCombo[i-1]); System.out.println("Saved Animals:"+savedAnimals[i-1]); } }
0a831400-0bf7-426f-8552-6dfe3d16ed9d
public crmondemand.xml.customobject6.query.QueryType getCustomPickList92() { return this.customPickList92; }
f69f7f47-d5d4-4edc-904d-1dfff47dd090
@Override public void enterRule(ParseTreeListener listener) { if ( listener instanceof Java7Listener ) ((Java7Listener)listener).enterVariableInitializer(this); }
7c739d28-b019-40ab-9b10-029f300ed57d
public void setCustomBoolean3(crmondemand.xml.opportunity.query.QueryType customBoolean3) { this.customBoolean3 = customBoolean3; }
224273cb-2979-4972-8cea-f9030baacf7b
public AstType getType() { AstType type = m_stable.getType(m_identifier.getName()); if (type == null) { reportTypeError("The operation " + m_identifier.getName() + " does not exist", m_identifier.m_token, operation, "name" ); return new AstType(); } if (!type.isOperation()) { reportTypeError(m_identifier.getName() + " is not an operation name", m_identifier.m_token, operation, "name" ); return new AstType(); } /* * Add a reference to the schema so that its members can be * accessed. */ if (type.m_classMembers != null) { m_stable.add(m_identifier.getName(), type.m_classMembers); } return type; } } /* * Predicate */ public class AstPredicate extends AstBase { SpecObject specObject; String property; public AstPredicate(SpecObject specObject, String property) { this.specObject = specObject; this.property = property; } public void checkType() { AstType type = getType(); if (type.getType() != AstType.TYPE_BOOL) { reportTypeError("Predicates must evaluate to a boolean value", m_token, specObject, property ); } } } public class AstPredicateExpression extends AstPredicate { AstExpression m_expression; public AstPredicateExpression(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = new AstSymbolTable(stable); stable.addKid(m_stable); m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public AstType getType() { return m_expression.getType(); } } public class AstForAllP extends AstPredicate { AstSchemaText m_schemaText; AstPredicate m_predicate; public AstForAllP(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "ForAll - Predicate"); m_schemaText.print(l + 1); m_predicate.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = new AstSymbolTable(stable); stable.addKid(m_stable); m_schemaText.populateTypeTable(m_stable); m_predicate.populateTypeTable(m_stable); } public void populateSymbolTable() { m_schemaText.populateSymbolTable(); m_predicate.populateSymbolTable(); } public void checkType() { m_schemaText.checkType(); m_predicate.getType(); } public AstType getType() { checkType(); return new AstType(AstType.TYPE_BOOL); } } public class AstThereExistsP extends AstPredicate { AstSchemaText m_schemaText; AstPredicate m_predicate; public AstThereExistsP(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "ThereExists - Predicate"); m_schemaText.print(l + 1); m_predicate.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = new AstSymbolTable(stable); stable.addKid(m_stable); m_schemaText.populateTypeTable(m_stable); m_predicate.populateTypeTable(m_stable); } public void populateSymbolTable() { m_schemaText.populateSymbolTable(); m_predicate.populateSymbolTable(); } public void checkType() { m_schemaText.checkType(); m_predicate.getType(); } public AstType getType() { checkType(); return new AstType(AstType.TYPE_BOOL); } } public class AstThereExists1P extends AstPredicate { AstSchemaText m_schemaText; AstPredicate m_predicate; public AstThereExists1P(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "ThereExists1 - Predicate"); m_schemaText.print(l + 1); m_predicate.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = new AstSymbolTable(stable); stable.addKid(m_stable); m_schemaText.populateTypeTable(m_stable); m_predicate.populateTypeTable(m_stable); } public void populateSymbolTable() { m_schemaText.populateSymbolTable(); m_predicate.populateSymbolTable(); } public void checkType() { m_schemaText.checkType(); m_predicate.getType(); } public AstType getType() { checkType(); return new AstType(AstType.TYPE_BOOL); } } public class AstLetP extends AstPredicate { List m_lets = new ArrayList(); AstPredicate m_predicate; public AstLetP(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "let - Predicate"); m_predicate.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_predicate.populateTypeTable(m_stable); } public void populateSymbolTable() { m_predicate.populateSymbolTable(); } public void checkType() { m_predicate.getType(); } public AstType getType() { checkType(); return new AstType(AstType.TYPE_BOOL); } } public class AstAndP extends AstPredicate { AstPredicate m_predicateL; AstPredicate m_predicateR; public AstAndP(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "AND - Predicate"); m_predicateL.print(l + 1); m_predicateR.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_predicateL.populateTypeTable(m_stable); m_predicateR.populateTypeTable(m_stable); } public void populateSymbolTable() { m_predicateL.populateSymbolTable(); m_predicateR.populateSymbolTable(); } public AstType getType() { m_predicateL.checkType(); m_predicateR.checkType(); return new AstType(AstType.TYPE_BOOL); } } public class AstOrP extends AstPredicate { AstPredicate m_predicateL; AstPredicate m_predicateR; public AstOrP(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "OR - Predicate"); m_predicateL.print(l + 1); m_predicateR.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_predicateL.populateTypeTable(m_stable); m_predicateR.populateTypeTable(m_stable); } public void populateSymbolTable() { m_predicateL.populateSymbolTable(); m_predicateR.populateSymbolTable(); } public AstType getType() { m_predicateL.checkType(); m_predicateR.checkType(); return new AstType(AstType.TYPE_BOOL); } } public class AstImpliesP extends AstPredicate { AstPredicate m_predicateL; AstPredicate m_predicateR; public AstImpliesP(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "IMPLIES - Predicate"); m_predicateL.print(l + 1); m_predicateR.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_predicateL.populateTypeTable(m_stable); m_predicateR.populateTypeTable(m_stable); } public void populateSymbolTable() { m_predicateL.populateSymbolTable(); m_predicateR.populateSymbolTable(); } public AstType getType() { m_predicateL.checkType(); m_predicateR.checkType(); return new AstType(AstType.TYPE_BOOL); } } public class AstBiimpliesP extends AstPredicate { AstPredicate m_predicateL; AstPredicate m_predicateR; public AstBiimpliesP(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "BIIMPLIES - Predicate"); m_predicateL.print(l + 1); m_predicateR.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_predicateL.populateTypeTable(m_stable); m_predicateR.populateTypeTable(m_stable); } public void populateSymbolTable() { m_predicateL.populateSymbolTable(); m_predicateR.populateSymbolTable(); } public AstType getType() { m_predicateL.checkType(); m_predicateR.checkType(); return new AstType(AstType.TYPE_BOOL); } } public class AstRelationsP extends AstPredicate { List m_relations = new ArrayList(); AstExpression m_expressionL; AstExpression m_expressionR; public AstRelationsP(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, getName()); m_expressionL.print(l + 1); m_expressionR.print(l + 1); } public String getName() { int i; AstRelation rnode; String name = ""; for (i = 0; i < m_relations.size(); i++) { rnode = (AstRelation) m_relations.get(0); name += rnode.m_infixRelationName.m_token.m_value + " "; } return name; } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expressionL.populateTypeTable(m_stable); m_expressionR.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expressionL.populateSymbolTable(); m_expressionR.populateSymbolTable(); } public AstType getType() { AstRelation r = (AstRelation) m_relations.get(0); AstType ret; AstType t1 = m_expressionL.getType(); AstType t2 = m_expressionR.getType(); if ((t1.isUndefined()) || (t2.isUndefined())) { return new AstType(AstType.TYPE_BOOL); } switch (r.m_infixRelationName.m_token.m_id) { case TozeTokenizer.TOKEN_MEM: case TozeTokenizer.TOKEN_NEM: if (!t2.isSet()) { reportTypeError("Right side of " + getName() + " must be a set", r.m_infixRelationName.m_token, specObject, property ); } if (!t1.isEqual(t2.m_setType)) { reportTypeError("Element is not the same type as the set for " + getName(), r.m_infixRelationName.m_token, specObject, property ); } break; case TozeTokenizer.TOKEN_PSUBS: case TozeTokenizer.TOKEN_SUBS: if (!t1.isEqual(t2)) { reportTypeError("Both sides of " + getName() + " must be sets of the same type", r.m_infixRelationName.m_token, specObject, property ); } break; case TozeTokenizer.TOKEN_EQUAL: case TozeTokenizer.TOKEN_NEQ: if (!t1.isCompatible(t2)) { reportTypeError("Both sides of " + getName() + " must be the same type", r.m_infixRelationName.m_token, specObject, property ); } break; case TozeTokenizer.TOKEN_LESSTHAN: case TozeTokenizer.TOKEN_LEQ: case TozeTokenizer.TOKEN_GEQ: case TozeTokenizer.TOKEN_GREATERTHAN: if ((!t1.isANumber() || !t2.isANumber())) { reportTypeError("Both sides of " + getName() + " must be numbers", r.m_infixRelationName.m_token, specObject, property ); } break; case TozeTokenizer.TOKEN_PREFIX: case TozeTokenizer.TOKEN_SUFFIX: case TozeTokenizer.TOKEN_INSEQ: if (!t2.isSequence()) { reportTypeError("Right side of " + getName() + " must be a sequence", r.m_infixRelationName.m_token, specObject, property ); } if (!t1.isSequence()) { reportTypeError("Left side of " + getName() + " must be a sequence", r.m_infixRelationName.m_token, specObject, property ); } if (!t1.isEqual(t2)) { reportTypeError("Both sequences of " + getName() + " must be of the same type", r.m_infixRelationName.m_token, specObject, property ); } return new AstType(AstType.TYPE_BOOL); case TozeTokenizer.TOKEN_BAGMEMBERSHIP: case TozeTokenizer.TOKEN_SQUAREIMAGEOREQUAL: case TozeTokenizer.TOKEN_PARTITIONS: return new AstType(); default: return new AstType(); } return new AstType(AstType.TYPE_BOOL); } } public class AstRelation extends AstBase { AstIdentifier m_identifier; AstInfixRelationName m_infixRelationName; public void print(int l) { if (m_infixRelationName != null) { m_infixRelationName.print(l); } if (m_identifier != null) { m_identifier.print(l); } } } public class AstPrefixRelationNameP extends AstPredicate { AstPrefixRelationName m_prefixRelationName; AstExpression m_expression; public AstPrefixRelationNameP(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public void checkType() { AstType type = m_expression.getType(); if (!type.isSet()) { reportTypeError("Expression for " + m_prefixRelationName.getName() + " must evaluate to a set", m_expression.m_token, specObject, property ); } } public AstType getType() { checkType(); return new AstType(AstType.TYPE_BOOL); } } public class AstSchemaReferenceP extends AstPredicate { AstSchemaReference m_schemaReference; public AstSchemaReferenceP(SpecObject specObject, String property) { super(specObject, property); } } public class AstPreP extends AstPredicate { AstSchemaReference m_schemaReference; public AstPreP(SpecObject specObject, String property) { super(specObject, property); } } public class AstInitP extends AstPredicate { AstExpression m_expression; public AstInitP(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public AstType getType() { m_expression.getType(); return new AstType(AstType.TYPE_BOOL); } } public class AstTrueFalseP extends AstPredicate { public AstTrueFalseP(SpecObject specObject, String property) { super(specObject, property); } public AstType getType() { return new AstType(AstType.TYPE_BOOL); } public void print(int l) { print(l, m_token.m_value); } } public class AstNotP extends AstPredicate { AstPredicate m_predicate; public AstNotP(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_predicate.populateTypeTable(m_stable); } public void populateSymbolTable() { m_predicate.populateSymbolTable(); } public AstType getType() { m_predicate.getType(); return new AstType(AstType.TYPE_BOOL); } } public class AstParenP extends AstPredicate { AstPredicate m_predicate; public AstParenP(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_predicate.populateTypeTable(m_stable); } public void populateSymbolTable() { m_predicate.populateSymbolTable(); } public AstType getType() { m_predicate.getType(); return new AstType(AstType.TYPE_BOOL); } } /* * Schema Expressions */ public class AstSchemaExpression extends AstBase { } public class AstForAllS extends AstSchemaExpression { AstSchemaText m_schemaText; AstSchemaExpression m_schemaExpression; public void print(int l) { print(l, "ForAll SchemaExpression"); m_schemaText.print(l + 1); m_schemaExpression.print(l + 1); } } public class AstThereExistsS extends AstSchemaExpression { AstSchemaText m_schemaText; AstSchemaExpression m_schemaExpression; public void print(int l) { print(l, "ThereExists SchemaExpression"); m_schemaText.print(l + 1); m_schemaExpression.print(l + 1); } } public class AstThereExists1S extends AstSchemaExpression { AstSchemaText m_schemaText; AstSchemaExpression m_schemaExpression; public void print(int l) { print(l, "ThereExists1 SchemaExpression"); m_schemaText.print(l + 1); m_schemaExpression.print(l + 1); } } public class AstSchemaTextS extends AstSchemaExpression { AstSchemaText m_schemaText; public void print(int l) { print(l, "SchemaText SchemaExpression"); m_schemaText.print(l + 1); } } public class AstSchemaReferenceS extends AstSchemaExpression { AstSchemaReference m_schemaReference; public void print(int l) { print(l, "SchemaReference SchemaExpression"); m_schemaReference.print(l + 1); } } public class AstNotS extends AstSchemaExpression { AstSchemaExpression m_schemaExpression; public void print(int l) { print(l, "Not SchemaExpression"); m_schemaExpression.print(l + 1); } } public class AstPreS extends AstSchemaExpression { AstSchemaExpression m_schemaExpression; public void print(int l) { print(l, "pre SchemaExpression"); m_schemaExpression.print(l + 1); } } public class AstAndS extends AstSchemaExpression { AstSchemaExpression m_schemaExpressionL; AstSchemaExpression m_schemaExpressionR; public void print(int l) { print(l, "AND SchemaExpression"); m_schemaExpressionL.print(l + 1); m_schemaExpressionR.print(l + 1); } } public class AstOrS extends AstSchemaExpression { AstSchemaExpression m_schemaExpressionL; AstSchemaExpression m_schemaExpressionR; public void print(int l) { print(l, "OR SchemaExpression"); m_schemaExpressionL.print(l + 1); m_schemaExpressionR.print(l + 1); } } public class AstImpliesS extends AstSchemaExpression { AstSchemaExpression m_schemaExpressionL; AstSchemaExpression m_schemaExpressionR; public void print(int l) { print(l, "IMPLIES SchemaExpression"); m_schemaExpressionL.print(l + 1); m_schemaExpressionR.print(l + 1); } } public class AstBiimpliesS extends AstSchemaExpression { AstSchemaExpression m_schemaExpressionL; AstSchemaExpression m_schemaExpressionR; public void print(int l) { print(l, "BIIMPLIES SchemaExpression"); m_schemaExpressionL.print(l + 1); m_schemaExpressionR.print(l + 1); } } public class AstProjS extends AstSchemaExpression { AstSchemaExpression m_schemaExpressionL; AstSchemaExpression m_schemaExpressionR; public void print(int l) { print(l, "PROJ SchemaExpression"); m_schemaExpressionL.print(l + 1); m_schemaExpressionR.print(l + 1); } } public class AstBslashS extends AstSchemaExpression { AstSchemaExpression m_schemaExpression; AstDeclarationNameList m_declarationNameList; public void print(int l) { print(l, "BSLASH SchemaExpression"); m_schemaExpression.print(l + 1); m_declarationNameList.print(l + 1); } } public class AstCompS extends AstSchemaExpression { AstSchemaExpression m_schemaExpressionL; AstSchemaExpression m_schemaExpressionR; public void print(int l) { print(l, "COMP SchemaExpression"); m_schemaExpressionL.print(l + 1); m_schemaExpressionR.print(l + 1); } } public class AstMgtS extends AstSchemaExpression { AstSchemaExpression m_schemaExpressionL; AstSchemaExpression m_schemaExpressionR; public void print(int l) { print(l, ">> SchemaExpression"); m_schemaExpressionL.print(l + 1); m_schemaExpressionR.print(l + 1); } } public class AstParenS extends AstSchemaExpression { AstSchemaExpression m_schemaExpression; public void print(int l) { print(l, "() SchemaExpression"); m_schemaExpression.print(l + 1); } } /* * Expression */ public class AstExpression extends AstBase { SpecObject specObject; String property; public AstExpression(SpecObject specObject, String property) { this.specObject = specObject; this.property = property; } public void checkType() { getType(); } } public class AstBinaryOpX extends AstExpression { AstExpression m_expressionL; AstExpression m_expressionR; public AstBinaryOpX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { m_expressionL.print(l); m_expressionR.print(l); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expressionL.populateTypeTable(m_stable); m_expressionR.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expressionL.populateSymbolTable(); m_expressionR.populateSymbolTable(); } public AstType getType() { AstType typeL = m_expressionL.getType(); AstType typeR = m_expressionR.getType(); if ((typeL.isUndefined()) || (typeR.isUndefined())) { return new AstType(); } if (!typeL.isCompatible(typeR)) { reportTypeError("Type mismatch", m_token, specObject, property ); } return typeL.resultantType(typeR); } } public class AstIfThenElseX extends AstExpression { AstPredicate m_predicate; AstExpression m_then; AstExpression m_else; public AstIfThenElseX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "IfThenElse"); m_predicate.print(l + 1); m_then.print(l + 1); m_else.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_predicate.populateTypeTable(m_stable); } public void populateSymbolTable() { m_predicate.populateSymbolTable(); m_then.populateSymbolTable(); m_else.populateSymbolTable(); } public AstType getType() { AstType t1 = m_then.getType(); AstType t2 = m_else.getType(); if ((t1.isUndefined()) || (t2.isUndefined())) { return new AstType(); } if (!t1.isCompatible(t2)) { reportTypeError( "The expression used for the then clause is a different type than the one used for the else clause", m_then.m_token, specObject, property ); } return t1.resultantType(t2); } } public class AstCrossProductX extends AstBinaryOpX { public AstCrossProductX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "CrossProduct"); super.print(l + 1); } public AstType getType() { AstType typeL = m_expressionL.getType(); AstType typeR = m_expressionR.getType(); if ((typeL.isUndefined()) || (typeR.isUndefined())) { return new AstType(); } typeL = typeL.getSetType(); typeR = typeR.getSetType(); if ((typeL == null) || (typeR == null)) { reportTypeError("Both expressions of a cross-product must evaluate to a set", m_token, specObject, property ); return new AstType(); } AstType result = new AstType(AstType.TYPE_SET); result.m_setType = new AstType(AstType.TYPE_TUPLE); result.m_setType.newTuple(typeL, typeR); return result; } } public class AstInfixGenericNameX extends AstBinaryOpX { AstInfixGenericName m_infixGenericName = new AstInfixGenericName(); public AstInfixGenericNameX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { m_infixGenericName.print(l); super.print(l + 1); } public String getName() { return m_infixGenericName.getName(); } public AstType getType() { AstType typeL = m_expressionL.getType(); AstType typeR = m_expressionR.getType(); if ((typeL.isUndefined()) || (typeR.isUndefined())) { return new AstType(); } if ((!typeL.isSet() || !typeR.isSet())) { reportTypeError("Both sides of an infix generic operator must be sets", m_infixGenericName.m_token, specObject, property ); return new AstType(); } AstType type = new AstType(AstType.TYPE_SET); type.m_setType = new AstType(AstType.TYPE_SET); type.m_setType.m_setType = new AstType(AstType.TYPE_TUPLE); type.m_setType.m_setType.newTuple(typeL.getSetType(), typeR.getSetType()); return type; } } public class AstInfixFunctionNameX extends AstBinaryOpX { AstInfixFunctionName m_infixFunctionName = new AstInfixFunctionName(); public AstInfixFunctionNameX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { m_infixFunctionName.print(l); super.print(l + 1); } public AstType getType() { boolean bad = false; int tid = m_infixFunctionName.m_token.m_id; String tname = m_infixFunctionName.m_token.m_value; AstType typeL = m_expressionL.getType(); AstType typeR = m_expressionR.getType(); if ((typeL.isUndefined()) || (typeR.isUndefined())) { return new AstType(); } if (tid == TozeTokenizer.TOKEN_MAP) { AstType type = new AstType(AstType.TYPE_TUPLE); type.m_tupleTypes.add(typeL); type.m_tupleTypes.add(typeR); return type; } if ((tid == TozeTokenizer.TOKEN_PLUS) || (tid == TozeTokenizer.TOKEN_MINUS) || (tid == TozeTokenizer.TOKEN_DIV) || (tid == TozeTokenizer.TOKEN_MOD) || (tid == TozeTokenizer.TOKEN_FSLASH) || (tid == TozeTokenizer.TOKEN_TIMES)) { AstType rtype = typeL.resultantType(typeR); if (!rtype.isANumber()) { reportTypeError("The expressions for the " + tname + " operator must be numbers", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } return rtype; } if ((tid == TozeTokenizer.TOKEN_UNI) || (tid == TozeTokenizer.TOKEN_SETMINUS) || (tid == TozeTokenizer.TOKEN_INT) || (tid == TozeTokenizer.TOKEN_BSLASH)) { if (!typeL.isSet() || !typeR.isSet()) { reportTypeError("Expressions for the " + tname + " operator must be sets", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } if (!typeL.isEqual(typeR)) { reportTypeError("Sets must be the same type for the operator " + tname, m_infixFunctionName.m_token, specObject, property ); return new AstType(); } return typeL; } if ((tid == TozeTokenizer.TOKEN_CAT) || (tid == TozeTokenizer.TOKEN_DCAT) || (tid == TozeTokenizer.TOKEN_PREFIX) || (tid == TozeTokenizer.TOKEN_SUFFIX)) { if (!typeL.isSequence() || !typeR.isSequence()) { reportTypeError("Expressions for the " + tname + " operator must be sequences", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } return typeL; } if (tid == TozeTokenizer.TOKEN_UPTO) { if (!typeL.isANumber() || !typeR.isANumber()) { reportTypeError("Expressions for " + tname + " must be numbers", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } AstType type = new AstType(AstType.TYPE_SET); type.m_setType = typeL; return type; } if ((tid == TozeTokenizer.TOKEN_FOVR) || (tid == TozeTokenizer.TOKEN_FCMP) || (tid == TozeTokenizer.TOKEN_CIRC)) { if (!typeL.isRelation() || !typeR.isRelation()) { reportTypeError("Expressions for " + tname + " must be relations", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } if (!typeL.isEqual(typeR)) { reportTypeError("Relations used in " + tname + " must be of the same type", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } return typeL; } if ((tid == TozeTokenizer.TOKEN_DRES) || (tid == TozeTokenizer.TOKEN_DSUB)) { if (!typeL.isSet()) { reportTypeError("Left-hand argument to " + tname + " must be a set", m_infixFunctionName.m_token, specObject, property ); bad = true; } if (!typeR.isRelation()) { reportTypeError("Right-hand argument to " + tname + " must be a relation", m_infixFunctionName.m_token, specObject, property ); bad = true; } if (bad) { return new AstType(); } if (!((AstType) typeR.getSetType().m_tupleTypes.get(0)).isEqual(typeL.getSetType())) { reportTypeError("Type of set must be the same as the domain type of the range", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } return typeR; } if ((tid == TozeTokenizer.TOKEN_RRES) || (tid == TozeTokenizer.TOKEN_RSUB)) { if (!typeR.isSet()) { reportTypeError("Right-hand argument to " + tname + " must be a set", m_infixFunctionName.m_token, specObject, property ); bad = true; } if (!typeL.isRelation()) { reportTypeError("Left-hand argument to " + tname + " must be a relation", m_infixFunctionName.m_token, specObject, property ); bad = true; } if (bad) { return new AstType(); } if (!((AstType) typeL.getSetType().m_tupleTypes.get(1)).isEqual(typeR.getSetType())) { reportTypeError("Type of set must be the same as the range type of the relation", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } return typeL; } if ((tid == TozeTokenizer.TOKEN_PROJECT)) { if (!typeL.isSequence()) { reportTypeError("Left-hand expression for a projection must be a sequence", m_infixFunctionName.m_token, specObject, property ); bad = true; } if (!typeR.isSet()) { reportTypeError("Right-hand expression for a projection must be a set", m_infixFunctionName.m_token, specObject, property ); bad = true; } if (bad) { return new AstType(); } AstType tl = (AstType) typeL.getSetType().m_tupleTypes.get(1); AstType tr = typeR.getSetType(); if (!tl.isCompatible(tr)) { reportTypeError("Type of set must be the same as the sequence type.", m_infixFunctionName.m_token, specObject, property ); } return typeL; } if ((tid == TozeTokenizer.TOKEN_EXTRACT)) { if (!typeL.isSet()) { reportTypeError("Left-hand expression must be a set", m_infixFunctionName.m_token, specObject, property ); bad = true; } else { } if (!typeR.isSequence()) { reportTypeError("Right-hand expression for a projection must be a sequence", m_infixFunctionName.m_token, specObject, property ); bad = true; } if (bad) { return new AstType(); } AstType tl = typeL.getSetType(); /* * Check that the set contains natural numbers. */ if (!tl.isANumber()) { reportTypeError("The set must contain numbers", m_infixFunctionName.m_token, specObject, property ); } return typeR; } if (tid == TozeTokenizer.TOKEN_HASH) { if (!typeL.isBag()) { reportTypeError("Left-hand expression for '#' must be a bag", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } if (!((AstType) typeL.getSetType().m_tupleTypes.get(0)).isEqual(typeR)) { reportTypeError("Right-hand expression for '#' must be the same type as contained in the bag", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } return new AstType(AstType.TYPE_NATURAL); } if (tid == TozeTokenizer.TOKEN_UPLUS) { if (!typeL.isBag() || !typeR.isBag()) { reportTypeError("Expressions for bag union must be bags", m_infixFunctionName.m_token, specObject, property ); return new AstType(); } if (!typeL.isEqual(typeR)) { reportTypeError("Both sides of bag union must be the same type", m_infixFunctionName.m_token, specObject, property ); } } return new AstType(); } } public class AstPowerX extends AstExpression { AstExpression m_expression; public AstPowerX(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public AstType getType() { AstType ttype = m_expression.getType(); if (ttype.isUndefined()) { return new AstType(); } if (ttype.getSetType() == null) { reportTypeError("Power set must be applied to a set", m_token, specObject, property ); return new AstType(); } AstType type = new AstType(AstType.TYPE_SET); type.m_setType = ttype; return type; } } public class AstUnaryOpX extends AstExpression { AstExpression m_expression; public AstUnaryOpX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, m_token.m_value); m_expression.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression.populateTypeTable(stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public AstType getType() { return m_expression.getType(); } } public class AstPrefixGenericNameX extends AstUnaryOpX { AstPrefixGenericName m_prefixGenericName = new AstPrefixGenericName(); public AstPrefixGenericNameX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { m_prefixGenericName.print(l); } public AstType getType() { switch (m_prefixGenericName.m_token.m_id) { case TozeTokenizer.TOKEN_SEQ: case TozeTokenizer.TOKEN_SEQONE: case TozeTokenizer.TOKEN_ISEQ: AstType t = m_expression.getType(); if (t.isUndefined()) { return new AstType(); } // AstType type = new AstType(AstType.TYPE_SET); // type.m_setType = new AstType(AstType.TYPE_SEQUENCE); if (t.isSet()) { t = t.getSetType(); } AstType rtype = new AstType(AstType.TYPE_SET); rtype.m_setType = new AstType(AstType.TYPE_SEQUENCE); rtype.m_setType.m_setType = new AstType(AstType.TYPE_TUPLE); rtype.m_setType.m_setType.newTuple(new AstType(AstType.TYPE_NATURAL1), t ); rtype.m_setType.m_setType.m_tupleIsSeq = true; return rtype; case TozeTokenizer.TOKEN_BAG: t = m_expression.getType(); if (t.isUndefined()) { return new AstType(); } // type = new AstType(AstType.TYPE_SET); // type.m_setType = new AstType(AstType.TYPE_BAG); if (t.isSet()) { t = t.getSetType(); } rtype = new AstType(AstType.TYPE_SET); rtype.m_setType = new AstType(AstType.TYPE_BAG); rtype.m_setType.m_setType = new AstType(AstType.TYPE_TUPLE); rtype.m_setType.m_setType.newTuple(t, new AstType(AstType.TYPE_NATURAL1) ); rtype.m_setType.m_setType.m_tupleIsSeq = true; return rtype; } return new AstType(); } } public class AstHyphenX extends AstUnaryOpX { AstDecorations m_decoration; public AstHyphenX(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public AstType getType() { AstType t = m_expression.getType(); if (!t.isANumber()) { reportTypeError("The expression for - must be a number", m_token, specObject, property ); return new AstType(); } return t; } } public class AstImageX extends AstExpression // (| |) { AstExpression m_expression1; AstExpression m_expression0; AstDecorations m_decoration; public AstImageX(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression1.populateTypeTable(m_stable); m_expression0.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression1.populateSymbolTable(); m_expression0.populateSymbolTable(); } public AstType getType() { boolean bad = false; AstType typeL = m_expression1.getType(); AstType typeM = m_expression0.getType(); if ((typeL.isUndefined()) || (typeM.isUndefined())) { return new AstType(); } if (!typeL.isRelation()) { reportTypeError("Left-hand expression to the image operator must be a relation", m_token, specObject, property ); bad = true; } if (!typeM.isSet()) { reportTypeError("Inside expression of the image operator must be a set", m_token, specObject, property ); bad = true; } if (bad) { return new AstType(); } if (!typeM.getSetType().isEqual((AstType) typeL.getSetType().m_tupleTypes.get(0))) { reportTypeError( "The type of the inside set expression must the the same type as the domain type of the relation for the image operator", m_token, specObject, property ); return new AstType(); } AstType type = new AstType(AstType.TYPE_SET); type.m_setType = (AstType) typeL.getSetType().m_tupleTypes.get(1); return type; } } public class AstExpressionListX extends AstExpression { List m_expressions = new ArrayList(); public AstExpressionListX(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; int i; for (i = 0; i < m_expressions.size(); i++) { ((AstBase) m_expressions.get(i)).populateTypeTable(m_stable); } } public void populateSymbolTable() { int i; for (i = 0; i < m_expressions.size(); i++) { ((AstBase) m_expressions.get(i)).populateSymbolTable(); } } public AstType getType() { AstType type = new AstType(AstType.TYPE_TUPLE); int i; for (i = 0; i < m_expressions.size(); i++) { AstType t = ((AstBase) m_expressions.get(i)).getType(); type.m_tupleTypes.add(t); } /* * Special case where a tuple is surrounded by parenthesis */ if (m_expressions.size() == 1) { AstType t = (AstType) type.m_tupleTypes.get(0); if (t.getType() == AstType.TYPE_TUPLE) { return t; } } return type; } } public class AstDistUnionX extends AstExpression { AstExpression m_expression = null; public AstDistUnionX(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public AstType getType() { AstType type = m_expression.getType(); if (type.isUndefined()) { return new AstType(); } if (type.getType() != AstType.TYPE_SET) { reportTypeError("Expression used in distributed union must be a set of sets.", m_token, specObject, property ); return new AstType(); } /* * If the set is a tuple, then we need to make sure that each tuple * is of the same type. */ if (type.getSetType().getType() == AstType.TYPE_TUPLE) { int i; AstType stype = type.getSetType(); if (stype.m_tupleTypes.size() == 0) { return new AstType(AstType.TYPE_EMPTY); } AstType type1 = (AstType) stype.m_tupleTypes.get(0); for (i = 1; i < stype.m_tupleTypes.size(); i++) { AstType type2 = (AstType) stype.m_tupleTypes.get(i); if (!type1.isCompatible(type2)) { reportTypeError("All sets used in a distributed union must be of the same type.", m_token, specObject, property ); return new AstType(); } } return type1; } else { if (type.getSetType().getType() != AstType.TYPE_SET) { reportTypeError("Expression used in distributed union must be a set of sets.", m_token, specObject, property ); return new AstType(); } return type.getSetType(); } } } public class AstDistIntersectionX extends AstExpression { AstExpression m_expression = null; public AstDistIntersectionX(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public AstType getType() { AstType type = m_expression.getType(); if (type.isUndefined()) { return new AstType(); } if (type.getType() != AstType.TYPE_SET) { reportTypeError("Expression used in distributed intersection must be a set of sets.", m_token, specObject, property ); return new AstType(); } /* * If the set is a tuple, then we need to make sure that each tuple * is of the same type. */ if (type.getSetType().getType() == AstType.TYPE_TUPLE) { int i; AstType stype = type.getSetType(); if (stype.m_tupleTypes.size() == 0) { return new AstType(AstType.TYPE_EMPTY); } AstType type1 = (AstType) stype.m_tupleTypes.get(0); for (i = 1; i < stype.m_tupleTypes.size(); i++) { AstType type2 = (AstType) stype.m_tupleTypes.get(i); if (!type1.isCompatible(type2)) { reportTypeError("All sets used in a distributed intersection must be of the same type.", m_token, specObject, property ); return new AstType(); } } return type1; } else { if (type.getSetType().getType() != AstType.TYPE_SET) { reportTypeError("Expression used in distributed intersection must be a set of sets.", m_token, specObject, property ); return new AstType(); } return type.getSetType(); } } } public class AstVariableX extends AstExpression { AstVariableName m_variable; AstActualParameters m_actualParameters; public AstVariableX(SpecObject specObject, String property) { super(specObject, property); } } public class AstSelfX extends AstExpression { public AstSelfX(SpecObject specObject, String property) { super(specObject, property); } } public class AstNumberX extends AstExpression { public AstNumberX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, m_token.m_value); } public AstType getType() { AstType type = new AstType(); if (m_token.m_value.indexOf('.') >= 0) { type.m_type = AstType.TYPE_REAL; } else { type.m_type = AstType.TYPE_NATURAL; } return type; } } public class AstSchemaReferenceX extends AstExpression { AstSchemaReference m_schemaReference; public AstSchemaReferenceX(SpecObject specObject, String property) { super(specObject, property); } } public class AstClassNameX extends AstExpression { AstClassName m_className; AstActualParameters m_actualParameters; AstRenameList m_renameList; public AstClassNameX(SpecObject specObject, String property) { super(specObject, property); } } public class AstDownArrowX extends AstExpression { AstExpression m_expression; public AstDownArrowX(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public AstType getType() { if (m_expression == null) { return new AstType(); } return m_expression.getType(); } } public class AstUnionX extends AstBinaryOpX { public void print(int l) { print(l, "Union"); super.print(l + 1); } public AstUnionX(SpecObject specObject, String property) { super(specObject, property); } public AstType getType() { AstType typeL = m_expressionL.getType(); AstType typeR = m_expressionR.getType(); if ((typeL.isUndefined()) || (typeR.isUndefined())) { return new AstType(); } if (!typeL.isSet() || !typeR.isSet()) { reportTypeError( "Expressions for the " + Character.toString(TozeFontMap.CHAR_CUP) + " operator must be sets", m_token, specObject, property ); return new AstType(); } if (!typeL.isEqual(typeR)) { reportTypeError( "Sets must be the same type for the operator " + Character.toString(TozeFontMap.CHAR_CUP), m_token, specObject, property ); return new AstType(); } return typeL; } } public class AstCopyrightX extends AstUnaryOpX { public AstCopyrightX(SpecObject specObject, String property) { super(specObject, property); } } public class AstAngleX extends AstExpression { List m_expressions = new ArrayList(); public AstAngleX(SpecObject specObject, String property) { super(specObject, property); } } public class AstBagX extends AstExpression { List m_expressions = new ArrayList(); public AstBagX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { int i; print(l, "BagExpression"); for (i = 0; i < m_expressions.size(); i++) { ((AstExpression) m_expressions.get(i)).print(l + 1); } } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; int i; for (i = 0; i < m_expressions.size(); i++) { ((AstBase) m_expressions.get(i)).populateTypeTable(m_stable); } } public void populateSymbolTable() { int i; for (i = 0; i < m_expressions.size(); i++) { ((AstBase) m_expressions.get(i)).populateSymbolTable(); } } public AstType getType() { int i; boolean wasUndefined = false; AstType type = new AstType(AstType.TYPE_BAG); if (m_expressions.size() == 0) { return new AstType(AstType.TYPE_EMPTY); } AstType stype = ((AstBase) m_expressions.get(0)).getType(); if (stype.isUndefined()) { return new AstType(); } for (i = 1; i < m_expressions.size(); i++) { AstType ttype = ((AstBase) m_expressions.get(i)).getType(); if (ttype.isUndefined()) { wasUndefined = true; } else { if (!ttype.isEqual(stype)) { reportTypeError("All expressions of a bag must be of the same type", m_token, specObject, property ); } } } if (wasUndefined) { return new AstType(); } AstType rtype = new AstType(AstType.TYPE_BAG); rtype.m_setType = new AstType(AstType.TYPE_TUPLE); rtype.m_setType.newTuple(stype, new AstType(AstType.TYPE_NATURAL1) ); rtype.m_setType.m_tupleIsSeq = false; return rtype; } } public class AstThetaX extends AstExpression { AstSchemaName m_schemaName; AstDecorations m_decorations; AstRenameList m_renameList; public AstThetaX(SpecObject specObject, String property) { super(specObject, property); } } public class AstMemberX extends AstExpression { AstExpression m_expression; AstVariableName m_variableName; public AstMemberX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "AstMember"); m_expression.print(l + 1); m_variableName.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_expression.populateSymbolTable(); } public AstType getType() { AstType ctype = m_expression.getType(); if (ctype.isUndefined()) { return new AstType(); } if (ctype == null) { reportTypeError("Undefined class variable", m_expression.m_token, specObject, property ); return new AstType(); } if (ctype.getType() != AstType.TYPE_CLASS) { reportTypeError("Member access must be from a class type", m_expression.m_token, specObject, property ); return new AstType(); } AstType type = null; if (m_variableName != null) { type = ctype.getClassMembers().getTypeVisible(m_variableName.getName()); } if (type == null) { // the variable name may be null after a class.member syntax // where member is blank, handle as a null and use a unique // TozeToken String member = "<null>"; TozeToken token = null; if (m_variableName != null) { member = m_variableName.getName(); token = m_variableName.m_token; } if (token == null) { token = new TozeToken(-1, member, -1, -1); } reportTypeError("The member " + member + " is not visible", token, specObject, property ); return new AstType(); } if (type.isUndefined()) { reportTypeError("The member " + m_variableName.getName() + " is undefined", m_variableName.m_token, specObject, property ); return new AstType(); } return type; } } public class AstPostfixFunctionNameX extends AstUnaryOpX { AstPostfixFunctionName m_postfixFunctionName; public AstPostfixFunctionNameX(SpecObject specObject, String property) { super(specObject, property); } public AstType getType() { AstType type = m_expression.getType(); if (type.isUndefined()) { return new AstType(); } if ((m_postfixFunctionName.m_token.m_id == TozeTokenizer.TOKEN_TILDE) || (m_postfixFunctionName.m_token.m_id == TozeTokenizer.TOKEN_INV)) { if (!type.isRelation()) { reportTypeError("The argument to '~' must be a relation", m_postfixFunctionName.m_token, specObject, property ); return new AstType(); } AstType rtype = new AstType(AstType.TYPE_SET); rtype.m_setType = new AstType(AstType.TYPE_TUPLE); rtype.m_setType.newTuple((AstType) type.m_setType.m_tupleTypes.get(1), (AstType) type.m_setType.m_tupleTypes.get(0) ); return rtype; } if ((m_postfixFunctionName.m_token.m_id == TozeTokenizer.TOKEN_TCL) || (m_postfixFunctionName.m_token.m_id == TozeTokenizer.TOKEN_RTCL)) { if (!type.isRelation()) { reportTypeError( "The argument to '" + m_postfixFunctionName.m_token.m_value + "' must be a relation", m_postfixFunctionName.m_token, specObject, property ); return new AstType(); } } return type; } } public class AstParenX extends AstExpression { public AstParenX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "Parenthesis"); super.print(l + 1); } } public class AstLambdaX extends AstExpression { AstSchemaText m_schemaText; AstExpression m_expression; public AstLambdaX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "Lambda"); m_schemaText.print(l + 1); m_expression.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_schemaText.populateTypeTable(m_stable); m_expression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_schemaText.populateSymbolTable(); m_expression.populateSymbolTable(); } public AstType getType() { m_schemaText.checkType(); List decls = m_schemaText.m_declaration.m_decls; AstType ttype = new AstType(AstType.TYPE_TUPLE); int i; for (i = 0; i < decls.size(); i++) { if (decls.get(i) instanceof AstBasicDeclaration1) { AstBasicDeclaration1 dec = (AstBasicDeclaration1) decls.get(i); List names = dec.m_declarationNameList.m_declarationNameList; int j; for (j = 0; j < names.size(); j++) { AstDeclarationName name = (AstDeclarationName) names.get(j); AstType nt = m_stable.getType(name.getName()); ttype.m_tupleTypes.add(nt); } } } AstType et = m_expression.getType(); if (et.isUndefined()) { return new AstType(); } ttype.m_tupleTypes.add(et); AstType type = new AstType(AstType.TYPE_SET); type.m_setType = ttype; return type; } } public class AstMuX extends AstExpression { AstSchemaText m_schemaText; AstExpression m_expression; public AstMuX(SpecObject specObject, String property) { super(specObject, property); } } public class AstLetX extends AstExpression { List m_letDefinitions = new ArrayList(); AstExpression m_expression; public AstLetX(SpecObject specObject, String property) { super(specObject, property); } } /* * This class is a merging of a variable (V), Schema Reference (S), and * class (C). * This is done because sometimes it is not possible to know at the time of * parsing whether something is either of the three. * * Word -> VSC * Word, Decoration -> VS * Word, ActualParameters -> VSC * Word, RenameList -> SC * Word, ActualParameters, RenameList -> SC * Word, Decoration, ActualParameters -> VS * Word, Decoration, RenameList -> S * Word, Decoration, ActualParameters, RenameList -> S */ public class AstVSCX extends AstExpression { // The Word will be stored in the token in the base class. AstDecorations m_decorations; AstActualParameters m_actualParameters; AstRenameList m_renameList; public AstVSCX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "VSC"); print(l + 1, m_token.m_value); if (m_decorations != null) { m_decorations.print(l + 1); } if (m_actualParameters != null) { m_actualParameters.print(l + 1); } if (m_renameList != null) { m_renameList.print(l + 1); } } public AstType getType() { AstType type = m_stable.getTypeDef(getName()); if (type == null) { type = m_stable.getType(getName()); if (type == null) { reportTypeError(getName() + " is undefined", m_token, specObject, property ); return new AstType(); } if (type.isUndefined()) { reportTypeError(getName() + " is undefined", m_token, specObject, property ); return new AstType(); } } return type; } public String getName() { if (m_decorations == null) { return m_token.m_value; } return m_token.m_value + m_decorations.getName(); } } public class AstSetExpressionX extends AstExpression { public AstSetExpressionX(SpecObject specObject, String property) { super(specObject, property); } } public class AstSetExpressionX1 extends AstSetExpressionX { List m_expressions = new ArrayList(); public AstSetExpressionX1(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { int i; print(l, "SetExpression"); for (i = 0; i < m_expressions.size(); i++) { ((AstExpression) m_expressions.get(i)).print(l + 1); } } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; int i; for (i = 0; i < m_expressions.size(); i++) { ((AstBase) m_expressions.get(i)).populateTypeTable(m_stable); } } public void populateSymbolTable() { int i; for (i = 0; i < m_expressions.size(); i++) { ((AstBase) m_expressions.get(i)).populateSymbolTable(); } } public AstType getType() { AstType type; int i; boolean wasUndefined = false; //ttp /* * if (m_expressions.size() > 1) * { * AstType ttype = new AstType(); * ttype.m_type = AstType.TYPE_TUPLE; * for (i=0; i<m_expressions.size(); i++) * { * type = ((AstBase)m_expressions.get(i)).getType(); * ttype.m_tupleTypes.add(type); * if (type.isUndefined()) wasUndefined = true; * } * if (wasUndefined) return new AstType(); * type = new AstType(AstType.TYPE_SET); * type.m_setType = ttype; * } * else if (m_expressions.size() == 1) */ if (m_expressions.size() != 0) { type = new AstType(AstType.TYPE_SET); type.m_setType = ((AstBase) m_expressions.get(0)).getType(); if (type.m_setType.isUndefined()) { return new AstType(); } } else { type = new AstType(AstType.TYPE_SET); type.m_setType = new AstType(AstType.TYPE_EMPTY); if (type.m_setType.isUndefined()) { return new AstType(); } } return type; } } public class AstSetExpressionX2 extends AstSetExpressionX { AstSchemaText m_schemaText; AstExpression m_expression; public AstSetExpressionX2(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "SetExpression"); if (m_schemaText != null) { m_schemaText.print(l + 1); } m_expression.print(l + 1); } public void populateTypeTable(AstSymbolTable stable) { m_stable = new AstSymbolTable(stable); stable.addKid(m_stable); if (m_schemaText != null) { m_schemaText.populateTypeTable(m_stable); } if (m_expression != null) { m_expression.populateTypeTable(m_stable); } } public void populateSymbolTable() { if (m_schemaText != null) { m_schemaText.populateSymbolTable(); } if (m_expression != null) { m_expression.populateSymbolTable(); } } public AstType getType() { if (m_schemaText != null) { m_schemaText.checkType(); } if (m_expression == null) { return m_schemaText.getType(); } AstType type = new AstType(AstType.TYPE_SET); type.m_setType = m_expression.getType(); if (type.m_setType.isUndefined()) { return new AstType(); } return type; } } public class AstSetExpressionX3 extends AstSetExpressionX { public AstSetExpressionX3(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "SetExpression - " + m_token.m_value); } public AstType getType() { AstType type = new AstType(); if (m_token.m_id == TozeTokenizer.TOKEN_NAT) { return m_stable.getTypeDef(m_token.m_value); } else if (m_token.m_id == TozeTokenizer.TOKEN_NATONE) { return m_stable.getTypeDef(m_token.m_value); } else if (m_token.m_id == TozeTokenizer.TOKEN_INTEGER) { return m_stable.getTypeDef(m_token.m_value); } else if (m_token.m_id == TozeTokenizer.TOKEN_REAL) { return m_stable.getTypeDef(m_token.m_value); } else if (m_token.m_id == TozeTokenizer.TOKEN_BOOL) { return m_stable.getTypeDef(m_token.m_value); } return m_stable.getTypeDef(m_token.m_value); } } public class AstSequenceX extends AstExpression { List m_expressions = new ArrayList(); public AstSequenceX(SpecObject specObject, String property) { super(specObject, property); } public void print(int l) { print(l, "Sequence"); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; int i; for (i = 0; i < m_expressions.size(); i++) { ((AstBase) m_expressions.get(i)).populateTypeTable(m_stable); } } public void populateSymbolTable() { int i; for (i = 0; i < m_expressions.size(); i++) { ((AstBase) m_expressions.get(i)).populateSymbolTable(); } } public AstType getType() { int i; boolean wasUndefined = false; AstType type = new AstType(AstType.TYPE_SEQUENCE); if (m_expressions.size() == 0) { type.m_setType = new AstType(AstType.TYPE_EMPTY); return type; } AstType stype = ((AstBase) m_expressions.get(0)).getType(); if (stype.isUndefined()) { return new AstType(); } for (i = 1; i < m_expressions.size(); i++) { AstType ttype = ((AstBase) m_expressions.get(i)).getType(); if (ttype.isUndefined()) { wasUndefined = true; } else { if (!ttype.isEqual(stype)) { reportTypeError("All expressions of a sequence must be of the same type", m_token, specObject, property ); } } } if (wasUndefined) { return new AstType(); } AstType rtype = new AstType(AstType.TYPE_SEQUENCE); rtype.m_setType = new AstType(AstType.TYPE_TUPLE); rtype.m_setType.newTuple(new AstType(AstType.TYPE_NATURAL1), stype ); rtype.m_setType.m_tupleIsSeq = true; return rtype; } } public class AstBuiltInFunctionX extends AstUnaryOpX { public AstBuiltInFunctionX(SpecObject specObject, String property) { super(specObject, property); } public AstType getType() { AstType type = m_expression.getType(); if (type.isUndefined()) { return new AstType(); } if (m_token.m_id == TozeTokenizer.TOKEN_DOM) { if (type.getType() != AstType.TYPE_SET) { reportTypeError("The argument to the function 'dom' must be a set of tuples", m_token, specObject, property ); return new AstType(); } if (type.getSetType().getType() != AstType.TYPE_TUPLE) { reportTypeError("The argument to the function 'dom' must be a set of tuples", m_token, specObject, property ); return new AstType(); } if (type.getSetType().m_tupleTypes.size() != 2) { reportTypeError("The argument to the function 'dom' must be a tuple of size 2", m_token, specObject, property ); return new AstType(); } AstType rtype = new AstType(AstType.TYPE_SET); rtype.m_setType = (AstType) type.getSetType().m_tupleTypes.get(0); return rtype; } if (m_token.m_id == TozeTokenizer.TOKEN_RAN) { if (type.getType() != AstType.TYPE_SET) { reportTypeError("The argument to the function 'ran' must be a set of tuples", m_token, specObject, property ); return new AstType(); } if (type.getSetType().getType() != AstType.TYPE_TUPLE) { reportTypeError("The argument to the function 'ran' must be a set of tuples", m_token, specObject, property ); return new AstType(); } if (type.getSetType().m_tupleTypes.size() != 2) { reportTypeError("The argument to the function 'ran' must be a tuple of size 2", m_token, specObject, property ); return new AstType(); } AstType rtype = new AstType(AstType.TYPE_SET); rtype.m_setType = (AstType) type.getSetType().m_tupleTypes.get(1); return rtype; } if (m_token.m_id == TozeTokenizer.TOKEN_REV) { if (type.getType() != AstType.TYPE_SEQUENCE) { reportTypeError("The argument to the function 'rev' must be a sequence", m_token, specObject, property ); return new AstType(); } return type; } if (m_token.m_id == TozeTokenizer.TOKEN_HEAD) { if (type.getType() != AstType.TYPE_SEQUENCE) { reportTypeError("The argument to the function 'head' must be a sequence", m_token, specObject, property ); return new AstType(); } return (AstType) type.getSetType().m_tupleTypes.get(1); // return type.m_setType; } if (m_token.m_id == TozeTokenizer.TOKEN_LAST) { if (type.getType() != AstType.TYPE_SEQUENCE) { reportTypeError("The argument to the function 'last' must be a sequence", m_token, specObject, property ); return new AstType(); } return (AstType) type.getSetType().m_tupleTypes.get(1); // return type.m_setType; } if (m_token.m_id == TozeTokenizer.TOKEN_TAIL) { if (type.getType() != AstType.TYPE_SEQUENCE) { reportTypeError("The argument to the function 'tail' must be a sequence", m_token, specObject, property ); return new AstType(); } return type; } if (m_token.m_id == TozeTokenizer.TOKEN_FRONT) { if (type.getType() != AstType.TYPE_SEQUENCE) { reportTypeError("The argument to the function 'front' must be a sequence", m_token, specObject, property ); return new AstType(); } return type; } if ((m_token.m_id == TozeTokenizer.TOKEN_FIRST) || (m_token.m_id == TozeTokenizer.TOKEN_SECOND)) { if ((type.getType() != AstType.TYPE_TUPLE) || (type.m_tupleTypes.size() != 2)) { reportTypeError("The argument to " + m_token.m_value + " must be a tuple of size 2", m_token, specObject, property ); return new AstType(); } if (m_token.m_id == TozeTokenizer.TOKEN_FIRST) { return (AstType) type.m_tupleTypes.get(0); } return (AstType) type.m_tupleTypes.get(1); } if (m_token.m_id == TozeTokenizer.TOKEN_HASH) { if (!type.isSet() && !type.isSequence()) { reportTypeError("Argument to '#' must be either a set or a sequence", m_token, specObject, property ); } return new AstType(AstType.TYPE_NATURAL); } return new AstType(); } } public class AstFunctionX extends AstExpression { AstExpression m_fexpression; AstExpression m_pexpression; public AstFunctionX(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_fexpression.populateTypeTable(m_stable); m_pexpression.populateTypeTable(m_stable); } public void populateSymbolTable() { m_fexpression.populateSymbolTable(); m_pexpression.populateSymbolTable(); } public AstType getType() { AstType ftype = m_fexpression.getType(); AstType ptype = m_pexpression.getType(); if ((ftype.isUndefined()) || (ptype.isUndefined())) { return new AstType(); } /* * Check the special case where it looks like an expression function * but it is really where a single element of a sequence is being * referenced. */ if (ftype.getType() == AstType.TYPE_SEQUENCE) { if (!ptype.isANumber()) { reportTypeError("Subscript to a sequence must be a number", m_token, specObject, property ); } return (AstType) ftype.getSetType().m_tupleTypes.get(1); } if ((ftype.getType() != AstType.TYPE_SET) && (ftype.getType() != AstType.TYPE_SEQUENCE)) { reportTypeError("Expression used as a function must evaluate to a set of a tuple", m_token, specObject, property ); return new AstType(); } if (ftype.getSetType().getType() != AstType.TYPE_TUPLE) { reportTypeError("Expression used as a function must evaluate to a tuple", m_token, specObject, property ); return new AstType(); } if (ftype.getSetType().m_tupleTypes.size() < 2) { reportTypeError("The tuple must be a binary relation", m_token, specObject, property ); return new AstType(); } //if (ptype.getType() == AstType.TYPE_TUPLE) if (ptype.isTuple()) { if ((ptype.m_tupleTypes.size() + 1) != ftype.m_setType.m_tupleTypes.size()) { reportTypeError("Number of parameters for the function do not match definition.", m_token, specObject, property ); } int i; for (i = 0; i < ptype.m_tupleTypes.size(); i++) { AstType t1 = (AstType) ptype.m_tupleTypes.get(i); AstType t2 = (AstType) ftype.m_setType.m_tupleTypes.get(i); if (!t1.isCompatible(t2)) { reportTypeError("Parameter " + (i + 1) + " does not match definition.", m_token, specObject, property ); } } } else { if (!ptype.isEqual((AstType) ftype.getSetType().m_tupleTypes.get(0))) { reportTypeError("Parameter types do not match function parameters", m_token, specObject, property ); } } List vtmp = ftype.getSetType().m_tupleTypes; return (AstType) vtmp.get(vtmp.size() - 1); } } public class AstPredicateX extends AstExpression { AstPredicate m_predicate; public AstPredicateX(SpecObject specObject, String property) { super(specObject, property); } public void populateTypeTable(AstSymbolTable stable) { m_stable = stable; m_predicate.populateTypeTable(stable); } public void populateSymbolTable() { m_predicate.populateSymbolTable(); } public AstType getType() { boolean bad = false; return new AstType(AstType.TYPE_BOOL); } } /* * Infix, Postfix, Prefix */ public class AstPrefixGenericName extends AstBase { AstDecorations m_decoration; public void print(int l) { print(l, "PrefixGenericName = " + m_token.m_value); if (m_decoration != null) { m_decoration.print(l + 1); } } } public class AstInfixGenericName extends AstBase { AstDecorations m_decoration; public void print(int l) { print(l, "InfixGenericName = " + getName()); if (m_decoration != null) { m_decoration.print(l + 1); } } public String getName() { return m_token.m_value; } } public class AstInfixFunctionName extends AstBase { AstDecorations m_decoration; public void print(int l) { print(l, m_token.m_value); if (m_decoration != null) { m_decoration.print(l + 1); } } } public class AstInfixRelationName extends AstBase { AstDecorations m_decoration; public void print(int l) { print(l, "InfixRelationName = " + m_token.m_value); if (m_decoration != null) { m_decoration.print(l + 1); } } } public class AstPrefixRelationName extends AstBase { public void print(int l) { print(l, "PrefixRelationName = " + getName()); } public String getName() { return m_token.m_value; } } public class AstPostfixFunctionName extends AstBase { AstDecorations m_decoration; public void print(int l) { print(l, "PrefixFunctionName = " + m_token.m_value); m_decoration.print(l + 1); }
d5e3b491-ee8a-4a5d-a465-e1598c834185
public MembreDTO getMembreDTO() { return this.membreDTO; }