if (inctokenizer!=null) processDB(data, inctokenizer, include_filename, new PathSpecification(file.getParentFile().getAbsolutePath()), loadStack, loadList);
if (inctokenizer!=null) processDB(data, inctokenizer, include_filename, new PathSpecification(file.getParentFile().getAbsolutePath(), paths), loadStack, loadList);
public static void processDB(DBData data, EnhancedStreamTokenizer tokenizer, String fileName,							   PathSpecification paths, Stack loadStack, ArrayList loadList) throws Exception{		String comment = nullString;	String str, str2;	String include_filename;	EnhancedStreamTokenizer inctokenizer = null;	if (data!=null)	{		if (loadStack.contains(fileName))		{			StringBuffer buf = new StringBuffer();			buf.append("Cyclic reference detected when trying to load '");			buf.append(fileName);			buf.append("'.\nLoad stack trace:\n");			for (int i = loadStack.size()-1; i>=0; i--)			{				buf.append("\t");				buf.append(loadStack.elementAt(i));				buf.append("\n");			}			throw new DBException(buf.toString());		}		else		{			loadStack.push(fileName);		}						try {						while (tokenizer.nextToken() != EnhancedStreamTokenizer.TT_EOF)	  		  if (tokenizer.ttype == EnhancedStreamTokenizer.TT_WORD)				if (tokenizer.sval.startsWith(DBConstants.commentString))					comment+=processComment(data, tokenizer, fileName);				else						/****************** records ********************/						if (tokenizer.sval.equalsIgnoreCase(RECORD) ||						tokenizer.sval.equalsIgnoreCase(GRECORD)) {										DBRecordData rd = new DBRecordData();							// read record_type						tokenizer.nextToken();						if ((tokenizer.ttype == EnhancedStreamTokenizer.TT_WORD) ||							(tokenizer.ttype == DBConstants.quoteChar)) rd.setRecord_type(tokenizer.sval);						else throw (new DBParseException("Invalid record type...", tokenizer, fileName));							// read record_name						tokenizer.nextToken();						if ((tokenizer.ttype == EnhancedStreamTokenizer.TT_WORD) ||							(tokenizer.ttype == DBConstants.quoteChar)) rd.setName(tokenizer.sval);						else throw (new DBParseException("Invalid record name...", tokenizer, fileName));							rd.setComment(comment);	comment = nullString;												processFields(rd, tokenizer, fileName, paths);						data.addRecord(rd);											}						/****************** templates ********************/						else if (tokenizer.sval.equalsIgnoreCase(TEMPLATE)) {							// read optional description						str = null;						tokenizer.nextToken();						if (tokenizer.ttype == DBConstants.quoteChar) str = tokenizer.sval;						else							tokenizer.pushBack();							/*						if (str==null)							System.out.println("template()\n{");						else							System.out.println("template(\""+str+"\")\n{");						*/							// multiple tempaltes						// only new ports are added						DBTemplate templateData = data.getTemplateData();						if (!templateData.isInitialized())						{							templateData.setInitialized(true);							templateData.setComment(comment); comment = nullString;							templateData.setDescription(str);								DBTemplateEntry entry = new DBTemplateEntry();							data.addEntry(entry);							}						else						{							// !!! TBD multiple templates support							comment = nullString;						}												processPorts(templateData, tokenizer, fileName, paths);												//System.out.println("}");						}						/****************** expands ********************/						else if (tokenizer.sval.equalsIgnoreCase(EXPAND)) {							// read template file						tokenizer.nextToken();						if (tokenizer.ttype == DBConstants.quoteChar) str = tokenizer.sval;						else throw (new DBParseException("Invalid expand file...", tokenizer, fileName));							// read tempalte instance id						tokenizer.nextToken();						if ((tokenizer.ttype == EnhancedStreamTokenizer.TT_WORD) ||							(tokenizer.ttype == DBConstants.quoteChar)) str2 = tokenizer.sval;						else throw (new DBParseException("Invalid expand template instance name...", tokenizer, fileName));							String loadedTemplateId = loadTemplate(data, str, fileName, paths, loadStack, loadList);							//System.out.println("expand(\""+str+"\", "+str2+")\n{");							DBTemplateInstance ti = new DBTemplateInstance(str2, loadedTemplateId);						ti.setComment(comment);	comment = nullString;							processMacros(ti, tokenizer, fileName, paths);												data.addTemplateInstance(ti);							//System.out.println("}");					}						/****************** includes ********************/										else if (tokenizer.sval.equalsIgnoreCase(INCLUDE)) {							// read incude_filename						tokenizer.nextToken();						if (tokenizer.ttype == DBConstants.quoteChar) include_filename=tokenizer.sval;						else throw (new DBParseException("Invalid include filename...", tokenizer, fileName));							DBDataEntry entry = new DBDataEntry(INCLUDE+" \""+include_filename+"\"");						entry.setComment(comment);	comment = nullString;						data.addEntry(entry);							File file = paths.search4File(include_filename);						inctokenizer = getEnhancedStreamTokenizer(file.getAbsolutePath());						if (inctokenizer!=null) processDB(data, inctokenizer, include_filename, new PathSpecification(file.getParentFile().getAbsolutePath()), loadStack, loadList);					}									/****************** path ********************/						 else if (tokenizer.sval.equalsIgnoreCase(PATH))	  				{						// read paths						tokenizer.nextToken();						if (tokenizer.ttype == DBConstants.quoteChar) str=tokenizer.sval;						else throw (new DBParseException("Invalid path...", tokenizer, fileName));							DBDataEntry entry = new DBDataEntry(PATH+" \""+str+"\"");						entry.setComment(comment);	comment = nullString;						data.addEntry(entry);							paths.setPath(str);						//Console.getInstance().println("Warning: 'path' command is not yet supported...");	  				}										/****************** addpath ********************/						 else if (tokenizer.sval.equalsIgnoreCase(ADDPATH))	  				{						// read add paths						tokenizer.nextToken();						if (tokenizer.ttype == DBConstants.quoteChar) str=tokenizer.sval;						else throw (new DBParseException("Invalid addpath...", tokenizer, fileName));							DBDataEntry entry = new DBDataEntry(ADDPATH+" \""+str+"\"");						entry.setComment(comment);	comment = nullString;						data.addEntry(entry);							paths.addAddPath(str);						//Console.getInstance().println("Warning: 'addpath' command is not yet supported...");	  				}			} catch (Exception e) {			//Console.getInstance().println("\n"+e);			throw e;		}		finally		{			loadStack.pop();		}	}	}