well,there are two ways here,
1-writing your own parser,
2-using .NET classes(System.Text.RegularExpression)
---------
about way one,
1-you should write a Context-Free grammar for your statements,your grammars should be unambiguous(because it results more performances)
2-you should write a procedure acts like a Token(it reads every symbol(word) from your statement)
3-you should use a stack and push the first element of your grammar inside it,
4-then you call Token,if TopofStack is noneterminal you should select the right production from your grammar(according to the top of stack and Token)and pop that noneterminal and push other noneterminal Symbols...
if you follow this algorithm you will parse your string(even you can execute some other procedures during you parssing operation..)
this I told you could be very fast(O(n))...(because your context-free grammar was unambiguous)...also in every step of your parssing you can do some other operations according to your requirements in your program.
(this I told you is easy but you should be familiar with the concepts of Context-Free grammars,Scanner,Token,unambiguous Grammars,....)
----------
about way 2
I think you can look inside System.Text.RegularExpressions nemespace and use RegularExpressions for your statements.
_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
|