inctokenizer = getStreamTokenizer(file.getAbsolutePath()); if (inctokenizer!=null) processDB(data, inctokenizer, include_filename, new DBPathSpecification(file.getParentFile().getAbsolutePath()));
inctokenizer = getStreamTokenizer(file.getAbsolutePath()); if (inctokenizer!=null) processDB(data, inctokenizer, include_filename, new PathSpecification(file.getParentFile().getAbsolutePath()));
public static void processDB(DBData data, StreamTokenizer tokenizer, String fileName, DBPathSpecification paths) throws Exception{		String comment = nullString;	String str, str2;	String include_filename;	StreamTokenizer inctokenizer = null;	if (data!=null)		try {				while (tokenizer.nextToken() != tokenizer.TT_EOF)  		  if (tokenizer.ttype == tokenizer.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 == tokenizer.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 == tokenizer.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);					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);										//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 == tokenizer.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);					//System.out.println("expand(\""+str+"\", "+str2+")\n{");					DBTemplateInstance ti = new DBTemplateInstance(str2, loadedTemplateId);					ti.setComment(comment);	comment = nullString;					processMacros(ti, tokenizer, fileName);										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);					//if (file!=null)					//{						inctokenizer = getStreamTokenizer(file.getAbsolutePath());						if (inctokenizer!=null) processDB(data, inctokenizer, include_filename, new DBPathSpecification(file.getParentFile().getAbsolutePath()));					//}				}							/****************** 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;	}		}