package tool.model.grammar;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;
import org.antlr.runtime.TokenStream;
import org.antlr.runtime.tree.CommonTree;
import org.antlr.runtime.tree.CommonTreeAdaptor;
import org.antlr.runtime.tree.CommonTreeNodeStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.junit.Test;
import tool.ToolPlugin;
import tool.ToolProjectSupport;
import tool.model.grammar.ForteParser.cursorDeclaration_return;
import tool.model.grammar.ForteParser.projectFile_return;
import tool.model.grammar.ForteParser.project_return;
import tool.repository.ToolRepositoryException;
public class TestPRX {
private static final boolean PRINT_TREE = false;
IPath planRoot;
IPath planLargeRoot;
static IProject testProject;
ForteParser parser;
CommonTreeAdaptor adaptor = new CommonTreeAdaptor(){
public Object create(Token payload){
return new CommonTree(payload);
}
};
public TestPRX(){
this.planRoot = new Path("TestSmall");
this.planLargeRoot = new Path("TestLarge");
this.parser = new ForteParser(null);
}
//@BeforeClass
public static void setup() throws CoreException, ToolRepositoryException, IOException{
if (ResourcesPlugin.getEncoding() != null){
IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
ToolProjectSupport.createProject("Test", myWorkspaceRoot.getLocationURI(), "", "", "", "");
testProject = myWorkspaceRoot.getProject("Test");
}
}
// @AfterClass
// public static void tearDown(){
// IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
// testProject = myWorkspaceRoot.getProject("Test");
// Map<String, ToolPlan> cache = ToolPlan.getPlanCache(testProject);
// System.out.println("No of plans cached: " + cache.size());
// }
private TokenStream getStream(String source){
CharStream stream =
new NoCaseStringStream(source);
ForteLexer lexer = new ForteLexer(stream);
TokenStream tokenStream = new CommonTokenStream(lexer);
return tokenStream;
}
private TokenStream getStream(File file) throws IOException{
CharStream stream =
new NoCaseFileStream(file.getAbsolutePath());
ForteLexer lexer = new ForteLexer(stream);
TokenStream tokenStream = new CommonTokenStream(lexer);
return tokenStream;
}
protected TokenStream getStream(IFile source) {
if (!source.exists())
return null;
CharStream stream;
try {
stream = new NoCaseFileStream(source);
ForteLexer lexer = new ForteLexer(stream);
TokenStream tokenStream = new CommonTokenStream(lexer);
return tokenStream;
} catch (IOException e) {
ToolPlugin.showError("Cannot create parser for Plan " + source.getName(), e);
}
return null;
}
private void failOnSyntaxError(String string, ForteParser parser, ForteAST ast){
int errors = 0;
int treeErrors = 0;
errors = parser.getNumberOfSyntaxErrors();
if (ast != null)
treeErrors = ast.getNumberOfSyntaxErrors();
if (errors + treeErrors> 0){
System.out.println(string + " errors: " + errors + " tree errors: " + treeErrors);
fail("Syntax errors: " + errors);
}
}
//@Test
public void testSmallProjects() throws IOException, RecognitionException{
File planFolderRoot = this.planRoot.toFile();
File[] planFolders = planFolderRoot.listFiles();
for (File folder : planFolders){
if (folder.isDirectory()){
testPRX(folder);
}
}
}
@Test
public void testAuction() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/Auction.pex"));
}
@Test
public void testAuctionServerProject() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/AuctionServerProject.pex"));
}
@Test
public void testAutoTester() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/AutoTester.pex"));
}
@Test
public void testClipboardSample() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/ClipboardSample.pex"));
}
@Test
public void testDDEclient() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/DDEclient.pex"));
}
@Test
public void testDDEserver() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/DDEserver.pex"));
}
@Test
public void testDVSubClass() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/DVSubClass.pex"));
}
@Test
public void testDynamicDataAccess() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/DynamicDataAccess.pex"));
}
@Test
public void testDynamicList() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/DynamicList.pex"));
}
@Test
public void testDynamicSQL() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/DynamicSQL.pex"));
}
@Test
public void testFileBrowser() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/FileBrowser.pex"));
}
@Test
public void testFileUtil() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/FileUtil.pex"));
}
@Test
public void testImageProject() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/ImageProject.pex"));
}
@Test
public void testImageTester() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/ImageTester.pex"));
}
@Test
public void testInheritedWindow() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/InheritedWindow.pex"));
}
@Test
public void testInternatBank() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/InternatBank.pex"));
}
@Test
public void testMultiList() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/MultiList.pex"));
}
@Test
public void testNestedWindow() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/NestedWindow.pex"));
}
@Test
public void testPencilPlay() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/PencilPlay.pex"));
}
@Test
public void testPrintSample() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/PrintSample.pex"));
}
@Test
public void testQueryMgr() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/QueryMgr.pex"));
}
@Test
public void testSimpleOutline() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/SimpleOutline.pex"));
}
@Test
public void testTabFolders() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/TabFolders.pex"));
}
@Test
public void testTimeIt() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/TimeIt.pex"));
}
@Test
public void testTreeList() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/TreeList.pex"));
}
@Test
public void testUtility() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/Utility.pex"));
}
@Test
public void testWinDB() throws IOException, RecognitionException{
testPEX(new File("Demo35Projects/WinDB.pex"));
}
// Forte Libraries
@Test
public void testAPPC() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/APPC.pex"));
}
@Test
public void testCorba() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/Corba.pex"));
}
@Test
public void testCosNaming() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/CosNaming.pex"));
}
@Test
public void testDB2() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/DB2.pex"));
}
@Test
public void testDCE() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/DCE.pex"));
}
@Test
public void testDDEProject() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/DDEProject.pex"));
}
@Test
public void testDisplayProject() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/DisplayProject.pex"));
}
@Test
public void testForeignObjMgr() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/ForeignObjMgr.pex"));
}
@Test
public void testFramework() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/Framework.pex"));
}
//@Test
public void testGenericDBMS() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/GenericDBMS.pex"));
}
@Test
public void testGenericResository() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/GenericResository.pex"));
}
@Test
public void testHTTP() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/HTTP.pex"));
}
@Test
public void testHTTPSupport() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/HTTPSupport.pex"));
}
@Test
public void testInformix() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/Informix.pex"));
}
@Test
public void testLDAP() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/LDAP.pex"));
}
@Test
public void testOLE() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/OLE.pex"));
}
@Test
public void testOracle() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/Oracle.pex"));
}
@Test
public void testRdb() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/Rdb.pex"));
}
@Test
public void testSybase() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/Sybase.pex"));
}
@Test
public void testSybaseCTLib() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/SybaseCTLib.pex"));
}
@Test
public void testSystemMonitor() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/SystemMonitor.pex"));
}
//@Test
public void testXMLDOM2() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/XMLDOM2.pex"));
}
@Test
public void testXMLParser() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/XMLParser.pex"));
}
@Test
public void testXMLSAX2() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/XMLSAX2.pex"));
}
@Test
public void testXSLT() throws IOException, RecognitionException{
testPEX(new File("UDSLibraries/XSLT.pex"));
}
public void testPRX(File project) throws IOException, RecognitionException{
File prx = new File(project, project.getName() + ".prx");
if (!prx.exists())
return;
System.out.println("===== PRX: " + prx.getName() + " =====");
TokenStream tokens = getStream(prx);
parser.setTokenStream(tokens);
parser.setTreeAdaptor(adaptor);
project_return result = parser.project();
CommonTree tree = (CommonTree) result.getTree();
ForteAST walker = null;
if (parser.getNumberOfSyntaxErrors() == 0){
if (PRINT_TREE)
System.out.println("Tree==>"+tree.toStringTree());
CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
nodes.setTokenStream(tokens);
walker = new ForteAST(nodes);
walker.project();
}
failOnSyntaxError("Project File: " + prx.getName(), parser, walker);
}
public int testPEX(File project) throws IOException, RecognitionException{
System.out.println("===== PEX: " + project.getName() + " =====");
TokenStream tokens = getStream(project);
parser.setTokenStream(tokens);
parser.setTreeAdaptor(adaptor);
projectFile_return result = parser.projectFile();
CommonTree tree = (CommonTree) result.getTree();
int errors = parser.getNumberOfSyntaxErrors();
ForteAST walker = null;
if (errors == 0){
if (PRINT_TREE)
System.out.println("Tree==>"+tree.toStringTree());
CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
nodes.setTokenStream(tokens);
walker = new ForteAST(testProject, nodes);
//walker.project();
}
failOnSyntaxError("Project File: " + project.getName(), parser, walker);
return errors;
}
//@Test
public void testConstants() throws IOException, RecognitionException{
parser.setTokenStream(getStream("begin TOOL NavAbsConstants;\n" +
"\n" +
"includes Framework;\n" +
"HAS PROPERTY IsLibrary = FALSE;\n" +
"\n" +
"-- START FORWARD CLASS DECLARATIONS\n" +
"-- END FORWARD CLASS DECLARATIONS\n" +
"\n" +
"-- START FORWARD CURSOR DECLARATIONS\n" +
"-- END FORWARD CURSOR DECLARATIONS\n" +
"\n" +
"-- START CONSTANT DEFINITIONS\n" +
"constant ACC_INFRA_ACC_TYPE_MF_SVC = 'MF_SVC' HAS PROPERTY id = 0 ;\n" +
"constant AI_ADHOC_RELATED_TRAN_TYPE = 'ADHOC' HAS PROPERTY id = 0 ;\n" +
"constant AM_ASSIGN_MULTIPLE = 2 HAS PROPERTY id = 0 ;\n" +
"constant AM_ASSIGN_SINGLE = 1 HAS PROPERTY id = 0 ;\n" +
"constant AM_DEASSIGN_MULTIPLE = 4 HAS PROPERTY id = 0 ;\n" +
"constant AM_DEASSIGN_SINGLE = 3 HAS PROPERTY id = 0 ;\n" +
"constant AM_EDIT_MULTIPLE = 6 HAS PROPERTY id = 0 ;\n" +
"constant AM_EDIT_SINGLE = 5 HAS PROPERTY id = 0 ;\n" +
"constant BI_SELECT = 1 HAS PROPERTY id = 0 ;\n" +
"constant BO_ACTUAL_BANK_REC_SEARCH = 1978 HAS PROPERTY id = 0 ;\n" +
"constant BO_CALC_UTILITIES = 2346 HAS PROPERTY id = 0 ;\n" +
"constant BO_INT_PMT_GRP_CONTACT_TYPE_COLLECTION = 2277 HAS PROPERTY id = 0 ;\n" +
"constant BO_INV_ACC_TRAN_FEE_OF_FUND = 2363 HAS PROPERTY id = 0 ;\n" +
"constant BO_LIFE_SPAN = 2318 HAS PROPERTY id = 0 ;\n" +
"constant BO_MF_SVC = 52303 HAS PROPERTY id = 0 ;\n" +
"constant BO_MF_SVC_COMPLT = 2341 HAS PROPERTY id = 0 ;\n" +
"constant BO_MF_SVC_COMPLT_COLLECTION = 2343 HAS PROPERTY id = 0 ;\n" +
"constant BO_MF_SVC_TRAN = 2342 HAS PROPERTY id = 0 ;\n" +
"constant BO_MF_SVC_TRAN_COLLECTION = 2344 HAS PROPERTY id = 0 ;\n" +
"constant BO_OFFICE_ADDR = 2315 HAS PROPERTY id = 0 ;\n" +
"constant BO_OWNER = 9719 HAS PROPERTY id = 0 ;\n" +
"constant BO_PENS_VAL_FACTOR = 2147483647 HAS PROPERTY id = 0 ;\n" +
"constant BO_REG_INVT_FAC_FEE = 2284 HAS PROPERTY id = 0 ;\n" +
"constant BO_REG_INVT_FAC_FEE_COLLECTION = 2285 HAS PROPERTY id = 0 ;\n" +
"constant BY_AHP_AMT_FOR_FIN_YEAR = 2418 HAS PROPERTY id = 0 ;\n" +
"constant BY_ALLOCATE_BONUS = 2310 HAS PROPERTY id = 0 ;\n" +
"constant BY_ALLOCATE_FEES = 2309 HAS PROPERTY id = 0 ;\n" +
"constant BY_ANNUAL_INCOME_ID = 2353 HAS PROPERTY id = 0 ;\n" +
"constant BY_BANK_DETAILS = 2272 HAS PROPERTY id = 0 ;\n" +
"constant BY_CLOSED_IND = 2267 HAS PROPERTY id = 0 ;\n" +
"constant BY_COMP_SEARCH_CRITERIA = 2218 HAS PROPERTY id = 0 ;\n" +
"constant BY_DEDUCT_AMT_USED_FOR_FINANCIAL_YEAR = 2270 HAS PROPERTY id = 0 ;\n" +
"constant BY_DISTICT_PARCEL_TRAN = 2318 HAS PROPERTY id = 0 ;\n" +
"constant BY_EBR = 2279 HAS PROPERTY id = 0 ;\n" +
"constant BY_ELIGIBLE_INVESTOR = 2287 HAS PROPERTY id = 0 ;\n" +
"constant BY_ETP_AND_DIS = 88888 HAS PROPERTY id = 0 ;\n" +
"constant BY_FIN_YEAR = 2257 HAS PROPERTY id = 0 ;\n" +
"constant BY_IBT_HLDG = 2280 HAS PROPERTY id = 0 ;\n" +
"constant BY_INC_ESTIMATION = 2297 HAS PROPERTY id = 0 ;\n" +
"constant BY_INVT_PROD_ID_DATE_RANGE = 2205 HAS PROPERTY id = 0 ;\n" +
"constant BY_INV_ACC_DEP_ID_FEE_ID = 2204 HAS PROPERTY id = 0 ;\n" +
"constant BY_INV_ACC_INT_CONNECTION = 2189 HAS PROPERTY id = 0 ;\n" +
"constant BY_INV_ACC_INT_EXISTS = 2188 HAS PROPERTY id = 0 ;\n" +
"constant BY_INV_ACC_NUM_INV_TYPE = 2238 HAS PROPERTY id = 0 ;\n" +
"constant BY_INV_ACC_NUM_NEW_BUSINESS = 2057 HAS PROPERTY id = 0 ;\n" +
"constant BY_INV_ACC_NUM_REV_PENS_TYPE = 2239 HAS PROPERTY id = 0 ;\n" +
"constant BY_INV_PROD_PLAN = 2312 HAS PROPERTY id = 0 ;\n" +
"constant BY_INV_PROD_PLAN_EST_AMT = 2317 HAS PROPERTY id = 0 ;\n" +
"constant BY_LAST_TO_DATE = 2313 HAS PROPERTY id = 0 ;\n" +
"constant BY_LATEST_TO_DATE = 2329 HAS PROPERTY id = 0 ;\n" +
"constant BY_LOCK_COUNT = 2202 HAS PROPERTY id = 0 ;\n" +
"constant BY_OBJECT_ALL_FOR_NEW_BUS = 2194 HAS PROPERTY id = 0 ;\n" +
"constant BY_OLDEST_SELL_PARCEL = 2345 HAS PROPERTY id = 0 ;\n" +
"constant BY_OUTSTANDING_BUY_ORDERS = 99999 HAS PROPERTY id = 0 ;\n" +
"constant BY_PARCEL_INV_PROD_PLAN = 2314 HAS PROPERTY id = 0 ;\n" +
"constant BY_PARCEL_TRAD_INV_PROD_PLAN = 2315 HAS PROPERTY id = 0 ;\n" +
"constant BY_PENS_INV_ACC_NUM = 2265 HAS PROPERTY id = 0 ;\n" +
"constant BY_PENS_LIMITS_INV_ACC_NUM = 2255 HAS PROPERTY id = 0 ;\n" +
"constant BY_PERIOD_BALANCE = 2283 HAS PROPERTY id = 0 ;\n" +
"constant BY_PROD_PLAN = 2338 HAS PROPERTY id = 0 ;\n" +
"constant BY_RECONCILE_DEP_TRAN = 2273 HAS PROPERTY id = 0 ;\n" +
"constant BY_REG_PENS_ID = 2220 HAS PROPERTY id = 0 ;\n" +
"constant BY_REJECT_OBJECT_ID = 2294 HAS PROPERTY id = 0 ;\n" +
"constant BY_REVERSAL_IND = 2264 HAS PROPERTY id = 0 ;\n" +
"constant BY_ROLE_TYPE_AND_PLAN = 2352 HAS PROPERTY id = 0 ;\n" +
"constant BY_SEARCH_CRITERIA = 67 HAS PROPERTY id = 0 ;\n" +
"constant BY_TOTAL_FEE_OF_FUND = 2314 HAS PROPERTY id = 0 ;\n" +
"constant BY_TOTAL_REDEMPTION_AMT = 2133 HAS PROPERTY id = 0 ;\n" +
"constant BY_TRADING_NUM = 2135 HAS PROPERTY id = 0 ;\n" +
"constant CD_PAPER_STOCK_CODE_UNKNOWN = 'UNKNOWN' HAS PROPERTY id = 0 ;\n" +
"constant CD_STAR_ID_TO_CPS = 1 HAS PROPERTY id = 0 ;\n" +
"constant C_CREDIT = 'C' HAS PROPERTY id = 0 ;\n" +
"constant C_DEBIT = 'D' HAS PROPERTY id = 0 ;\n" +
"constant C_FALSE = FALSE HAS PROPERTY id = 0 ;\n" +
"constant C_FALSE_STRING = 'FALSE' HAS PROPERTY id = 0 ;\n" +
"constant C_INCOMING_RECEIPTS_DISPLAY_TEXT = 'Incoming Receipts' HAS PROPERTY id = 0 ;\n" +
"constant C_LENDER_FILE_EXTRACTS_COMPANY_NAME = 'Navigator Australia Limited' HAS PROPERTY id = 0 ;\n" +
"constant C_NO = 'N' HAS PROPERTY id = 0 ;\n" +
"constant C_NO_FULL = 'No' HAS PROPERTY id = 0 ;\n" +
"constant C_NULL = 'NULL' HAS PROPERTY id = 0 ;\n" +
"constant C_ONE_HUNDRED = 100 HAS PROPERTY id = 0 ;\n" +
"constant C_TRUE = TRUE HAS PROPERTY id = 0 ;\n" +
"constant C_TRUE_STRING = 'TRUE' HAS PROPERTY id = 0 ;\n" +
"constant C_YES = 'Y' HAS PROPERTY id = 0 ;\n" +
"constant C_YES_FULL = 'Yes' HAS PROPERTY id = 0 ;\n" +
"constant DB_ALL = 2222 HAS PROPERTY id = 0 ;\n" +
"constant DB_BATCH_ID = 2075 HAS PROPERTY id = 0 ;\n" +
"constant OBJECT_TREATMENT_NOT_INITIALISED = 0 HAS PROPERTY id = 0 ;\n" +
"constant PB_ACCEPT = 'Accept' HAS PROPERTY id = 0 ;\n" +
"constant PB_DELETE = 'Delete' HAS PROPERTY id = 0 ;\n" +
"constant PB_DISALLOW = 'Disallow' HAS PROPERTY id = 0 ;\n" +
"constant PENDING_CGTTAX_RULENO = 136 HAS PROPERTY id = 0 ;\n" +
"constant PENDING_CONSOLIDATIONTAX_RULENO = 135 HAS PROPERTY id = 0 ;\n" +
"constant PENDING_SUPERANNUATIONTAX_RULENO = 136 HAS PROPERTY id = 0 ;\n" +
"constant PENDING_WITHHOLDINGTAX_RULENO = 137 HAS PROPERTY id = 0 ;\n" +
"constant PT_ANNUAL_INCOME_ALLOC = 2132 HAS PROPERTY id = 0 ;\n" +
"constant PT_AVG_UNITS_FOR_INVESTOR = 2154 HAS PROPERTY id = 0 ;\n" +
"constant PT_AVG_UNITS_FOR_PLAN = 2153 HAS PROPERTY id = 0 ;\n" +
"constant PT_BY_NTIER_MF_SVC_ID = 2163 HAS PROPERTY id = 0 ;\n" +
"constant PT_CALCULATE_AVG_PROD_RATE = 2113 HAS PROPERTY id = 0 ;\n" +
"constant PT_CALCULATE_CGT = 2194 HAS PROPERTY id = 0 ;\n" +
"constant PT_CALCULATE_CGT_QRT = 111111111 HAS PROPERTY id = 0 ;\n" +
"constant PT_CALCULATE_DAILY_AVG_INV_HOLDINGS = 2115 HAS PROPERTY id = 0 ;\n" +
"constant PT_CANCEL_WAITING_INV_ORDERS = 2174 HAS PROPERTY id = 0 ;\n" +
"constant PT_CA_ALLOCATION = 2147483647 HAS PROPERTY id = 0 ;\n" +
"constant PT_DEFERRED_SERVICE_FEES = 2286 HAS PROPERTY id = 0 ;\n" +
"constant PT_DETERMINE_ISSUE_STOCK = 2150 HAS PROPERTY id = 0 ;\n" +
"constant PT_DISHONOUR_DEP_DET = 2167 HAS PROPERTY id = 0 ;\n" +
"constant PT_FILE_EXPORT = 999999 HAS PROPERTY id = 0 ;\n" +
"constant PT_INVALD_DEP_DET = 2137 HAS PROPERTY id = 0 ;\n" +
"constant PT_INVESTMENTS_EXITS = 2164 HAS PROPERTY id = 0 ;\n" +
"constant PT_PROCESS_ALLOCATE_INTEREST_INCOME = 2139 HAS PROPERTY id = 0 ;\n" +
"constant PT_PROCESS_INV_ORDER_CANCEL = 2112 HAS PROPERTY id = 0 ;\n" +
"constant PT_PROCESS_MF_INCOME_ALLOCATION = 2181 HAS PROPERTY id = 0 ;\n" +
"constant PT_PROCESS_REVERSE_MFINC = 2172 HAS PROPERTY id = 0 ;\n" +
"constant PT_REVERSE_DEP_FEES = 2165 HAS PROPERTY id = 0 ;\n" +
"constant PT_RUN_CHASE_BATCH = 2196 HAS PROPERTY id = 0 ;\n" +
"constant PT_TOTAL_AVG_HOLD_FOR_ALL_INV = 2159 HAS PROPERTY id = 0 ;\n" +
"constant PT_TOTAL_AVG_UNITS_FOR_ALL_INV_ACC = 2166 HAS PROPERTY id = 0 ;\n" +
"constant PT_TOTAL_CURR_HOLD_FOR_ALL_INV = 2158 HAS PROPERTY id = 0 ;\n" +
"constant PT_UNITS_ON_DAY_FOR_INVESTOR = 2152 HAS PROPERTY id = 0 ;\n" +
"constant PT_UNITS_ON_DAY_FOR_PLAN = 2151 HAS PROPERTY id = 0 ;\n" +
"constant RESULTS_WIDTH = 500 HAS PROPERTY id = 0 ;\n" +
"constant RP_RIF_CONTROL_REPORT = 215 HAS PROPERTY id = 0 ;\n" +
"constant RT_BOOLEAN_DATA = 2014 HAS PROPERTY id = 0 ;\n" +
"constant RT_DATE_TIME_NULLABLE = 2033 HAS PROPERTY id = 0 ;\n" +
"constant RT_DECIMAL_NULLABLE = 2013 HAS PROPERTY id = 0 ;\n" +
"constant RT_DOUBLE_DATA = 2105 HAS PROPERTY id = 0 ;\n" +
"constant RT_INTEGER_DATA = 2124 HAS PROPERTY id = 0 ;\n" +
"constant RT_OBJECT_ARRAY = 53913 HAS PROPERTY id = 0 ;\n" +
"constant RT_PARTY_TYPE = 2125 HAS PROPERTY id = 0 ;\n" +
"constant RT_TEXT_DATA = 2106 HAS PROPERTY id = 0 ;\n" +
"constant SM_ALL_ALREADY_DEASSIGNED = 100490 HAS PROPERTY id = 0 ;\n" +
"constant SM_ALL_ASSIGNMENTS_REMOVED = 100505 HAS PROPERTY id = 0 ;\n" +
"constant SM_ALL_DATES_ELAPSED_NONE_DEASSIGNED = 100491 HAS PROPERTY id = 0 ;\n" +
"constant SM_ALL_FROM_DATES_ELAPSED = 100504 HAS PROPERTY id = 0 ;\n" +
"constant SM_ALL_ITEMS_ASSIGNED = 100482 HAS PROPERTY id = 0 ;\n" +
"constant SM_ALL_ITEMS_DEASSIGNED = 100497 HAS PROPERTY id = 0 ;\n" +
"constant SM_ALL_ITEMS_DEASSIGNED_SELECT = 100485 HAS PROPERTY id = 0 ;\n" +
"constant SM_ALL_TO_DATES_ELAPSED_SELECT = 100486 HAS PROPERTY id = 0 ;\n" +
"constant SM_ASSIGN_ITEM = 100475 HAS PROPERTY id = 0 ;\n" +
"constant SM_DEASSIGN_ITEM = 100228 HAS PROPERTY id = 0 ;\n" +
"constant SM_EDIT_ITEM = 100229 HAS PROPERTY id = 0 ;\n" +
"constant SM_FROM_DATE_ELAPSED_CANT_REMOVE = 100503 HAS PROPERTY id = 0 ;\n" +
"constant SM_INVALID_PERIOD_SPECIFY = 100498 HAS PROPERTY id = 0 ;\n" +
"constant SM_INVALID_SHARED_OBJECTS_FUNCTION = 1190 HAS PROPERTY id = 0 ;\n" +
"constant SM_ITEM_EDITED_OK = 100499 HAS PROPERTY id = 0 ;\n" +
"constant SM_NO_DATES_PASSED_NONE_DEASSIGNED = 100489 HAS PROPERTY id = 0 ;\n" +
"constant SM_NO_FROM_DATES_PASSED_SELECT = 100484 HAS PROPERTY id = 0 ;\n" +
"constant SM_NO_ITEMS_ASSIGNED_PERIOD = 100477 HAS PROPERTY id = 0 ;\n" +
"constant SM_NO_ITEMS_DEASSIGNED_SELECT = 100483 HAS PROPERTY id = 0 ;\n" +
"constant SM_NO_VALID_PERIODS_SELECT = 100488 HAS PROPERTY id = 0 ;\n" +
"constant SM_ONE_ITEM_TO_EDIT = 100501 HAS PROPERTY id = 0 ;\n" +
"constant SM_PMT_GRP_AND_DEALER_NO_LINK = 1196 HAS PROPERTY id = 0 ;\n" +
"constant SM_REMOVE_ITEM = 100230 HAS PROPERTY id = 0 ;\n" +
"constant SM_SOME_DEASSIGNED = 100493 HAS PROPERTY id = 0 ;\n" +
"constant SM_SOME_DEASSIGNED_ALREADY = 100496 HAS PROPERTY id = 0 ;\n" +
"constant SM_SOME_DEASSIGNED_FROM_DATE = 100494 HAS PROPERTY id = 0 ;\n" +
"constant SM_SOME_DEASSIGNED_PERIOD = 100492 HAS PROPERTY id = 0 ;\n" +
"constant SM_SOME_DEASSIGNED_TO_DATE = 100495 HAS PROPERTY id = 0 ;\n" +
"constant SM_SOME_ITEMS_ASSIGNED_PERIOD = 100478 HAS PROPERTY id = 0 ;\n" +
"constant SM_SOME_REMOVED_FROM_DATE = 100502 HAS PROPERTY id = 0 ;\n" +
"constant SM_TO_DATE_ELAPSED = 100500 HAS PROPERTY id = 0 ;\n" +
"constant SR_CONFIRMATION_REKEY_WINDOW = 54527 HAS PROPERTY id = 0 ;\n" +
"constant SR_GAP_CAPTURE_WINDOW = 53862 HAS PROPERTY id = 0 ;\n" +
"constant SR_MAINT_STAPLED_SEC_WINDOW = 54142 HAS PROPERTY id = 0 ;\n" +
"constant SR_PORTFOLIO_ADJUSTMENTS_EDIT_RECORD = 53852 HAS PROPERTY id = 0 ;\n" +
"constant SR_TFN_WIDGET = 52002 HAS PROPERTY id = 0 ;\n" +
"constant WC_SUSPEND_PAYMENT = 'SUSPND' HAS PROPERTY id = 0 ;\n" +
"constant WT_INV_ACC_ASSIGNMENT = 64548754 HAS PROPERTY id = 0 ;\n" +
"constant WT_INV_ACC_MAINT_WIN = 2056 HAS PROPERTY id = 0 ;\n" +
"constant WT_MATCH_EXP_BANK_REC = 2124 HAS PROPERTY id = 0 ;\n" +
"constant WT_NAV_ABS_GET_DATES_WIN = 2061 HAS PROPERTY id = 0 ;\n" +
"constant WT_NAV_UNIT_SUMMARYDETAILS_WINDOW = 98989898 HAS PROPERTY id = 0 ;\n" +
"constant WT_PARTY_MAINT_WIN = 30 HAS PROPERTY id = 0 ;\n" +
"constant WT_PARTY_SEARCH_WIN = 55 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_ADVISER = 2144 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_CLOSED_INVACC = 2205 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_GEARERNUM = 2142 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INTACC = 2140 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INTACC_VIA_ADVISER = 53491 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INTGRP = 2139 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INTOFFICE = 2200 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INTPMTGRP = 2199 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INVACC = 2137 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INVACCTRAN = 51002 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INVESTOR = 2147 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INVMGR = 2141 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_INVTPROD = 2201 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_MFPLAN = 2198 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_MFPROD = 2196 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_MFSVC = 2197 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_NAVBANKACC = 2146 HAS PROPERTY id = 0 ;\n" +
"constant WT_REPORTING_SEARCH_PARTY = 2134 HAS PROPERTY id = 0 ;\n" +
"constant WT_WORKFLOW_SEARCH_INVACC = 52003 HAS PROPERTY id = 0 ;\n" +
"constant WT_WORKFLOW_SEARCH_INVACCTRAN = 2208 HAS PROPERTY id = 0 ;\n" +
"-- END CONSTANT DEFINITIONS\n" +
"\n" +
"-- START C DATA TYPE DEFINITIONS\n" +
"-- END C DATA TYPE DEFINITIONS\n" +
"\n" +
"HAS PROPERTY\n" +
" CompatibilityLevel = 0;\n" +
" ProjectType = APPLICATION;\n" +
" Restricted = FALSE;\n" +
" MultiThreaded = TRUE;\n" +
" Internal = FALSE;\n" +
" LibraryName = 'consab';\n" +
"\n" +
"UUID = '623D50D0-CEAF-11E0-A010-9943839CAA77';\n" +
"\n" +
"-- START CLASS DEFINITIONS\n" +
"-- END CLASS DEFINITIONS\n" +
"\n" +
"-- START SERVICE OBJECT DEFINITIONS\n" +
"-- END SERVICE OBJECT DEFINITIONS\n" +
"\n" +
"-- START CURSOR DEFINITIONS\n" +
"-- END CURSOR DEFINITIONS\n" +
"\n" +
"-- START TYPEDEF DEFINITIONS\n" +
"-- END TYPEDEF DEFINITIONS\n" +
"\n" +
"-- START METHOD DEFINITIONS\n" +
"-- END METHOD DEFINITIONS\n" +
"\n" +
"end NavAbsConstants;\n" +
""));
parser.setTreeAdaptor(adaptor);
project_return result = parser.project();
CommonTree tree = (CommonTree) result.getTree();
// printTree(tree, 1);
failOnSyntaxError("Project String" , parser, null);
}
@Test
public void testCursorDeclaration() throws IOException, RecognitionException{
System.out.println("====== Cursor=====");
parser.setTokenStream(getStream("cursor BlobCursor(name: Framework.string)\n" +
"begin\n" +
" select BlobValue from ArtistBlob\n" +
"where Name like :name;\n" +
"end;\n" +
""));
parser.setTreeAdaptor(adaptor);
cursorDeclaration_return result = parser.cursorDeclaration();
CommonTree tree = (CommonTree) result.getTree();
printTree(tree, 1);
failOnSyntaxError("Cursor" , parser, null);
}
public void printTree(CommonTree tree, int indent){
if (tree != null){
StringBuffer sb = new StringBuffer(indent);
for (int i = 0; i < indent; i++)
sb = sb.append(" ");
for (int i = 0; i < tree.getChildCount(); i++){
System.out.println(sb.toString() + tree.getChild(i).toString());
printTree((CommonTree)tree.getChild(i), indent+1);
}
}
}
}