Hi,
I want to make an interpreter but i´m having some problems with code.
Interpreter have to interpret when the user declares a var and recognize that the user want to declare a var.
Example:
user writes in the text-box2 -- "y = 2", or "r = 2"
I want that the interpreter create a variable with the value(string) given by user and assign the value(int, float, etc) given by user.
I have this code but it didn´t work:
private void button1_Click(object sender, EventArgs e)
{
string in1 = textBox2.Text;
string in2 = textBox2.Text;
float conv;
if (textBox2.Text == String.Format("{0} = {1}", in1, in2))
{
in1 = in2;
conv = Convert.ToInt32(in2);
textBox1.Text = String.Format("{0} = {1}", in1, in2);
}
}
and then the value of var (example: y") appears in the text-box1
example : text-box2 user writes -- "y = 3"
then, in text-box1 will appear this: "var created: y = 3"
I wonder if anyone can help me on this. :)