public void WriteToFile(IProcessInstance proc, FinalFile file)
        {
            o2Mate.Expression expr   = new o2Mate.Expression();
            IData             result = expr.Evaluate(this.expression, proc.CurrentScope);

            if (result != null)
            {
                if (proc.CurrentScope.Exists(this.varName))
                {
                    IData d = proc.CurrentScope.GetVariable(this.varName);
                    d.Value        = result.ValueString;
                    d.IsComputable = result.IsComputable;
                }
                else
                {
                    proc.CurrentScope.Add(this.varName, result.ValueString, proc.Name, result.IsComputable);
                }
            }
            else
            {
                if (proc.CurrentScope.Exists(this.varName))
                {
                    IData d = proc.CurrentScope.GetVariable(this.varName);
                    d.Value        = "0";
                    d.IsComputable = true;
                }
                else
                {
                    proc.CurrentScope.Add(this.varName, "0", proc.Name, true);
                }
            }
            proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "affectation", this.varName));
        }
Exemple #2
0
 public void Convert(ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     this.cachedProc = proc;
     if (proc.CurrentScope.Exists("CrLf"))
     {
         this.crlf = proc.CurrentScope.GetVariable("CrLf");
     }
     else
     {
         this.crlf       = new Variable(proc.Name, true);
         this.crlf.Value = @"\r\n";
     }
     if (proc.CurrentScope.Exists(proc.DefaultWriter))
     {
         this.defaultWriter = proc.CurrentScope.GetVariable(proc.DefaultWriter);
         if (!this.defaultWriter.IsGlobal)
         {
             this.cachedComp.UpdateParameters(converter, proc, this.defaultWriter.Name, true);
         }
         if (this.parts != null)
         {
             foreach (ICompiler c in this.parts)
             {
                 c.Convert(converter, proc, file);
             }
         }
         else
         {
             converter.Convert(this);
         }
     }
 }
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentScope.Exists(proc.DefaultWriter))
     {
         string             writer = proc.CurrentScope.GetVariable(proc.DefaultWriter).ValueString;
         o2Mate.LocaleGroup lg     = new LocaleGroup();
         string             groupName;
         string             title;
         if (lg.ExtractGroupAndName(this.localeName, out groupName, out title))
         {
             ILocaleSet set      = lg.Get(groupName) as ILocaleSet;
             string     language = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
             try
             {
                 // lève une exception si l'élement n'existe pas
                 FinalFile.WriteToFile(ref writer, set.Get(title, language), this.enc);
             }
             catch
             {
                 FinalFile.WriteToFile(ref writer, this.localeName, this.enc);
             }
         }
         proc.CurrentScope.GetVariable(proc.DefaultWriter).Value = writer;
     }
 }
        private static string IndentText(string text, int indent, ref bool startLine)
        {
            string          output  = "";
            Regex           reg     = new Regex("((.*" + Environment.NewLine + ")|.*$)");
            MatchCollection matches = reg.Matches(text);

            foreach (Match m in matches)
            {
                if (!String.IsNullOrEmpty(m.Groups[1].Value))
                {
                    if (!startLine)
                    {
                        if (m.Groups[1].Value.EndsWith(Environment.NewLine))
                        {
                            startLine = true;
                        }
                        output += m.Groups[1].Value;
                    }
                    else
                    {
                        if (!m.Groups[1].Value.EndsWith(Environment.NewLine))
                        {
                            startLine = false;
                        }
                        output += FinalFile.Indent(indent) + m.Groups[1].Value;
                    }
                }
            }
            return(output);
        }
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentScope.Exists(this.varName))
     {
         if (proc.CurrentScope.Exists(proc.DefaultWriter))
         {
             string writer = proc.CurrentScope.GetVariable(proc.DefaultWriter).ValueString;
             FinalFile.WriteToFile(ref writer, proc.CurrentScope.GetVariable(this.varName).ValueString, this.enc);
             proc.CurrentScope.GetVariable(proc.DefaultWriter).Value = writer;
             proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "print variable", this.varName));
         }
     }
     else if (proc.CurrentDictionnaire.Exists(this.varName))
     {
         if (proc.CurrentDictionnaire.IsString(this.varName))
         {
             if (proc.CurrentScope.Exists(proc.DefaultWriter))
             {
                 string writer = proc.CurrentScope.GetVariable(proc.DefaultWriter).ValueString;
                 FinalFile.WriteToFile(ref writer, proc.CurrentDictionnaire.GetString(this.varName), this.enc);
                 proc.CurrentScope.GetVariable(proc.DefaultWriter).Value = writer;
                 proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "print string", this.varName));
             }
         }
     }
 }
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentDictionnaire.IsArray(this.tabName))
     {
         Array             arr    = proc.CurrentDictionnaire.GetArray(this.tabName) as Array;
         Fields            f      = null;
         o2Mate.Expression expr   = new o2Mate.Expression();
         IData             result = expr.Evaluate(this.expression, proc.CurrentScope);
         if (result != null)
         {
             if (result.ValueInt <= arr.Count)
             {
                 f = arr.Item(result.ValueInt) as Fields;
             }
         }
         else
         {
             if (arr.Count > 0)
             {
                 f = arr.Item(1) as Fields;
             }
         }
         if (f != null && f.Exists(this.fieldName))
         {
             if (proc.CurrentScope.Exists(proc.DefaultWriter))
             {
                 string writer = proc.CurrentScope.GetVariable(proc.DefaultWriter).ValueString;
                 FinalFile.WriteToFile(ref writer, f.GetString(this.fieldName), this.enc);
                 proc.CurrentScope.GetVariable(proc.DefaultWriter).Value = writer;
                 proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "print field", this.tabName, this.fieldName));
             }
         }
     }
 }
Exemple #7
0
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentDictionnaire.IsArray(this.tabName))
     {
         Object obj  = proc.CurrentDictionnaire.GetArray(this.tabName);
         Array  arr  = obj as Array;
         int    size = arr.Count;
         if (proc.CurrentScope.Exists(this.varName))
         {
             IData d = proc.CurrentScope.GetVariable(this.varName);
             d.Value        = size.ToString();
             d.IsComputable = false;
             proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "size", this.varName, this.tabName));
         }
         else
         {
             proc.CurrentScope.Add(this.varName, size.ToString(), proc.Name, false);
             proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "size", this.varName, this.tabName));
         }
     }
     else
     {
         if (proc.CurrentScope.Exists(this.varName))
         {
             IData d = proc.CurrentScope.GetVariable(this.varName);
             d.Value        = "0";
             d.IsComputable = false;
         }
         else
         {
             proc.CurrentScope.Add(this.varName, "0", proc.Name, true);
         }
     }
 }
Exemple #8
0
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentScope.Exists(proc.DefaultWriter))
     {
         string writer = proc.CurrentScope.GetVariable(proc.DefaultWriter).ValueString;
         FinalFile.Unindent(ref writer);
         proc.CurrentScope.GetVariable(proc.DefaultWriter).Value = writer;
     }
 }
Exemple #9
0
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentScope.Exists(proc.DefaultWriter))
     {
         string writer = proc.CurrentScope.GetVariable(proc.DefaultWriter).ValueString;
         FinalFile.WriteToFile(ref writer, this.text.Replace(Environment.NewLine, "").Replace("\\", "\\\\").Replace(" ", "").Replace("\t", "").Replace('·', ' ').Replace('¬', '\t').Replace("¶", Environment.NewLine), this.enc);
         proc.CurrentScope.GetVariable(proc.DefaultWriter).Value = writer;
         proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "print"));
     }
 }
Exemple #10
0
        public void Convert(ICodeConverter converter, IProcessInstance proc, FinalFile file)
        {
            // pas de test sur l'existence du tableau dans le dictionnaire
            IData res = Helper.ConvertNewExpression(this.cachedComp, proc, converter, this.expression);

            this.index = res.ValueString;
            // add a new variable or change an existing variable
            this.value = Helper.ConvertNewDictionaryArray(this.cachedComp, proc, converter, this.varName);
            converter.Convert(this);
        }
 public void Convert(ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     if (converter.ImplementedFunctions.Exists(new Predicate <IFunction>(delegate(IFunction f) { return(f.StrictName == this.processName); })))
     {
         converter.Convert(this);
     }
     else
     {
         throw new Exception("Pour convertir le programme, les processus doivent être implémentés avant leur exécution; le processus '" + this.processName + "' n'a pas été déclaré.");
     }
 }
Exemple #12
0
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentDictionnaire.IsArray(this.tabName))
     {
         Array             arr    = proc.CurrentDictionnaire.GetArray(this.tabName) as Array;
         o2Mate.Expression expr   = new o2Mate.Expression();
         IData             result = expr.Evaluate(this.expression, proc.CurrentScope);
         Fields            f      = null;
         if (result != null)
         {
             if (result.ValueInt <= arr.Count)
             {
                 f = arr.Item(result.ValueInt) as Fields;
             }
         }
         else
         {
             if (arr.Count > 0)
             {
                 f = arr.Item(1) as Fields;
             }
         }
         if (f != null && f.Exists(this.fieldName))
         {
             if (proc.CurrentScope.Exists(this.varName))
             {
                 IData d = proc.CurrentScope.GetVariable(this.varName);
                 d.Value        = f.GetString(this.fieldName);
                 d.IsComputable = false;
             }
             else
             {
                 proc.CurrentScope.Add(this.varName, f.GetString(this.fieldName), proc.Name, false);
                 proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "dictionary field", this.varName, this.tabName, this.fieldName));
             }
         }
         else
         {
             if (proc.CurrentScope.Exists(this.varName))
             {
                 IData d = proc.CurrentScope.GetVariable(this.varName);
                 d.Value        = "0";
                 d.IsComputable = false;
             }
             else
             {
                 proc.CurrentScope.Add(this.varName, "0", proc.Name, false);
             }
         }
     }
 }
 /// <summary>
 /// This method offers to augment indentation
 /// It keeps the number of indentation in a formatted string
 /// </summary>
 /// <param name="destination">formatted string data</param>
 public static void Indent(ref string destination)
 {
     try
     {
         string fileName;
         int    indent;
         bool   startLine;
         if (FinalFile.ExtractInfos(destination, out fileName, out indent, out startLine))
         {
             destination = "{\"" + fileName + "\"," + (indent + 1).ToString() + "," + startLine.ToString() + "}";
         }
     }
     catch { }
 }
        public void Convert(ICodeConverter converter, IProcessInstance proc, FinalFile file)
        {
            IData res = Helper.ConvertNewExpression(this.cachedComp, proc, converter, this.expression);

            this.index = res.ValueString;
            if (proc.CurrentScope.Exists(proc.DefaultWriter))
            {
                this.defaultWriter = proc.CurrentScope.GetVariable(proc.DefaultWriter);
                if (!this.defaultWriter.IsGlobal)
                {
                    this.cachedComp.UpdateParameters(converter, proc, this.defaultWriter.Name, true);
                }
                converter.Convert(this);
            }
        }
Exemple #15
0
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentDictionnaire.IsString(this.stringName))
     {
         if (proc.CurrentScope.Exists(this.varName))
         {
             IData d = proc.CurrentScope.GetVariable(this.varName);
             d.Value        = proc.CurrentDictionnaire.GetString(this.stringName);
             d.IsComputable = false;
         }
         else
         {
             proc.CurrentScope.Add(this.varName, proc.CurrentDictionnaire.GetString(this.stringName), proc.Name, false);
             proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "dictionary string", this.varName, this.stringName));
         }
     }
 }
        public void Convert(ICodeConverter converter, IProcess proc, FinalFile file)
        {
            Process  jobProc = new Process();
            Function f       = new Function();

            f.IsJob = true;
            f.Name  = this.jobName;
            // la première fonction commence à xxx_1
            f.InstanceNumber = converter.ImplementedFunctions.FindAll(new Predicate <IFunction>(delegate(IFunction func)
            {
                return(func.IsJob && func.StrictName == this.jobName);
            })).Count + 1;
            jobProc.Name         = ":" + f.Name;
            jobProc.FunctionName = f.Name;
            this.cachedComp.PushProcess(jobProc);
            converter.ImplementedFunctions.Add(f);
            converter.PushFunction(converter.CurrentFunction);
            converter.SetCurrentFunction(f);
        }
 /// <summary>
 /// This method works with a formatted string data
 /// The first data is the full path of the file where to write
 /// The second data is the number of indentation
 /// The thirth data says true when starting a new line
 /// </summary>
 /// <param name="destination">formatted data information</param>
 /// <param name="text">text to write</param>
 /// <param name="enc">encoding object</param>
 public static void WriteToFile(ref string destination, string text, Encoding enc)
 {
     try
     {
         string fileName;
         int    indent;
         bool   startLine;
         if (FinalFile.ExtractInfos(destination, out fileName, out indent, out startLine))
         {
             FileStream   fs = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Write);
             StreamWriter sw = new StreamWriter(fs, enc);
             sw.Write(FinalFile.IndentText(text, indent, ref startLine));
             sw.Dispose();
             fs.Dispose();
             destination = "{\"" + fileName + "\"," + indent.ToString() + "," + startLine.ToString() + "}";
         }
     }
     catch { }
 }
        public void WriteToFile(IProcessInstance proc, FinalFile file)
        {
            int nextPosition;

            o2Mate.Expression expr   = new o2Mate.Expression();
            IData             result = expr.Evaluate(this.expression, proc.CurrentScope);

            if (result != null)
            {
                if (result.ValueInt == 1)
                {
                    nextPosition = proc.GetPositionLabel(this.labelTrue);
                    proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "goto", this.labelTrue));
                }
                else
                {
                    nextPosition = proc.GetPositionLabel(this.labelFalse);
                    proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "goto", this.labelFalse));
                }
                proc.CurrentPositionExecution = nextPosition;
            }
        }
 public void Convert(ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     this.cachedProc = proc;
     if (proc.CurrentScope.Exists(this.varName))
     {
         this.isFromDict = false;
         this.value      = proc.CurrentScope.GetVariable(this.varName);
         // update parameters for this variable to use
         this.cachedComp.UpdateParameters(converter, proc, this.varName, false);
     }
     else if (proc.CurrentDictionnaire.IsString(this.varName))
     {
         this.isFromDict = true;
     }
     if (proc.CurrentScope.Exists(proc.DefaultWriter))
     {
         this.defaultWriter = proc.CurrentScope.GetVariable(proc.DefaultWriter);
         if (!this.defaultWriter.IsGlobal)
         {
             this.cachedComp.UpdateParameters(converter, proc, this.defaultWriter.Name, true);
         }
         converter.Convert(this);
     }
 }
Exemple #20
0
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     file.WriteToFile(Environment.NewLine, this.enc);
 }
Exemple #21
0
 /// <summary>
 /// Converts the object and write specific statements for an another programming language
 /// </summary>
 /// <param name="converter">the language converter</param>
 /// <param name="proc">current process</param>
 /// <param name="file">final file</param>
 public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
 }
Exemple #22
0
 /// <summary>
 /// Execute the object and write results onto the final file
 /// </summary>
 /// <param name="proc">current process</param>
 /// <param name="file">final file</param>
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
 }
 public void Convert(ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     this.result = Helper.ConvertNewInferedVariable(this.cachedComp, proc, converter, this.expression, this.varName);
     converter.Convert(this);
 }
 public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     proc.DefaultWriter = this.varName;
 }
 /// <summary>
 /// Process the statement and writes results in a file
 /// </summary>
 /// <param name="proc">process object</param>
 /// <param name="file">final file object</param>
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "declare template", this.Path, this.Name, this.Parameters));
 }
 /// <summary>
 /// Process the statement and writes results in a file
 /// </summary>
 /// <param name="proc">process object</param>
 /// <param name="file">final file object</param>
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "injector", this.Name));
 }
Exemple #27
0
        public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
        {
            o2Mate.Expression expr = new o2Mate.Expression();
            this.directories = new List <string>();
            for (int index = 0; index < this.filePath.Count - 1; ++index)
            {
                string expression = this.filePath[index];
                string path       = Helper.ConvertNewExpression(this.cachedComp, proc, converter, expression, EnumDataType.E_STRING_OBJECT);
                this.directories.Add(path);
            }
            this.fileName = new List <string>();
            {
                string   expression = this.filePath[this.filePath.Count - 1];
                string[] split      = expression.Split('.');
                foreach (string s in split)
                {
                    string path = Helper.ConvertNewExpression(this.cachedComp, proc, converter, s, EnumDataType.E_STRING_OBJECT);
                    this.fileName.Add(path);
                }
            }

            if (proc.CurrentScope.Exists(this.writerName))
            {
                this.newWriter = proc.CurrentScope.GetVariable(this.writerName);
                if (this.newWriter.TypeExists(EnumDataType.E_WRITER))
                {
                    proc.CurrentScope.Update(this.writerName, "", this.newWriter.PrefixInfo(EnumDataType.E_WRITER).BelongsTo, false, EnumDataType.E_WRITER);
                    this.cachedComp.UpdateParameters(converter, proc, this.writerName, true);
                }
                else
                {
                    this.newWriter = proc.CurrentScope.Update(this.writerName, "", proc.Name, false, EnumDataType.E_WRITER);
                    IStructure st = converter.CreateNewField(converter.RootStructureInstance, this.newWriter, false);
                    converter.CurrentFunction.LocalVariables.Add(st);
                }
            }
            else
            {
                this.newWriter = proc.CurrentScope.Add(this.writerName, "", proc.Name, false, EnumDataType.E_WRITER);
                IStructure st = converter.CreateNewField(converter.RootStructureInstance, this.newWriter, false);
                converter.CurrentFunction.LocalVariables.Add(st);
            }
            converter.Convert(this);
        }
Exemple #28
0
        public void WriteToFile(IProcessInstance proc, FinalFile file)
        {
            string fileName = FinalFile.BuildDirectory;

            for (int index = 0; index < this.filePath.Count - 1; ++index)
            {
                string            expression = this.filePath[index];
                o2Mate.Expression expr       = new o2Mate.Expression();
                o2Mate.IData      result     = expr.Evaluate(expression, proc.CurrentScope);
                string            value      = result.ValueString;
                foreach (char c in Path.GetInvalidPathChars())
                {
                    int position = -1;
                    if ((position = value.IndexOf(c)) != -1)
                    {
                        value = value.Substring(0, position) + value.Substring(position + 1);
                    }
                }
                fileName += value + Path.DirectorySeparatorChar;
                FinalFile.EnsureDirectoryCreated(fileName);
            }
            {
                string            expression = this.filePath[this.filePath.Count - 1];
                o2Mate.Expression expr       = new o2Mate.Expression();
                // le séparateur . permet d'utiliser des expressions
                string[] split = expression.Split('.');
                bool     first = true;
                foreach (string s in split)
                {
                    o2Mate.IData result = expr.Evaluate(s, proc.CurrentScope);
                    string       value  = result.ValueString;
                    foreach (char c in Path.GetInvalidFileNameChars())
                    {
                        int position = -1;
                        if ((position = value.IndexOf(c)) != -1)
                        {
                            value = value.Substring(0, position) + value.Substring(position + 1);
                        }
                    }
                    if (!first)
                    {
                        fileName += ".";
                    }
                    else
                    {
                        first = false;
                    }
                    fileName += value;
                }
            }
            FinalFile.EraseFile(fileName);
            if (proc.CurrentScope.Exists(this.writerName))
            {
                IData d = proc.CurrentScope.GetVariable(this.writerName);
                d.Value        = "{\"" + fileName + "\",0,true}";
                d.IsComputable = true;
                proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "create writer", this.writerName, fileName));
            }
            else
            {
                proc.CurrentScope.Add(this.writerName, "{\"" + fileName + "\",0,true}", proc.Name, true);
                proc.CurrentProject.Add(new ProjectItem(proc.Name, proc.CurrentPositionExecution, "create writer", this.writerName, fileName));
            }
        }
Exemple #29
0
 public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentScope.Exists(proc.DefaultWriter))
     {
         this.defaultWriter = proc.DefaultWriter;
         converter.Convert(this);
     }
 }
Exemple #30
0
 public void Convert(ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     this.value = Helper.ConvertNewDictionaryString(this.cachedComp, proc, converter, this.varName);
     converter.Convert(this);
 }