Esempio n. 1
0
        public override void CacheBlock(CommandBlock lBlock)
        {
            string lCommand = lBlock.elements[0].ToLower();

            if (lCommand == "codeblock")
            {
                replicationExportBlocks++;
                string lExportIdent = lBlock.elements[1];
                if (Program.IsValidIdent(lExportIdent))
                {
                    if (!mTemplates.ContainsKey(lExportIdent))
                    {
                        mTemplates[lExportIdent] = new CodeReplicationBlockPlugin(lBlock);
                    }
                    else
                    {
                        Console.WriteLine("ERROR: AUTA ident already exists: " + lExportIdent + ". File Path: " + lBlock.filePath.ToString());
                        mError = true;
                    }
                }
            }
            else if (lCommand == "replicate")
            {
                mProcessPaths.Add(lBlock.filePath);
            }
        }
 public override void CacheBlock(CommandBlock lBlock)
 {
     for (int i = 1; i < lBlock.lines.Count; ++i)
     {
         string lLine = lBlock.lines[i];
         if (templateTypes.AcceptedLine(lLine))
         {
             templateTypes.CacheLine(lLine);
         }
         else
         {
             if (templateLabels.AcceptedLine(lLine))
             {
                 var lLabelBlock = templateLabels.ExtractAUTABlock(lBlock.lines.ToList(), i, lBlock.filePath);
                 templateLabels.CacheBlock(lLabelBlock);
                 if (lLabelBlock.endIndex > i)
                 {
                     i = lLabelBlock.endIndex;
                 }
             }
             else
             {
                 var newFuncBody = new TemplateFunctions();
                 if (newFuncBody.AcceptedLine(lLine))
                 {
                     i = newFuncBody.CacheBlock(lBlock.lines, i, lBlock.filePath);
                     templateFunctions.Add(newFuncBody);
                 }
             }
         }
     }
 }
Esempio n. 3
0
 public override void CacheBlock(CommandBlock lBlock)
 {
     for (int i = 1; i < lBlock.lines.Count; ++i)
     {
         string lLine = lBlock.lines[i];
         if (mTypes.AcceptedLine(lLine))
         {
             mTypes.CacheLine(lLine);
         }
         else
         {
             if (mLabels.AcceptedLine(lLine))
             {
                 var lLabelBlock = mLabels.ExtractAUTABlock(lBlock.lines.ToList(), i, lBlock.filePath);
                 mLabels.CacheBlock(lLabelBlock);
                 if (lLabelBlock.endIndex > i)
                 {
                     i = lLabelBlock.endIndex;
                 }
             }
             else
             {
                 var lMatch = lImportScopeBlock.Match(lLine);
                 if (lMatch.Success)
                 {
                     mScopes.Add(lMatch.Groups[1].Value);
                 }
             }
         }
     }
 }
Esempio n. 4
0
        protected List <string> ExtractLabelSymbols(CommandBlock lBlock)
        {
            var   ltemplateLabels = new List <string>();
            Match lMatch          = LabelList.Match(lBlock.lines[0]);

            if (lMatch.Success)
            {
                if (templateLabels != null)
                {
                    mError = true;
                    Console.WriteLine("ERROR: Template Block Already has template labels : " + lBlock.filePath + " on line : ", lBlock.lines[0]);
                    return(null);
                }
                else
                {
                    var lMatches = ExtractLabels.Matches(lMatch.Groups[1].Value);
                    for (int i = 0; i < lMatches.Count; ++i)
                    {
                        ltemplateLabels.Add(lMatches[i].Groups[0].Value);
                    }
                }
            }
            else
            {
                mError = true;
                Console.WriteLine("ERROR: Failed to pass block : " + lBlock.lines[0]);
                return(null);
            }
            return(ltemplateLabels);
        }
Esempio n. 5
0
 public override void CacheBlock(CommandBlock lBlock)
 {
     foreach (var lLine in lBlock.lines)
     {
         CacheLine(lLine);
     }
 }
 public CodeReplicationBlockPlugin(CommandBlock lBlock)
 {
     codeTypes  = new TemplateTypes();
     codeLabels = new TemplateLabels();
     codeBlocks = new List <CodeBlockBodyPlugin>();
     CacheBlock(lBlock);
 }
        public override void CacheBlock(CommandBlock lBlock)
        {
            string lCommand = lBlock.elements[0].ToLower();

            if (lCommand == "exportgroup")
            {
                ++exportBlocks;
                string lExportIdent = lBlock.elements[1];
                if (Program.IsValidIdent(lExportIdent))
                {
                    if (lBlock.lines.Count > 2)
                    {
                        if (!mExports.ContainsKey(lExportIdent))
                        {
                            mExports[lExportIdent] = lBlock.lines.GetRange(1, lBlock.lines.Count - 2);
                        }
                        else
                        {
                            mExports[lExportIdent].AddRange(lBlock.lines.GetRange(1, lBlock.lines.Count - 2));
                        }
                    }
                    else
                    {
                        mError = true;
                        Console.WriteLine("ERROR: AUTA Block doesn't contain sufficient lines: " + lExportIdent);
                    }
                }
            }
            else if (lCommand == "importgroup")
            {
                mProcessPaths.Add(lBlock.filePath);
            }
        }
Esempio n. 8
0
        public override void CacheBlock(CommandBlock lBlock)
        {
            string lCommand = lBlock.elements[0].ToLower();

            if (lCommand == "function")
            {
                ++functionExportBlocks;
                string lExportIdent = lBlock.elements[1];
                if (Program.IsValidIdent(lExportIdent))
                {
                    if (!mTemplates.ContainsKey(lExportIdent))
                    {
                        mTemplates[lExportIdent] = new TemplateBlock();
                        mTemplates[lExportIdent].CacheBlock(lBlock);
                    }
                    else
                    {
                        Console.WriteLine("ERROR: AUTA ident already exists: " + lExportIdent);
                        mError = true;
                    }
                }
            }
            if (lCommand == "declare" || lCommand == "define" || lCommand == "instance" || lCommand == "specialise")
            {
                mProcessPaths.Add(lBlock.filePath);
            }
        }
Esempio n. 9
0
        public override void CacheBlock(CommandBlock lBlock)
        {
            string lCommand = lBlock.elements[0].ToLower();

            if (lCommand == "export")
            {
                ++exportBlocks;
                string lExportIdent = lBlock.elements[1];
                if (Program.IsValidIdent(lExportIdent))
                {
                    if (!mExports.ContainsKey(lExportIdent))
                    {
                        mExports[lExportIdent] = lBlock.lines;
                    }
                    else
                    {
                        Console.WriteLine("ERROR: AUTA ident already exists: " + lExportIdent);
                        mError = true;
                    }
                }
            }
            else if (lCommand == "import")
            {
                mProcessPaths.Add(lBlock.filePath);
            }
        }
Esempio n. 10
0
        public virtual CommandBlock ExtractAUTABlock(List <string> lines, int startIndex, string filePath)
        {
            string[] elements = ParseAUTABlockStart(lines[startIndex]);
            if (elements == null || (elements.Length > 2 && Program.IsValidIdent(elements[1])))
            {
                Console.WriteLine("ERROR: Bad AUTA block Started : " + filePath + ", line: " + startIndex.ToString() + " : " + lines[startIndex]);
                return(null);
            }
            else
            {
                var lNewBlock = new CommandBlock();
                lNewBlock.lines = new List <string>();
                lNewBlock.lines.Add(lines[startIndex]);
                lNewBlock.elements = elements;
                lNewBlock.filePath = filePath;

                for (int index = startIndex + 1; index < lines.Count; ++index)
                {
                    var lLine = lines[index];
                    lNewBlock.lines.Add(lLine);
                    if (ParseAUTAEnd(lLine, lNewBlock.elements[1]))
                    {
                        lNewBlock.endIndex = index;
                        return(lNewBlock);
                    }
                }
                Console.WriteLine("ERROR: AUTA block never terminated: " + filePath + ", line: " + startIndex.ToString() + " : " + lines[startIndex]);
            }
            return(null);
        }
Esempio n. 11
0
 public ScopeBlockBody(CommandBlock lBlock)
 {
     mLabels       = new TemplateLabels();
     mTypes        = new TemplateTypes();
     mScopeBodies  = new List <ScopeBlockBody>();
     mScopes       = new List <string>();
     LoopDetection = false;
     CacheBlock(lBlock);
 }
Esempio n. 12
0
        public string[] GenerateDefineText(CommandBlock lBlock)
        {
            List <string> lResult = new List <string>();

            foreach (var lFunction in templateFunctions)
            {
                lResult.AddRange(lFunction.GenerateDefinition());
            }
            lResult = templateLabels.DuplicateForLabels(lResult);
            return(lResult.ToArray());
        }
Esempio n. 13
0
        public virtual CommandBlock ExtractAUTABlock(List <string> lines, int startIndex, string filePath)
        {
            string[] elements = ParseAUTABlockStart(lines[startIndex]);
            if (elements == null || (elements.Length > 2 && Program.IsValidIdent(elements[1])))
            {
                Console.WriteLine("ERROR: Bad AUTA block Started : " + filePath + ", line: " + startIndex.ToString() + " : " + lines[startIndex]);
                return(null);
            }
            else
            {
                var lNewBlock = new CommandBlock();
                lNewBlock.lines = new List <string>();
                lNewBlock.lines.Add(lines[startIndex]);
                lNewBlock.elements = elements;
                lNewBlock.filePath = filePath;

                List <CommandInterface> mRecursivePlugins = new List <CommandInterface>();
                mRecursivePlugins.Add(this);

                for (int index = startIndex + 1; index < lines.Count; ++index)
                {
                    var lLine = lines[index];
                    lNewBlock.lines.Add(lLine);
                    var plugin = Program.GetPluginsList().FirstOrDefault(x => x.AcceptedLine(lLine));
                    if (plugin?.ParseAUTABlockStart(lines[index]) != null)
                    {
                        mRecursivePlugins.Add(plugin);
                    }
                    if (mRecursivePlugins.Last().ParseAUTAEnd(lLine, lNewBlock.elements[1]))
                    {
                        mRecursivePlugins.RemoveAt(mRecursivePlugins.Count - 1);
                        if (mRecursivePlugins.Count == 0)
                        {
                            lNewBlock.endIndex = index;
                            return(lNewBlock);
                        }
                    }
                }
                if (mRecursivePlugins.Count == 0)
                {
                    Console.WriteLine("ERROR: AUTA block never terminated: " + filePath + ", line: " + startIndex.ToString() + " : " + lines[startIndex]);
                }
                if (mRecursivePlugins.Count > 0)
                {
                    Console.WriteLine("ERROR: AUTA block contained un terminated AUTA blocks: " + filePath + ", line: " + startIndex.ToString() + " : " + lines[startIndex]);
                }
                if (mRecursivePlugins.Count < 0)
                {
                    Console.WriteLine("ERROR: AUTA block contained too many terminating AUTA commands: " + filePath + ", line: " + startIndex.ToString() + " : " + lines[startIndex]);
                }
            }
            return(null);
        }
Esempio n. 14
0
        public override void CacheBlock(CommandBlock lBlock)
        {
            lBlock.endIndex = -1;

            templateLabels = ExtractLabelSymbols(lBlock);
            if (templateLabels == null)
            {
                return;
            }

            ExtractLabelSets(lBlock);
        }
        public override string[] ProcessBlock(CommandBlock lBlock)
        {
            List <string> lResult = new List <string>();

            foreach (var lFunction in codeBlocks)
            {
                var lTemp = lFunction.ProcessBlock(lBlock).ToList();
                lTemp = codeLabels.DuplicateForLabels(lTemp);
                lResult.AddRange(codeTypes.DuplicateForAllTypes(lTemp));
            }
            return(lResult.ToArray());
        }
Esempio n. 16
0
        public string[] GenerateInstanceText(CommandBlock lBlock)
        {
            List <string> lResult = new List <string>();

            foreach (var lFunction in templateFunctions)
            {
                lResult.Add(StripDefaultParams(lFunction.GenerateInstantiation()));
            }
            lResult = templateLabels.DuplicateForLabels(lResult);
            lResult = templateTypes.DuplicateForTypes(lResult);
            return(lResult.ToArray());
        }
Esempio n. 17
0
        public override string[] ProcessBlock(CommandBlock lBlock)
        {
            string lCommand = lBlock.elements[0].ToLower();

            if (lCommand == "declare" || lCommand == "define" || lCommand == "instance" || lCommand == "specialise")
            {
                ++functionImportBlocks;
                string lExportIdent = lBlock.elements[1];
                if (Program.IsValidIdent(lExportIdent))
                {
                    if (mTemplates.ContainsKey(lExportIdent))
                    {
                        string[] lContents = null;
                        switch (lCommand)
                        {
                        case "declare":
                            lContents = mTemplates[lExportIdent].GenerateDeclareText(lBlock);
                            break;

                        case "define":
                            lContents = mTemplates[lExportIdent].GenerateDefineText(lBlock);
                            break;

                        case "instance":
                            lContents = mTemplates[lExportIdent].GenerateInstanceText(lBlock);
                            break;

                        case "specialise":
                            lContents = mTemplates[lExportIdent].GenerateSpecialisationText(lBlock);
                            break;

                        default:
                            return(null);
                        }
                        return(Program.ProcessExtraCommands(lBlock.lines[0], lContents.ToList()));
                    }
                    else
                    {
                        mError = true;
                        Console.WriteLine("ERROR: AUTA ident doesn't exist: " + lExportIdent);
                    }
                }
                else
                {
                    mError = true;
                    Console.WriteLine("ERROR: AUTA ident isn't valid: " + lExportIdent);
                }
            }
            return(null);
        }
Esempio n. 18
0
 public override string[] ProcessBlock(CommandBlock lBlock)
 {
     if (lBlock.elements[0].ToLower() == "replicate")
     {
         ++replicationImportBlocks;
         string lExportIdent = lBlock.elements[1];
         if (mTemplates.ContainsKey(lExportIdent))
         {
             return(Program.ProcessExtraCommands(lBlock.lines[0], mTemplates[lExportIdent].ProcessBlock(lBlock).ToList()));
         }
         else
         {
             mError = true;
             Console.WriteLine("ERROR: AUTA ident doesn't exist: " + lExportIdent);
         }
     }
     return(null);
 }
Esempio n. 19
0
 public override string[] ProcessBlock(CommandBlock lBlock)
 {
     if (lBlock.elements[0].ToLower() == "importgroup")
     {
         ++importBlocks;
         string lExportIdent = lBlock.elements[1];
         if (mExports.ContainsKey(lExportIdent))
         {
             return(Program.ProcessExtraCommands(lBlock.lines[0], mExports[lExportIdent]));
         }
         else
         {
             mError = true;
             Console.WriteLine("ERROR: AUTA ident doesn't exist: " + lExportIdent);
             return(null);
         }
     }
     return(null);
 }
Esempio n. 20
0
        public void ExtractLabelSets(CommandBlock lBlock)
        {
            for (int l = 0; l < lBlock.lines.Count; ++l)
            {
                var lLine = lBlock.lines[l];
                if (lEndMatch.IsMatch(lLine))
                {
                    lBlock.endIndex = l;
                    return;
                }

                var lLabelMatch = lLabelTags.Match(lLine);
                if (lLabelMatch.Success)
                {
                    string lLabelSetString = lLabelMatch.Groups[1].Value;
                    var    lMatches        = ExtractLabelContents.Matches(lLabelSetString);
                    if (lMatches.Count > 0)
                    {
                        List <string> lLabels = new List <string>();
                        for (int i = 0; i < lMatches.Count; ++i)
                        {
                            string lTemp = lMatches[i].Groups[1].Value;
                            lTemp = lTemp.Trim();
                            lTemp = lRemoveBackslashes.Replace(lTemp, "${1}");
                            lLabels.Add(lTemp);
                        }
                        if (templateLabelSets.Count > 0 && lLabels.Count != templateLabelSets[0].Count)
                        {
                            Console.WriteLine("ERROR: Label set size do not match previous label sets sizes : " + lBlock.filePath + " on line : " + lLine);
                            mError = true;
                        }
                        templateLabelSets.Add(lLabels);
                    }
                    else
                    {
                        Console.WriteLine("ERROR: Unable to extract labels : " + lBlock.filePath + " on line : " + lLine);
                        mError = true;
                    }
                }
            }
        }
 public override void CacheBlock(CommandBlock lBlock)
 {
     for (int i = 1; i < lBlock.lines.Count; ++i)
     {
         string lLine = lBlock.lines[i];
         if (codeTypes.AcceptedLine(lLine))
         {
             codeTypes.CacheLine(lLine);
         }
         else
         {
             if (codeLabels.AcceptedLine(lLine))
             {
                 var lLabelBlock = codeLabels.ExtractAUTABlock(lBlock.lines.ToList(), i, lBlock.filePath);
                 codeLabels.CacheBlock(lLabelBlock);
                 if (lLabelBlock.endIndex > i)
                 {
                     i = lLabelBlock.endIndex;
                 }
             }
             else
             {
                 var newFuncBody = new CodeBlockBodyPlugin();
                 if (newFuncBody.AcceptedLine(lLine))
                 {
                     var codeBlockBlock = newFuncBody.ExtractAUTABlock(lBlock.lines.ToList(), i, lBlock.filePath);
                     if (codeBlockBlock != null)
                     {
                         newFuncBody.CacheBlock(codeBlockBlock);
                         codeBlocks.Add(newFuncBody);
                     }
                     else
                     {
                         mError = true;
                     }
                 }
             }
         }
     }
 }
Esempio n. 22
0
        public override void CacheBlock(CommandBlock lBlock)
        {
            string lCommand = lBlock.elements[0].ToLower();

            if (lCommand == "scopeblock")
            {
                scopeBlocks++;
                string lExportIdent = lBlock.elements[1];
                if (Program.IsValidIdent(lExportIdent))
                {
                    if (!mScopes.ContainsKey(lExportIdent))
                    {
                        mScopes[lExportIdent] = new ScopeBlockBody(lBlock);
                    }
                    else
                    {
                        Console.WriteLine("ERROR: AUTA ident already exists: " + lExportIdent);
                        mError = true;
                    }
                }
            }
        }
Esempio n. 23
0
        public override void CacheBlock(CommandBlock lBlock)
        {
            string lCommand = lBlock.elements[0].ToLower();

            if (lCommand == "flagblock")
            {
                flagBlocks++;
                string lExportIdent = lBlock.elements[1];
                if (Program.IsValidIdent(lExportIdent))
                {
                    if (!mFlags.ContainsKey(lExportIdent))
                    {
                        mFlags[lExportIdent] = new FlagBlockBody(lBlock);
                    }
                    else
                    {
                        Console.WriteLine("ERROR: AUTA ident already exists: " + lExportIdent + ". File Path: " + lBlock.filePath.ToString());
                        mError = true;
                    }
                }
            }
        }
Esempio n. 24
0
        public override void CacheBlock(CommandBlock lBlock)
        {
            int Count = 0;

            for (int i = 1; i < lBlock.lines.Count; ++i)
            {
                string lLine  = lBlock.lines[i];
                var    lMatch = lFlagBlockRegex.Match(lLine.ToLower());
                if (lMatch.Success)
                {
                    if (lMatch.Captures[0].ToString() == "true")
                    {
                        Count++;
                        mFlagValue = true;
                    }
                    else
                    {
                        if (lMatch.Captures[0].ToString() == "false")
                        {
                            Count++;
                            mFlagValue = false;
                        }
                    }
                }
            }
            if (Count == 0)
            {
                mError = true;
                Console.WriteLine("ERROR: No true/false statements in FlagBlock : " + lBlock.lines[0]);
            }
            if (Count > 1)
            {
                mError = true;
                Console.WriteLine("ERROR: multiple true/false statements in FlagBlock : " + lBlock.lines[0]);
            }
        }
Esempio n. 25
0
 public override string[] ProcessBlock(CommandBlock lBlock)
 {
     return(codeBlockBody.ToArray());
 }
Esempio n. 26
0
 public override void CacheBlock(CommandBlock lBlock)
 {
     codeBlockBody = lBlock.lines.GetRange(1, lBlock.lines.Count - 2);
 }
Esempio n. 27
0
 public bool AcceptedBlock(CommandBlock lBlock)
 {
     return(AcceptedLine(lBlock.lines[0]));
 }
Esempio n. 28
0
 public abstract string[] ProcessBlock(CommandBlock lBlock);
Esempio n. 29
0
 public abstract void CacheBlock(CommandBlock lBlock);
Esempio n. 30
0
 public override void CacheBlock(CommandBlock lBlock)
 {
 }