Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Minyailov Oleh\nIS-92");

            double[] arr = new double[5];

            variable v1 = new variable(0, 2, 1);
            variable v2 = new variable(1, 1, 0);
            variable v3 = new variable(3, 23, 22);
            variable v4 = new variable(2, 8, 12);
            variable v5 = new variable(5, 6, 1);

            v1.calculate();
            v2.calculate();
            v3.calculate();
            v4.calculate();
            v5.calculate();

            arr[0] = v1.Res;
            arr[1] = v2.Res;
            arr[2] = v3.Res;
            arr[3] = v4.Res;
            arr[4] = v5.Res;

            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine(arr[i]);
            }

            //((2 * c) - d / 23) / (Math.Log(1 - (a / 4)));
        }
        // Recursively expand V.  The returned string is malloc'd.
        public static string recursively_expand_for_file(variable v)
        {
            string value = "";

            if (v.expanding)
            {
                if (v.exp_count == 0)
                {
                    // Expanding V causes infinite recursion.  Lose.
                    MessageBox.Show("Recursive variable (" + v.name + ") references itself (eventually) line(" + Read.LINENO + ")");
                }
                --v.exp_count;
            }

            v.expanding = true;
            if (v.append)
            {
                value = allocated_variable_append(v);
            }
            else
            {
                value = ExpandString(v.value);
            }
            v.expanding = false;

            return(value);
        }
Beispiel #3
0
        public void variable()
        {
            try
            {
                cnx = new cnx();
                rdr = cnx.ExecuteCommand("SELECT * FROM TC_VARIABLE WHERE ID_VARIABLE IN (1,2,3,4)", CommandType.Text);


                List <variable> list = new List <variable>();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        variable f = new variable()
                        {
                            id_variable = rdr["ID_VARIABLE"].ToString(),
                            descripcion = rdr["DESCRIPCION"].ToString()
                        };
                        list.Add(f);
                    }
                    rdr.Close();
                    rdr = null;
                    string data = JsonConvert.SerializeObject(list);
                    Context.Response.Write(data);
                    //return data;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        public string actividad(string actividad)
        {
            try
            {
                cnx = new cnx();
                rdr = cnx.ExecuteCommand("select a.ID_ACTIVIDAD, b.DESCRIPCION from DSC.TI_FUENTE_VARIABLE_ACTIVIDAD a  left join tc_actividad b on a.id_actividad = b.id_actividad where a.ID_FUENTE = 1 and a.ID_VARIABLE = 1 and a.ID_ACTIVIDAD_PADRE = " + actividad + "", CommandType.Text);


                List <variable> list = new List <variable>();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        variable f = new variable()
                        {
                            id_variable = rdr["ID_ACTIVIDAD"].ToString(),
                            descripcion = rdr["DESCRIPCION"].ToString()
                        };
                        list.Add(f);
                    }
                    rdr.Close();
                    rdr = null;
                    string data = JsonConvert.SerializeObject(list);
                    //Context.Response.Write(data);
                    return(data);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return("");
        }
Beispiel #5
0
        public string getVariable()
        {
            try
            {
                cnx = new cnx();
                rdr = cnx.ExecuteCommand("PR_OBTIENE_EMS_VARIABLES", CommandType.StoredProcedure);


                List <variable> list = new List <variable>();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        variable f = new variable()
                        {
                            id_variable = rdr["ID_VARIABLE"].ToString(),
                            descripcion = rdr["DESCRIPCION"].ToString()
                        };
                        list.Add(f);
                    }
                    rdr.Close();
                    rdr = null;
                    string data = JsonConvert.SerializeObject(list);
                    return(data);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return("");
        }
 public Location(float location)
 {
     this.location = location;
     if (0 <= location)
     {
         this.type = variable.pozitive;
     }
     else
     {
         this.type     = variable.negative;
         this.location = -1 * this.location;
     }
     if (this.location <= 2)
     {
         Yakin(this.location);
     }
     if (1 <= this.location && this.location <= 4)
     {
         Orta(this.location);
     }
     if (3 <= this.location)
     {
         Uzak(this.location);
     }
 }
        /* Define variable named NAME with value VALUE in SET.  VALUE is copied. LENGTH is the length of NAME, which does not need to be null-terminated.
         * ORIGIN specifies the origin of the variable (makefile, command line or environment).
         * If RECURSIVE is nonzero a flag is set in the variable saying that it should be recursively re-expanded.  */
        public static variable define_variable_in_set(string name, string value, variable_origin origin, bool recursive, Dictionary <string, variable> set)
        {
            Form1.UpdateVariablesTable(name, false);
            variable v;

            if (set == null)
            {
                set = current_variable_set_list;
            }

            if (set.ContainsKey(name))
            {
                v = set[name];
            }
            else
            {
                v      = new variable();
                v.name = name;
                set.Add(v.name, v);
                v.value       = value;
                v.special     = false;
                v.expanding   = false;
                v.exp_count   = 0;
                v.per_target  = false;
                v.append      = false;
                v.private_var = false;
                v.export      = variable_export.v_default;
                v.exportable  = true;
                if (name[0] != '_' && (name[0] < 'A' || name[0] > 'Z') && (name[0] < 'a' || name[0] > 'z'))
                {
                    v.exportable = false;
                }
                else
                {
                    int index = 1;
                    int temp;
                    for (; index < name.Length; index++)
                    {
                        if (name[index] != '_' && (name[index] < 'a' || name[index] > 'z') && (name[index] < 'A' || name[index] > 'Z') && !int.TryParse(name[index] + "", out temp))
                        {
                            break;
                        }
                    }
                    if (index != name.Length)
                    {
                        v.exportable = false;
                    }
                }
            }
            v.value        = value;
            v.origin       = origin;
            v.recursive    = recursive;
            v.unresolved   = false;
            v.isvaluegraph = false;
            v.printed      = false;
            return(v);
        }
 public static variable set_special_var(variable var)
 {
     if (var.name.Equals(Read.RECIPEPREFIX_NAME))
     {
         // The user is resetting the command introduction prefix.  This has to happen immediately, so that subsequent rules are interpreted properly.
         Read.TAB_CHAR = (var.value.Length == 0 ? Read.RECIPEPREFIX_DEFAULT : var.value[0]);
     }
     return(var);
 }
Beispiel #9
0
        public static variable FromDtoToEntity(variables1 v1)
        {
            variable v = new variable();

            v.variable_id   = v1.variable_id;
            v.name_v        = v1.name_v;
            v.default_shape = v1.default_shape;
            return(v);
        }
        public static variable define_unresolved_variable(string name, string value)
        {
            variable v = define_variable_in_set(name, name, variable_origin.o_file, false, current_variable_set_list);

            v.unresolved       = true;
            v.printed          = false;
            v.unresolved_value = value;
            return(v);
        }
Beispiel #11
0
    void instantiateListValue(int list, int index, int value)
    {
        GameObject a = GameObject.CreatePrimitive(PrimitiveType.Sphere);

        a.transform.SetParent(lists [list].transform);
        a.transform.localPosition = new Vector3(10f, 0f, (index + 1) * (5 / 6f));
        a.name = index.ToString();
        a.AddComponent <variable> ();
        a.GetComponent <variable>().value = value;

        GameObject c = new GameObject();

        c.name = "Canvas";
        c.AddComponent <Canvas> ();
        c.AddComponent <RectTransform> ();
        c.AddComponent <CanvasScaler> ();
        c.AddComponent <GraphicRaycaster> ();

        c.GetComponent <Canvas> ().renderMode = RenderMode.WorldSpace;
        c.transform.SetParent(a.transform);
        c.GetComponent <RectTransform> ().transform.localPosition = new Vector3(0f, 1f, 0f);
        c.GetComponent <RectTransform> ().transform.Rotate(new Vector3(0, -90, 0));

        c.GetComponent <RectTransform> ().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1);
        c.GetComponent <RectTransform> ().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1);
        //c.GetComponent<RectTransform> ().localScale = new Vector3 (1f, 1f, 1f);
        c.GetComponent <RectTransform> ().anchorMax = new Vector2(.5f, .5f);
        c.GetComponent <RectTransform> ().anchorMin = new Vector2(.5f, .5f);


        GameObject t = new GameObject();

        t.AddComponent <Text> ();
        t.GetComponent <Text>().text = value.ToString();
        t.name = "Text";
        t.GetComponent <Text>().fontSize  = 30;
        t.GetComponent <Text>().alignment = TextAnchor.LowerCenter;
        t.GetComponent <Text>().font      = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
        t.AddComponent <RectTransform> ();
        t.AddComponent <CanvasRenderer> ();

        t.transform.SetParent(c.transform);
        t.GetComponent <RectTransform> ().transform.localPosition = new Vector3(0f, 0f, 0f);
        t.GetComponent <RectTransform> ().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 300);
        t.GetComponent <RectTransform> ().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 100);
        t.GetComponent <RectTransform> ().anchorMax = new Vector2(.5f, .5f);
        t.GetComponent <RectTransform> ().anchorMin = new Vector2(.5f, .5f);
        t.GetComponent <RectTransform> ().transform.localRotation = Quaternion.identity;
        t.GetComponent <RectTransform> ().localScale = new Vector3(0.01f, 0.01f, 0.01f);

        nodes.Add(a);

        variable z = (variable)a.GetComponent(typeof(variable));

        z.Move(new Vector3(-10f, 0f, 0f));
    }
        /* Try to interpret LINE (a null-terminated string) as a variable definition.
         * ORIGIN may be o_file, o_override, o_env, o_env_override, or o_command specifying that the variable definition comes
         * from a makefile, an override directive, the environment with or without the -e switch, or the command line.
         *
         * See the comments for assign_variable_definition().
         * If LINE was recognized as a variable definition, a pointer to its `struct variable' is returned.
         * If LINE is not a variable definition, NULL is returned.  */
        public static variable try_variable_definition(string line, variable_origin origin, int target_var)
        {
            variable v = new variable();

            if (assign_variable_definition(ref v, line) == null)
            {
                return(null);
            }

            return(do_variable_definition(v.name, v.value, origin, v.flavor, target_var));
        }
        /* Try to interpret LINE (a null-terminated string) as a variable definition.
         * If LINE was recognized as a variable definition, a pointer to its `struct
         * variable' is returned.  If LINE is not a variable definition, NULL is returned.  */

        public static variable assign_variable_definition(ref variable v, string line)
        {
            string          beg    = "";
            variable_flavor flavor = new variable_flavor();
            string          name   = "";

            beg  = Utils.next_token(line);
            line = parse_variable_definition(beg, ref flavor);
            if (line == null)
            {
                return(null);
            }

            int endindex = 0;

            if (flavor == variable_flavor.f_append)
            {
                endindex = beg.IndexOf("+=");
            }
            else
            {
                if (flavor == variable_flavor.f_recursive)
                {
                    endindex = beg.IndexOf("=");
                }
                else
                {
                    endindex = beg.IndexOf(":=");
                    if (endindex < 0)
                    {
                        endindex = beg.IndexOf("?=");
                    }
                }
            }
            name = beg.Substring(0, endindex).Trim();


            line     = line.Trim();
            v.value  = line;
            v.flavor = flavor;

            // Expand the name, so "$(foo)bar = baz" works.
            v.name = ExpandString(name);

            if (v.name.Length == 0)
            {
                MessageBox.Show("Empty variable name - (" + (new StackFrame()).GetFileName() + " - " + (new StackFrame()).GetFileLineNumber() + ")");
            }
            return(v);
        }
        public static string allocated_variable_append(variable v)
        {
            string val = "";

            // Construct the appended variable value.
            string obuf = variable_buffer;
            int    olen = variable_buffer_length;

            variable_buffer        = "";
            val                    = variable_append(v.name, v.name.Length, current_variable_set_list);
            val                    = variable_buffer;
            variable_buffer        = obuf;
            variable_buffer_length = olen;
            return(val);
        }
Beispiel #15
0
        private ListaParametro getParametros(ParseTreeNode nodoParametros)
        {
            ListaParametro parametros = new ListaParametro();
            string         tipo, nombre;
            variable       nuevoParametro;

            foreach (ParseTreeNode item in nodoParametros.ChildNodes)
            {
                tipo           = item.ChildNodes[0].ChildNodes[0].Token.Value.ToString();
                nombre         = item.ChildNodes[1].Token.Value.ToString();
                nuevoParametro = new variable(nombre, tipo);
                parametros.addParametro(nuevoParametro);
            }

            return(parametros);
        }
        // Expand a simple reference to variable NAME, which is LENGTH chars long.
        public static string reference_variable(string name)
        {
            Form1.UpdateVariablesTable(name, true);
            variable v = lookup_variable(name);

            if (v == null)
            {
                v = do_variable_definition(name, "", variable_origin.o_file, variable_flavor.f_simple, 0);
                //MessageBox.Show("Undefined variable (" + name + ") line [" + Read.LINENO + "]!");
            }

            // If there's no variable by that name or it has no value, stop now.
            if (v == null || (v.value == "" && !v.append))
            {
                return("");
            }

            return(v.recursive? recursively_expand(v) : v.value);
        }
Beispiel #17
0
        private nodo_expresion get_id(nodo_expresion raiz)
        {
            variable variable = ejecutar.buscar_variable(raiz.valor);

            if (variable != null)
            {
                if (variable.valor.Equals(""))
                {
                    errores.errores.add_error("Error Semantico", "Variable \"" + raiz.valor + "\" no inicializada", raiz.fila, raiz.columna);
                    return(new nodo_expresion("error", "error", "error", raiz.fila, raiz.columna));
                }
                else
                {
                    return(new nodo_expresion(variable.valor, "terminal", variable.tipo, raiz.fila, raiz.columna));
                }
            }
            else
            {
                errores.errores.add_error("Error Semantico", "Variable \"" + raiz.valor + "\" no definida", raiz.fila, raiz.columna);
                return(new nodo_expresion("error", "error", "error", raiz.fila, raiz.columna));
            }
        }
Beispiel #18
0
        public string actividad(string actividad)
        {
            try
            {
                cnx = new cnx();

                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter()
                {
                    ParameterName = "@ID_ACTIVIDAD", Value = actividad
                };
                rdr = cnx.ExecuteCommand("PR_OBTIENE_EMS_ACTIVIDAD_ACTIVIDAD", CommandType.StoredProcedure, parameters);


                List <variable> list = new List <variable>();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        variable f = new variable()
                        {
                            id_variable = rdr["ID_ACTIVIDAD"].ToString(),
                            descripcion = rdr["DESCRIPCION"].ToString()
                        };
                        list.Add(f);
                    }
                    rdr.Close();
                    rdr = null;
                    string data = JsonConvert.SerializeObject(list);
                    return(data);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return("");
        }
Beispiel #19
0
 Construct(variable, fallback);
Beispiel #20
0
        List <Token> Scanner(List <string> splitCode)
        {
            List <Token>  output      = new List <Token>();
            List <string> identifiers = new List <string>(new string[] { "int", "float", "string", "double", "bool", "char" });
            List <string> symbols     = new List <string>(new string[] { "+", "-", "/", "%", "*", "(", ")", "{", "}", ",", ";", "&&",
                                                                         "||", "<", ">", "=", "!", "++", "==", ">=", "<=", "!=" });
            List <string> reservedWords = new List <string>(new string[] { "for", "while", "if", "do", "return", "break", "continue", "end" });
            bool          match         = false;


            for (int i = 0; i < splitCode.Count; i++)
            {
                if (identifiers.Contains(splitCode[i]) && match == false)
                {
                    output.Add(new Token(splitCode[i], "identifier"));
                    match = true;
                }
                if (symbols.Contains(splitCode[i]) && match == false)
                {
                    output.Add(new Token(splitCode[i], "symbol"));
                    match = true;
                }
                if (reservedWords.Contains(splitCode[i]) && match == false)
                {
                    output.Add(new Token(splitCode[i], "reserved word"));
                    match = true;
                }
                if (float.TryParse(splitCode[i], out _) && match == false)
                {
                    output.Add(new Token(splitCode[i], "number"));
                    match = true;
                }
                if (isValidVar(splitCode[i]) && match == false)
                {
                    variable pnn = new variable();
                    pnn.name = splitCode[i];
                    Lvar.Add(pnn);
                    output.Add(new Token(splitCode[i], "variable"));
                    match = true;
                }
                if (splitCode[i].StartsWith("'") && splitCode[i].EndsWith("'") && match == false)
                {
                    output.Add(new Token(splitCode[i], "string"));
                    match = true;
                }
                if (match == false)
                {
                    output.Add(new Token(splitCode[i], "unknown"));
                }
                match = false;
            }
            return(output);

            bool isValidVar(string v)
            {
                if (v.Length >= 1)
                {
                    if (char.IsLetter(v[0]) || v[0] == '_')
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #21
0
    variable myenum;     //Not Enum

    public static string Start(variable tmpval)
    {
        myenum = tmpval;
        return(string.Empty);    //this method needs a return value
    }
Beispiel #22
0
 void Awake()
 {
     _instance = this;
 }
Beispiel #23
0
 public variables1(variable p)
 {
     variable_id   = p.variable_id;
     name_v        = p.name_v;
     default_shape = p.default_shape;
 }
 new UnsupportedNatvisEntity(variable, item.GetType(), _logger));
 set => Set(variable, value);
Beispiel #26
0
    void incrementArrayValueByArrayIndex(int list, int index, int otherindex)
    {
        GameObject a = GameObject.CreatePrimitive(PrimitiveType.Sphere);

        a.transform.SetParent(lists [list].transform);
        a.transform.position = lists [list].transform.position + new Vector3(0f, 0f, (index + 1) * (5 / 6f));
        a.name = otherindex.ToString();
        a.AddComponent <variable> ();
        foreach (GameObject geo in nodes)
        {
            if (geo.name == index.ToString() && geo.transform.parent == lists[list].transform)
            {
                a.GetComponent <variable>().value = geo.GetComponent <variable>().value;
                break;
            }
        }


        GameObject c = new GameObject();

        c.name = "Canvas";
        c.AddComponent <Canvas> ();
        c.AddComponent <RectTransform> ();
        c.AddComponent <CanvasScaler> ();
        c.AddComponent <GraphicRaycaster> ();

        c.GetComponent <Canvas> ().renderMode = RenderMode.WorldSpace;
        c.transform.SetParent(a.transform);
        c.GetComponent <RectTransform> ().transform.localPosition = new Vector3(0f, 1f, 0f);
        c.GetComponent <RectTransform> ().transform.Rotate(new Vector3(0, -90, 0));

        c.GetComponent <RectTransform> ().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1);
        c.GetComponent <RectTransform> ().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1);
        //c.GetComponent<RectTransform> ().localScale = new Vector3 (1f, 1f, 1f);
        c.GetComponent <RectTransform> ().anchorMax = new Vector2(.5f, .5f);
        c.GetComponent <RectTransform> ().anchorMin = new Vector2(.5f, .5f);


        GameObject t = new GameObject();

        t.AddComponent <Text> ();
        t.GetComponent <Text>().text = a.GetComponent <variable>().value.ToString();
        t.name = "Text";
        t.GetComponent <Text>().fontSize  = 30;
        t.GetComponent <Text>().alignment = TextAnchor.LowerCenter;
        t.GetComponent <Text>().font      = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
        t.AddComponent <RectTransform> ();
        t.AddComponent <CanvasRenderer> ();

        t.transform.SetParent(c.transform);
        t.GetComponent <RectTransform> ().transform.localPosition = new Vector3(0f, 0f, 0f);
        t.GetComponent <RectTransform> ().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 300);
        t.GetComponent <RectTransform> ().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 100);
        t.GetComponent <RectTransform> ().anchorMax = new Vector2(.5f, .5f);
        t.GetComponent <RectTransform> ().anchorMin = new Vector2(.5f, .5f);
        t.GetComponent <RectTransform> ().transform.localRotation = Quaternion.identity;
        t.GetComponent <RectTransform> ().localScale = new Vector3(0.01f, 0.01f, 0.01f);

        variable z = (variable)a.GetComponent(typeof(variable));

        z.Move(new Vector3(0f, 0f, (otherindex - index) * (5 / 6f)));
        foreach (GameObject geo in nodes)
        {
            if (geo.name == otherindex.ToString() && geo.transform.parent == lists[list].transform)
            {
                a.GetComponent <variable>().value += geo.GetComponent <variable>().value;
                break;
            }
        }

        updateArrayValue(list, otherindex, a.GetComponent <variable> ().value);

        //a.SetActive (false);
    }
Beispiel #27
0
        /// <summary>
        ///  variable_analysis
        /// </summary>
        /// <param name="st"></param>

        private void variable_analysis(string st)//float x;
        {
            int    ind   = st.IndexOf(' ');
            string vtype = st.Substring(0, ind);

            st = st.Substring(ind);


            int i = 0;

            vname = "";
            while (st [i] != ';' && st [i] != '[' && st [i] != '(')
            {
                if (st [i] != ',')
                {
                    vname += st [i++].ToString();
                }
                else
                {
                    VAR [var_count] = new variable();
                    VAR [var_count].set_name(vname);
                    VAR [var_count++].set_type(vtype);
                    vname = "";
                    i++;
                }
            }
            VAR [var_count] = new variable();
            VAR [var_count].set_name(vname);
            VAR [var_count++].set_type(vtype);
            if (!st.Contains("[") /* && st[i] != '='*/ && st.Contains("(")) //for function
            {
                // call_fun_analysis(statment);
                if (st.Contains("(") && st.Contains("="))
                {
                    if (live_code == false)
                    {
                        File.AppendAllText("D:\\java.txt", statment + "\r\n");
                    }
                    else
                    {
                        txtresult.Text = statment + "\r\n";
                    }
                }
                else
                {
                    if (live_code == false)
                    {
                        if (pub.inside_class)
                        {
                            File.AppendAllText("D:\\java.txt", "public" + statment + "\r\n");
                        }
                        else
                        {
                            txtresult.Text += "public" + statment + "\r\n";
                        }
                    }
                    else
                    if (live_code == false)
                    {
                        File.AppendAllText("D:\\java.txt", "public static " + statment + "\r\n");
                    }
                    else
                    {
                        txtresult.Text += "public static " + statment + "\r\n";
                    }
                }
            }
            else if (st.Contains("["))
            {
                string arrsize = "";
                while (st [i] != ']')
                {
                    arrsize += st [i];
                    i++;
                }
                int newcount = var_count - 1;

                if (live_code == false)
                {
                    if (pub.inside_class)
                    {
                        File.AppendAllText("D:\\java.txt", "public " + VAR [newcount].get_type().Trim() + "[] " + VAR [newcount].get_name().Trim() + "= new " + VAR [newcount].get_type().Trim() + arrsize + "]" + "\r\n");
                    }

                    else
                    {
                        File.AppendAllText("D:\\java.txt", VAR [newcount].get_type().Trim() + "[] " + VAR [newcount].get_name().Trim() + "= new " + VAR [newcount].get_type().Trim() + arrsize + "]" + "\r\n");
                    }
                }
                else
                {
                    txtresult.Text += VAR [newcount].get_type().Trim() + "[] " + VAR [newcount].get_name().Trim() + "= new " + VAR [newcount].get_type().Trim() + arrsize + "]" + "\r\n";
                }
            }
            else

            if (live_code == false)
            {
                if (pub.inside_class)
                {
                    File.AppendAllText("D:\\java.txt", "public" + statment + "\r\n");
                }

                else
                {
                    File.AppendAllText("D:\\java.txt", statment + "\r\n");
                }
            }
            else
            {
                txtresult.Text += statment + "\r\n";
            }

            // File.AppendAllText("D:\\java.txt", VAR[var_count-1].get_type().Trim() + " " + VAR[var_count-1].get_name().Trim() + ";" + "\r\n");
        }
        /* Scan STRING for variable references and expansion-function calls.  Only LENGTH bytes of STRING are actually scanned.  If LENGTH is -1, scan until
         * a null byte is found.
         * Write the results to LINE, which must point into `variable_buffer'.  If LINE is NULL, start at the beginning of the buffer.
         * Return a pointer to LINE, or to the beginning of the buffer if LINE is NULL. */
        public static string ExpandString(string line)
        {
            string   result = "";
            variable v      = new variable();

            if (line.Trim().Length == 0)
            {
                return("");
            }
            for (int i = 0; i < line.Length; i++)
            {
                // Copy all following uninteresting chars all at once, and skip them.  Uninteresting chars end at the next $ or the end of the input.
                int index = line.IndexOf('$', i);
                if (index >= 0)
                {
                    result += line.Substring(i, index - i);
                }
                else
                {
                    result += line;
                    break;
                }
                i = index + 1;

                // Dispatch on the char that follows the $.
                switch (line[i])
                {
                case '$':
                    // $$ seen means output one $ to buffer.
                    result += line[i];
                    break;

                case '(':
                case '{':
                    // $(...) or ${...} is the general case of substitution.
                {
                    char openparen  = line[i];
                    char closeparen = (openparen == '(') ? ')' : '}';

                    string funcout  = "";
                    string funcline = line.Substring(i);
                    if (Functions.handle_function(ref funcout, ref funcline))
                    {
                        result += funcout;
                        line    = funcline;
                        i       = -1;   // because its gonna be 0, when breaking
                        break;
                    }

                    // Is there a variable reference inside the parens or braces? If so, expand it before expanding the entire reference.
                    int closeparenIndex = line.IndexOf(closeparen, i);
                    if (closeparenIndex < 0)
                    {
                        MessageBox.Show("Unterminated variable reference at line(" + Read.LINENO + ") should not be NULL");
                    }
                    string expandedString = "";
                    bool   stringExpanded = false;
                    if (line.Substring(i, closeparenIndex - i).IndexOf("$") > 0)
                    {
                        // BEG now points past the opening paren or brace. Count parens or braces until it is matched.
                        int count = 0;
                        int j;
                        for (j = i + 1; j < line.Length; j++)
                        {
                            if (line[j] == openparen)
                            {
                                ++count;
                            }
                            else if (line[j] == closeparen)
                            {
                                if (--count < 0)
                                {
                                    break;
                                }
                            }
                        }
                        // If COUNT is >= 0, there were unmatched opening parens or braces, so we go to the simple case of a variable name such as `$($(a)'.
                        if (count < 0)
                        {
                            // Exapnd the name
                            expandedString  = ExpandString(line.Substring(i + 1, j - (i + 1)));
                            line            = line.Substring(0, i + 1) + expandedString + line.Substring(j);
                            closeparenIndex = line.IndexOf(closeparen, i);
                            stringExpanded  = true;
                        }
                    }

                    /* This is not a reference to a built-in function and any variable references inside are now expanded.
                     * Is the resultant text a substitution reference? */
                    int colonIndex = line.IndexOf(':', i);
                    if (colonIndex >= 0 && colonIndex <= closeparenIndex)
                    {
                        // This looks like a substitution reference: $(FOO:A=B).
                        int equalIndex = line.IndexOf('=', colonIndex);
                        if (equalIndex < 0)
                        {
                            // This is an ordinary variable reference. Look up the value of the variable.
                            if (stringExpanded)
                            {
                                result += reference_variable(expandedString);
                            }
                            else
                            {
                                result += reference_variable(line.Substring(i + 1, colonIndex - i - 1));
                            }

                            if (closeparenIndex >= line.Length - 1)
                            {
                                line = "";
                            }
                            else
                            {
                                line = line.Substring(closeparenIndex + 1);
                            }
                            i = -1;         // because its gonna be 0, when breaking
                        }
                        else
                        {
                            // Extract the variable name before the colon and look up that variable.
                            v = lookup_variable(line.Substring(i + 1, colonIndex - i - 1));

                            if (v == null)
                            {
                                Form1.UpdateVariablesTable(line.Substring(i + 1, colonIndex - i - 1), true);
                            }
                            else
                            {
                                // Here, we refer to a variable, but without a reference
                                Form1.UpdateVariablesTable(v.name, true);
                            }
                            if (v == null)
                            {
                                MessageBox.Show("Undefined variable at line(" + Read.LINENO + ") should not be NULL");
                                if (closeparenIndex >= line.Length - 1)
                                {
                                    line = "";
                                }
                                else
                                {
                                    line = line.Substring(closeparenIndex + 1);
                                }
                                i = -1;         // because its gonna be 0, when breaking
                            }
                            // If the variable is not empty, perform the substitution.
                            if (v != null && v.value != null && v.value != "")
                            {
                                string pattern = "";
                                string replace = "";

                                string value = (v.recursive ? recursively_expand(v) : v.value);

                                // If we have $(foo:o=c) and foo variables resolves to UNRESOLVED variable
                                if (value.StartsWith("UNRESOLVED"))
                                {
                                    variable tmp = define_unresolved_variable(Utils.GetUnresolvedName(), "$(" + v.value + line.Substring(colonIndex, closeparenIndex - colonIndex + 1));
                                    result += tmp.name;
                                    if (closeparenIndex >= line.Length - 1)
                                    {
                                        line = "";
                                    }
                                    else
                                    {
                                        line = line.Substring(closeparenIndex + 1);
                                    }
                                    i = -1;         // because its gonna be 0, when breaking
                                    break;
                                }
                                // Copy the pattern and the replacement.  Add in an extra % at the beginning to use in case there isn't one in the pattern.
                                pattern = line.Substring(colonIndex + 1, line.IndexOf('=', colonIndex) - colonIndex - 1);
                                replace = line.Substring(equalIndex + 1, closeparenIndex - equalIndex - 1);

                                /*AHMED: Here we do the substituation $(foo:o=c) */
                                string[] values = value.Split(new char[] { ' ' });
                                for (int l = 0; l < values.Length; l++)
                                {
                                    result += PatternReplace(values[l], pattern, replace);
                                    if (l < values.Length - 1)
                                    {
                                        result += " ";
                                    }
                                }
                                if (closeparenIndex >= line.Length - 1)
                                {
                                    line = "";
                                }
                                else
                                {
                                    line = line.Substring(closeparenIndex + 1);
                                }
                                i = -1;         // because its gonna be 0, when breaking
                            }
                        }
                    }
                    else
                    {
                        // This is an ordinary variable reference. Look up the value of the variable.
                        result += reference_variable(line.Substring(i + 1, closeparenIndex - i - 1));
                        if (closeparenIndex >= line.Length - 1)
                        {
                            line = "";
                        }
                        else
                        {
                            line = line.Substring(closeparenIndex + 1);
                        }
                        i = -1;         // because its gonna be 0, when breaking
                    }
                    break;
                }

                default:
                {
                    // A $ followed by a random char is a variable reference: $a is equivalent to $(a).
                    result += reference_variable(line[i] + "");
                    if (i >= line.Length - 1)
                    {
                        line = "";
                    }
                    else
                    {
                        line = line.Substring(i + 1);
                    }
                    i = -1;         // because its gonna be 0, when breaking
                }

                break;
                }
            }
            return(result);
        }
 public static string recursively_expand(variable v)
 {
     return(recursively_expand_for_file(v));
 }