public static void Register(TableOfMacros table, string fileData) { try { RegisterWitoutBuilding(table, fileData); for (int position = 0; position < fileData.Length; ++position) { if (fileData[position] == StaticData.MacroSeparator) { string macrosName = ParseUtilites.GetMacrosNameInPosition(fileData, position); if (macrosName == "#macro") { string macrosData = ParseUtilites.GetMacrossData(fileData, position); string userDefinedMacrossName = StaticData.MacroSeparator + ParseUtilites.SplitAvoidingRedundantCharacters(macrosData)[0 ]; MainCompositeView cv = new MainCompositeView(fileData); cv.StartPositionInFile = position; int startOfMacroData = ParseUtilites.GetMacrosCloseBracketPosAfterMacroSep(fileData, position) + 1; Visitor v = new BuildCompositeVisitor(fileData, table, startOfMacroData); cv.Accept(v); position = cv.EndPositionInFile + "#end".Length; ((UserDefinedMacross)table.Get(userDefinedMacrossName)).CompositeView = cv; } } } } catch (Exception ex) { Console.WriteLine("Error while building table of macros!"); Console.WriteLine("Error message: {0}", ex.Message); } }
public static string Merge(string filepath, Context context) { string fileData; RegisterUserDefinedMacrossIncludingParsing(filepath, out fileData); MainCompositeView compositeView = new MainCompositeView(fileData); try { Visitor v = new BuildCompositeVisitor(fileData, Table); compositeView.Accept(v); } catch (Exception ex) { Console.WriteLine("Error while merging file: {0}", Path.GetFileName(filepath)); Console.WriteLine("Error message: {0}", ex.Message); } return(compositeView.Evaluate(context)); }