예제 #1
0
        private void HandleConstructionAtPosition(CompositeConstruction comCon, string name, ref int position)
        {
            Macross currentMacros = table.Get(name);

            if (currentMacros.Name == "break")
            {
                comCon.AddUnit(
                    new StaticText(comCon, fileData.Substring(currentPosition, position - currentPosition)));
                TextUnit comp = new BreakConstruction(comCon, fileData);
                comCon.AddUnit(comp);
                currentPosition = position + name.Length;
                position        = currentPosition;
                return;
            }
            int    macrosDataEndPos = ParseUtilites.GetMacrosCloseBracketPosAfterMacroSep(fileData, position);
            string macrosData       = ParseUtilites.GetMacrossData(fileData, position, macrosDataEndPos);

            comCon.AddUnit(
                new StaticText(comCon, fileData.Substring(currentPosition, position - currentPosition)));
            if (currentMacros.IsCompositeMacross() && currentMacros.Name != "#elseif" && currentMacros.Name != "#else")
            {
                currentPosition = macrosDataEndPos + 1;
                TextUnit compositePart = PredefinedMacros.GetMacro(comCon, name, fileData, macrosData);
                comCon.AddUnit(compositePart);
                CompositeConstruction comp = (CompositeConstruction)compositePart;
                comp.StartPositionInFile = position;
                comp.Accept(this);
                position = currentPosition;
            }
            else
            {
                currentPosition = macrosDataEndPos + 1;
                if (currentMacros is UserDefinedMacross)
                {
                    UserDefinedMacross userDefined = (UserDefinedMacross)currentMacros;
                    TextUnit           comp        = new UserDefinedMacrosConstruction(comCon, userDefined, fileData, macrosData);
                    comCon.AddUnit(comp);
                    position = currentPosition;
                }
                else
                {
                    TextUnit comp = PredefinedMacros.GetMacro(comCon, name, fileData, macrosData);
                    comCon.AddUnit(comp);
                    position = currentPosition;
                }
            }
        }
예제 #2
0
        private void HandleElseConstructionAtPosition(IfConstruction ifCon, string name, ref int position)
        {
            ifCon.AddUnit(
                new StaticText(ifCon, fileData.Substring(currentPosition, position - currentPosition)));
            string macrosData = null;

            if (name == "#elseif")
            {
                int macrosDataEndPos = ParseUtilites.GetMacrosCloseBracketPosAfterMacroSep(fileData, position);
                macrosData      = ParseUtilites.GetMacrossData(fileData, position, macrosDataEndPos);
                currentPosition = macrosDataEndPos + 1;
            }
            else
            {
                currentPosition = currentPosition + "#else".Length;
            }
            ElseConstruction compositePart = (ElseConstruction)PredefinedMacros.GetMacro(ifCon, name, fileData, macrosData);

            compositePart.SetFatherIfConstruction(ifCon);
            ifCon.AddElseConstruction(compositePart);
            compositePart.StartPositionInFile = position;
            compositePart.Accept(this);
            position = currentPosition;
        }