Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
        private static void RegisterWitoutBuilding(TableOfMacros table, string fileData)
        {
            int positionOfMacros = 0;
            int searchAfter      = 0;

            while ((positionOfMacros = fileData.IndexOf("#macro", searchAfter, StringComparison.Ordinal)) != -1)
            {
                string        macrosData = ParseUtilites.GetMacrossData(fileData, positionOfMacros);
                List <string> split      = new List <string>(ParseUtilites.SplitAvoidingRedundantCharacters(macrosData));
                string        macrosName = StaticData.MacroSeparator + split[0];
                if (table.Contains(macrosName))
                {
                    throw new Exception("MacroDefinitionAlreadyExists!");
                }
                split.RemoveAt(0);
                Macross macrossToAdd = new UserDefinedMacross(macrosName, split);
                table.Add(macrosName, macrossToAdd);
                searchAfter = positionOfMacros + 1;
            }
        }
Esempio n. 3
0
 static MacroEngine()
 {
     Table = new TableOfMacros();
 }