
-----------------------------------
The_Bean
Wed Sep 17, 2008 9:14 pm

String to Command?
-----------------------------------
Is there anyway to convert a string to a command?

example:
for a drawing program
the user inputs "Draw.FillOval(...)"
then have turing converts the string to a command and actually draws the circle

I actually need it for a graphing calculator, but that example is a bit easier to understand

-----------------------------------
[Gandalf]
Wed Sep 17, 2008 9:28 pm

RE:String to Command?
-----------------------------------
Mostly you would just use conditional statements for something like this, unless you're planning to create your own Turing interpreter in Turing.  If your goal is to create a graphing calculator, though, why do you need this at all?  Just get the function (say) that you want to graph and use the appropriate drawing commands accordingly.

-----------------------------------
Tony
Wed Sep 17, 2008 9:44 pm

RE:String to Command?
-----------------------------------
Though the function would still have to be interpreted. Which is more involving than simply conditional statements.

-----------------------------------
The_Bean
Wed Sep 17, 2008 9:48 pm

Re: String to Command?
-----------------------------------
when the user inputs:
y=(x-4)(x-3)^2(x+2)

and then somehow get from a string into

for x : -25..25
y:=(x-4)*(x-3)**2*(x+2)
Draw.Dot(x,y,7)
end for

-----------------------------------
Tony
Wed Sep 17, 2008 11:31 pm

RE:String to Command?
-----------------------------------
you're going to need a scanner -- fairly easy since there are very few symbols.

you're going to need a parser build a parse tree of the expression

you're going to need a way to evaluate that tree (should also be easy -- recursion + eval of basic algebra operations)
