コード例 #1
0
ファイル: Translator.cs プロジェクト: Fuzzuca/Leggermente
        public void WriteConstant(CodeImage ci, ResultCode res)
        {
            VariableCollection vc = ci.Constant;

            res.AddBlankLine();
            for (int i = 0; i < vc.Count; i++)
            {
                res.AddLine("static const int " + vc[i].Name + " = new Variable(" + vc[i].Name + ", " + vc[i].Value + ");", lm);
            }
            res.AddBlankLine();
        }
コード例 #2
0
ファイル: Translator.cs プロジェクト: Fuzzuca/Leggermente
        //Metodi pubblici
        public ResultCode Translate(CodeType type, string Code, string[] PackagesPath, string ExoprtPath)
        {
            PackageCollection pc     = PackageCollection.LoadPackageByFile(PackagesPath, lm);
            CodeImage         code   = CodeImage.CreateCodeImage(Code, pc, type, lm);
            ResultCode        result = new ResultCode(ExoprtPath);

            if (lm.WithOutError)
            {
                for (int i = 0; i < code.Package.Count; i++)
                {
                    result.AddInclude(code.Package[i].Name, lm);
                }

                int general = pc.FirstIndexOf("GENERAL");
                if (general < 0)
                {
                    lm.Add("Cannot find the main package for the program execution");
                }
                else
                {
                    code.Package.Add(pc[general]);
                }

                result.AddBlankLine();

                if (code.Type == CodeType.Program)
                {
                    result.AddLine("namespace Leggermente.Programma{ class Program{", lm);
                }
                else
                {
                    result.AddLine("namespace Leggermente.lib." + code.PackageName + "{ class " + code.PackageName + "{", lm);
                }

                WriteConstant(code, result);
                if (lm.WithOutError)
                {
                    Parsing(code, result);
                }

                result.AddBlankLine();
                result.AddLine("} }", lm);

                WriteCsDocumets(result);
            }
            return(result);
        }
コード例 #3
0
ファイル: Translator.cs プロジェクト: Fuzzuca/Leggermente
        //Metodi privati
        public void Parsing(CodeImage ci, ResultCode res)
        {
            FunctionCollection fc = new FunctionCollection();

            for (int i = 0; i < ci.Section.Count; i++)
            {
                fc.Add(ci.Section[i].Function);
            }

            ParserFunction parser = new ParserFunction(ci.Constant, fc, ci.Package, res, lm);

            if (ci.Type == CodeType.Package)
            {
                WritePackageFile(ci.PackageName, fc, res.FileName);
            }

            for (int i = 0; i < ci.Section.Count; i++)
            {
                parser.AnalyzeFunction(ci.Section[i]);
            }
        }