Question on Parsing(I think)

Started by
1 comment, last by Peon 21 years, 3 months ago
If i want to make a math program (I am REALLY board), And I want it to be able to do take the problem some one writes and have the program do it how whould I do such a thing. example ( 7 = 2x + 7x^2 ) ^2 is squared some one told me this was called parsing, or that that was the techniqe used to od this, where can I find a tutorial on this, or a little help. Homepage Luck is a Horse to ride like any other...Luckily im not a gambler, I dont know how to ride. For any total noob out there Here is a like to my tutorials, thry them out
BoC HomepageLuck is a Horse to ride like any other...Luckily im not a gambler, I dont know how to ride.
Advertisement
Yup. Parsing is the process of breaking something down into smaller chunks - in this case, breaking the input string down into individual numbers/symbols or ''tokens,'' as they''re usually called.

In this sort of situation, you''d store the input in a char[] array, then set up a char * to point to the beginning of the array. You move through, looking at each (*char) and reading it into the appropriate place, and ++char each loop, until you''ve processed the whole string.

IMO though the stuff you''ll have more problems with here is the actual solving (as I''m assuming that''s aimed at being an algebra solver). You''ll need to think your data structures out pretty well...

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Quadratics are a piece of cake to solve thouh, especially with a computer (assumiung you parse it correctly)

Peon
Peon

This topic is closed to new replies.

Advertisement